CMS 3D CMS Logo

Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends

edm::ServiceRegistry Class Reference

#include <ServiceRegistry.h>

List of all members.

Classes

class  Operate

Public Member Functions

template<class T >
T & get () const
template<class T >
bool isAvailable () const
ServiceToken presentToken () const
virtual ~ServiceRegistry ()

Static Public Member Functions

template<class T >
static ServiceToken createContaining (std::auto_ptr< T > iService)
 create a service token that holds the service defined by iService
template<class T >
static ServiceToken createContaining (boost::shared_ptr< serviceregistry::ServiceWrapper< T > > iWrapper, ServiceToken iToken, serviceregistry::ServiceLegacy iLegacy)
template<class T >
static ServiceToken createContaining (boost::shared_ptr< serviceregistry::ServiceWrapper< T > > iWrapper)
 create a service token that holds the service held by iWrapper
template<class T >
static ServiceToken createContaining (std::auto_ptr< T > iService, ServiceToken iToken, serviceregistry::ServiceLegacy iLegacy)
static ServiceToken createServicesFromConfig (const std::string &config)
static ServiceToken createSet (std::vector< ParameterSet > &, ServiceToken, serviceregistry::ServiceLegacy)
static ServiceToken createSet (std::vector< ParameterSet > &)
static ServiceRegistryinstance ()

Private Member Functions

const ServiceRegistryoperator= (const ServiceRegistry &)
 ServiceRegistry (const ServiceRegistry &)
 ServiceRegistry ()
ServiceToken setContext (const ServiceToken &iNewToken)
void unsetContext (const ServiceToken &iOldToken)

Private Attributes

boost::shared_ptr
< serviceregistry::ServicesManager
manager_

Friends

class edm::FwkImpl
int main (int argc, char *argv[])
class Operate

Detailed Description

Definition at line 37 of file ServiceRegistry.h.


Constructor & Destructor Documentation

ServiceRegistry::~ServiceRegistry ( ) [virtual]

Definition at line 41 of file ServiceRegistry.cc.

{
}
ServiceRegistry::ServiceRegistry ( ) [private]

Definition at line 32 of file ServiceRegistry.cc.

{
}
edm::ServiceRegistry::ServiceRegistry ( const ServiceRegistry ) [private]

Member Function Documentation

template<class T >
static ServiceToken edm::ServiceRegistry::createContaining ( std::auto_ptr< T >  iService) [inline, static]

create a service token that holds the service defined by iService

Definition at line 103 of file ServiceRegistry.h.

References cmsDriver::config, and wrapper.

Referenced by edm::EventProcessor::init(), and main().

                                                                      {
            std::vector<edm::ParameterSet> config;
            boost::shared_ptr<serviceregistry::ServicesManager> manager( new serviceregistry::ServicesManager(config) );
            boost::shared_ptr<serviceregistry::ServiceWrapper<T> >
               wrapper(new serviceregistry::ServiceWrapper<T>(iService));
            manager->put(wrapper);
            return manager;
         }
template<class T >
static ServiceToken edm::ServiceRegistry::createContaining ( std::auto_ptr< T >  iService,
ServiceToken  iToken,
serviceregistry::ServiceLegacy  iLegacy 
) [inline, static]

Definition at line 112 of file ServiceRegistry.h.

References cmsDriver::config, and wrapper.

                                                                                   {
            std::vector<edm::ParameterSet> config;
            boost::shared_ptr<serviceregistry::ServicesManager> manager( new serviceregistry::ServicesManager(iToken,
                                                                                                              iLegacy,
                                                                                                              config) );
            boost::shared_ptr<serviceregistry::ServiceWrapper<T> >
            wrapper(new serviceregistry::ServiceWrapper<T>(iService));
            manager->put(wrapper);
            return manager;
         }
template<class T >
static ServiceToken edm::ServiceRegistry::createContaining ( boost::shared_ptr< serviceregistry::ServiceWrapper< T > >  iWrapper) [inline, static]

create a service token that holds the service held by iWrapper

Definition at line 126 of file ServiceRegistry.h.

References cmsDriver::config.

                                                                                                           {
            std::vector<edm::ParameterSet> config;
            boost::shared_ptr<serviceregistry::ServicesManager> manager( new serviceregistry::ServicesManager(config) );
            manager->put(iWrapper);
            return manager;
         }
template<class T >
static ServiceToken edm::ServiceRegistry::createContaining ( boost::shared_ptr< serviceregistry::ServiceWrapper< T > >  iWrapper,
ServiceToken  iToken,
serviceregistry::ServiceLegacy  iLegacy 
) [inline, static]

Definition at line 133 of file ServiceRegistry.h.

References cmsDriver::config.

                                                                                   {
            std::vector<edm::ParameterSet> config;
            boost::shared_ptr<serviceregistry::ServicesManager> manager( new serviceregistry::ServicesManager(iToken,
                                                                                                              iLegacy,
                                                                                                              config) );
            manager->put(iWrapper);
            return manager;
         }
edm::ServiceToken ServiceRegistry::createServicesFromConfig ( const std::string &  config) [static]

Definition at line 88 of file ServiceRegistry.cc.

References createSet(), and edm::makeParameterSets().

Referenced by HPDNoiseLibraryReader::initializeServices().

                                                                    {
   boost::shared_ptr<std::vector<ParameterSet> > pServiceSets;
   boost::shared_ptr<ParameterSet> params;
   edm::makeParameterSets(config, params, pServiceSets);

   //create the services
   return ServiceToken(edm::ServiceRegistry::createSet(*pServiceSets.get()));
}
edm::ServiceToken ServiceRegistry::createSet ( std::vector< ParameterSet > &  iPS) [static]

Definition at line 98 of file ServiceRegistry.cc.

Referenced by createServicesFromConfig(), cond::FWIncantation::FWIncantation(), edm::EventProcessor::init(), evf::FWEPWrapper::init(), and cond::Utilities::initializePluginManager().

{
   using namespace edm::serviceregistry;
   boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iPS));
   return edm::ServiceToken(returnValue);
}
edm::ServiceToken ServiceRegistry::createSet ( std::vector< ParameterSet > &  iPS,
ServiceToken  iToken,
serviceregistry::ServiceLegacy  iLegacy 
) [static]

Definition at line 105 of file ServiceRegistry.cc.

{
   using namespace edm::serviceregistry;
   boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iToken,iLegacy,iPS));
   return edm::ServiceToken(returnValue);
}
template<class T >
T& edm::ServiceRegistry::get ( void  ) const [inline]

Definition at line 66 of file ServiceRegistry.h.

References manager_, edm::errors::NotFound, and edm::Exception::throwThis().

                        {
            if(0 == manager_.get()) {
               Exception::throwThis(errors::NotFound,
                "Service"
                " no ServiceRegistry has been set for this thread");
            }
            return manager_-> template get<T>();
         }
edm::ServiceRegistry & ServiceRegistry::instance ( void  ) [static]

Definition at line 115 of file ServiceRegistry.cc.

Referenced by edm::EventProcessor::init(), edm::Service< SiStripCondObjBuilderFromDb >::isAvailable(), edm::Service< SiStripCondObjBuilderFromDb >::operator*(), edm::Service< SiStripCondObjBuilderFromDb >::operator->(), and edm::ServiceRegistry::Operate::~Operate().

{
   static boost::thread_specific_ptr<ServiceRegistry> s_registry;
   if(0 == s_registry.get()){
      s_registry.reset(new ServiceRegistry);
   }
   return *s_registry;
}
template<class T >
bool edm::ServiceRegistry::isAvailable ( ) const [inline]

Definition at line 76 of file ServiceRegistry.h.

References manager_, edm::errors::NotFound, and edm::Exception::throwThis().

                                  {
            if(0 == manager_.get()) {
               Exception::throwThis(errors::NotFound,
                "Service"
                " no ServiceRegistry has been set for this thread");
            }
            return manager_-> template isAvailable<T>();
         }
const ServiceRegistry& edm::ServiceRegistry::operator= ( const ServiceRegistry ) [private]
edm::ServiceToken ServiceRegistry::presentToken ( ) const

The token can be passed to another thread in order to have the same services available in the other thread.

Definition at line 78 of file ServiceRegistry.cc.

{
   return manager_;
}
edm::ServiceToken ServiceRegistry::setContext ( const ServiceToken iNewToken) [private]

Definition at line 61 of file ServiceRegistry.cc.

References edm::ServiceToken::manager_.

{
   edm::ServiceToken returnValue(manager_);
   manager_ = iNewToken.manager_;
   return returnValue;
}
void ServiceRegistry::unsetContext ( const ServiceToken iOldToken) [private]

Definition at line 69 of file ServiceRegistry.cc.

References edm::ServiceToken::manager_.

Referenced by edm::ServiceRegistry::Operate::~Operate().

{
   manager_ = iOldToken.manager_;
}

Friends And Related Function Documentation

friend class edm::FwkImpl [friend]

Definition at line 58 of file ServiceRegistry.h.

int main ( int  argc,
char *  argv[] 
) [friend]

------------------ CALO JETS ------------------

------------------ PF JETS ------------------

Definition at line 92 of file HcalPedestalValidator.cc.

                                   {

// CORAL required variables to be set, even if not needed
  const char* foo1 = "CORAL_AUTH_USER=blaaah";
  const char* foo2 = "CORAL_AUTH_PASSWORD=blaaah";
  if (!::getenv("CORAL_AUTH_USER")) ::putenv(const_cast<char*>(foo1));
  if (!::getenv("CORAL_AUTH_PASSWORD")) ::putenv(const_cast<char*>(foo2)); 

  Args args;
  args.defineParameter ("-p", "raw pedestals");
  args.defineParameter ("-w", "raw widths");
  args.defineParameter ("-run", "current run number <0>");
  args.defineParameter ("-ptag", "raw pedestal tag <NULL>");
  args.defineParameter ("-wtag", "raw width tag <ptag>");
  args.defineParameter ("-pref", "reference pedestals");
  args.defineParameter ("-wref", "reference widths");
  args.defineParameter ("-ptagref", "reference pedestal tag <NULL>");
  args.defineParameter ("-wtagref", "reference width tag <ptagref>");
  args.defineParameter ("-pval", "validated pedestals");
  args.defineParameter ("-wval", "validated widths");
  args.defineOption ("-help", "this help");

  args.parse (argn, argv);
  std::vector<std::string> arguments = args.arguments ();
  if (args.optionIsSet ("-help")) {
    args.printOptionsHelp ();
    return -1;
  }

// read parameters from command line
  std::string RawPedSource = args.getParameter("-p");
  std::string RawPedWidSource = args.getParameter("-w");
  std::string RawPedTag = args.getParameter("-ptag").empty() ? "" : args.getParameter("-ptag");
  std::string RawPedWidTag = args.getParameter("-wtag").empty() ? RawPedTag : args.getParameter("-wtag");
  int RawPedRun = args.getParameter("-run").empty() ? 0 : (int)strtoll (args.getParameter("-run").c_str(),0,0);
  int RawPedWidRun = RawPedRun;
  std::string RefPedSource = args.getParameter("-pref");
  std::string RefPedWidSource = args.getParameter("-wref");
  std::string RefPedTag = args.getParameter("-ptagref").empty() ? "" : args.getParameter("-ptagref");
  std::string RefPedWidTag = args.getParameter("-wtagref").empty() ? RefPedTag : args.getParameter("-wtagref");
  int RefPedRun = RawPedRun;
  int RefPedWidRun = RefPedRun;
  std::string outputPedDest = args.getParameter("-pval");
  std::string outputPedWidDest = args.getParameter("-wval");
  std::string outputPedTag = "";
  std::string outputPedWidTag = "";
  int outputPedRun = RawPedRun;
  int outputPedWidRun = outputPedRun;

// get reference objects
  HcalPedestals* RefPeds = 0;
  RefPeds = new HcalPedestals ();
  if (!getObject (RefPeds, RefPedSource, RefPedTag, RefPedRun)) {
    std::cerr << "HcalPedestalValidator-> Failed to get reference Pedestals" << std::endl;
    return 1;
  }
  HcalPedestalWidths* RefPedWids = 0;
  RefPedWids = new HcalPedestalWidths ();
  if (!getObject (RefPedWids, RefPedWidSource, RefPedWidTag, RefPedWidRun)) {
    std::cerr << "HcalPedestalValidator-> Failed to get reference PedestalWidths" << std::endl;
    return 2;
  }

// get input raw objects
  HcalPedestals* RawPeds = 0;
  RawPeds = new HcalPedestals ();
  if (!getObject (RawPeds, RawPedSource, RawPedTag, RawPedRun)) {
    std::cerr << "HcalPedestalValidator-> Failed to get raw Pedestals" << std::endl;
    return 3;
  }
  HcalPedestalWidths* RawPedWids = 0;
  RawPedWids = new HcalPedestalWidths ();
  if (!getObject (RawPedWids, RawPedWidSource, RawPedWidTag, RawPedWidRun)) {
    std::cerr << "HcalPedestalValidator-> Failed to get raw PedestalWidths" << std::endl;
    return 4;
  }

// make output objects
  HcalPedestals* outputPeds = 0;
  outputPeds = new HcalPedestals ();
  HcalPedestalWidths* outputPedWids = 0;
  outputPedWids = new HcalPedestalWidths ();

// run algorithm
  int nstat[4]={2500,2500,2500,2500};
  int Flag=HcalPedestalAnalysis::HcalPedVal(nstat,RefPeds,RefPedWids,RawPeds,RawPedWids,outputPeds,outputPedWids);

  delete RefPeds;
  delete RefPedWids;
  delete RawPeds;
  delete RawPedWids;


// store new objects if necessary
  if (Flag%100000>0) {
    if (outputPeds) {
      if (!putObject (&outputPeds, outputPedDest, outputPedTag, outputPedRun)) {
          std::cerr << "HcalPedestalAnalyzer-> Failed to put output Pedestals" << std::endl;
          return 5;
        }
    }
    if (outputPedWids) {
        if (!putObject (&outputPedWids, outputPedWidDest, outputPedWidTag, outputPedWidRun)) {
        std::cerr << "HcalPedestalAnalyzer-> Failed to put output PedestalWidths" << std::endl;
        return 6;
      }
    }
  }
  delete outputPeds;
  delete outputPedWids;

return 0;
}
friend class Operate [friend]

Definition at line 60 of file ServiceRegistry.h.


Member Data Documentation

Definition at line 156 of file ServiceRegistry.h.

Referenced by get(), and isAvailable().