CMS 3D CMS Logo

edm::ServiceRegistry Class Reference

#include <FWCore/ServiceRegistry/interface/ServiceRegistry.h>

List of all members.

Public Member Functions

template<class T>
T & get () const
template<class T>
bool isAvailable () const
ServiceToken presentToken () const
 The token can be passed to another thread in order to have the same services available in the other thread.
virtual ~ServiceRegistry ()

Static Public Member Functions

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)
template<class T>
static ServiceToken createContaining (std::auto_ptr< T > iService)
 create a service token that holds the service defined by iService
static ServiceToken createServicesFromConfig (const std::string &config)
static ServiceToken createSet (const std::vector< ParameterSet > &, ServiceToken, serviceregistry::ServiceLegacy)
static ServiceToken createSet (const 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

Classes

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.

00042 {
00043 }

ServiceRegistry::ServiceRegistry (  )  [private]

Definition at line 32 of file ServiceRegistry.cc.

00033 {
00034 }

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


Member Function Documentation

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 131 of file ServiceRegistry.h.

References edmplugin::standard::config().

00133                                                                                    {
00134             std::vector<edm::ParameterSet> config;
00135             boost::shared_ptr<serviceregistry::ServicesManager> manager( new serviceregistry::ServicesManager(iToken,
00136                                                                                                               iLegacy,
00137                                                                                                               config) );
00138             manager->put(iWrapper);
00139             return manager;
00140          }

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 124 of file ServiceRegistry.h.

References edmplugin::standard::config().

00124                                                                                                            {
00125             std::vector<edm::ParameterSet> config;
00126             boost::shared_ptr<serviceregistry::ServicesManager> manager( new serviceregistry::ServicesManager(config) );
00127             manager->put(iWrapper);
00128             return manager;
00129          }

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

Definition at line 110 of file ServiceRegistry.h.

References edmplugin::standard::config(), and wrapper.

00112                                                                                    {
00113             std::vector<edm::ParameterSet> config;
00114             boost::shared_ptr<serviceregistry::ServicesManager> manager( new serviceregistry::ServicesManager(iToken,
00115                                                                                                               iLegacy,
00116                                                                                                               config) );
00117             boost::shared_ptr<serviceregistry::ServiceWrapper<T> >
00118             wrapper(new serviceregistry::ServiceWrapper<T>(iService));
00119             manager->put(wrapper);
00120             return manager;
00121          }

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 101 of file ServiceRegistry.h.

References edmplugin::standard::config(), and wrapper.

Referenced by edm::EventProcessor::init(), and VisEventProcessorService::initEventProcessor().

00101                                                                       {
00102             std::vector<edm::ParameterSet> config;
00103             boost::shared_ptr<serviceregistry::ServicesManager> manager( new serviceregistry::ServicesManager(config) );
00104             boost::shared_ptr<serviceregistry::ServiceWrapper<T> >
00105                wrapper(new serviceregistry::ServiceWrapper<T>(iService));
00106             manager->put(wrapper);
00107             return manager;
00108          }

edm::ServiceToken ServiceRegistry::createServicesFromConfig ( const std::string &  config  )  [static]

Definition at line 88 of file ServiceRegistry.cc.

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

Referenced by HPDNoiseLibraryReader::initializeServices().

00088                                                                     {
00089    boost::shared_ptr<std::vector<ParameterSet> > pServiceSets;
00090    boost::shared_ptr<ParameterSet> params;
00091    edm::makeParameterSets(config, params, pServiceSets);
00092 
00093    //create the services
00094    return ServiceToken(edm::ServiceRegistry::createSet(*pServiceSets.get()));
00095 }

edm::ServiceToken ServiceRegistry::createSet ( const std::vector< ParameterSet > &  iPS,
ServiceToken  iToken,
serviceregistry::ServiceLegacy  iLegacy 
) [static]

Definition at line 105 of file ServiceRegistry.cc.

00108 {
00109    using namespace edm::serviceregistry;
00110    boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iToken,iLegacy,iPS));
00111    return edm::ServiceToken(returnValue);
00112 }

edm::ServiceToken ServiceRegistry::createSet ( const std::vector< ParameterSet > &  iPS  )  [static]

Definition at line 98 of file ServiceRegistry.cc.

Referenced by createServicesFromConfig(), cond::FWIncantation::FWIncantation(), edm::EventProcessor::init(), and evf::FUEventProcessor::initEventProcessor().

00099 {
00100    using namespace edm::serviceregistry;
00101    boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iPS));
00102    return edm::ServiceToken(returnValue);
00103 }

template<class T>
T& edm::ServiceRegistry::get ( void   )  const [inline]

Definition at line 66 of file ServiceRegistry.h.

References manager_, and edm::errors::NotFound.

00066                         {
00067             if(0 == manager_.get()) {
00068                throw edm::Exception(edm::errors::NotFound,"Service")
00069                <<" no ServiceRegistry has been set for this thread";
00070             }
00071             return manager_-> template get<T>();
00072          }

edm::ServiceRegistry & ServiceRegistry::instance ( void   )  [static]

Definition at line 115 of file ServiceRegistry.cc.

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

00116 {
00117    static boost::thread_specific_ptr<ServiceRegistry> s_registry;
00118    if(0 == s_registry.get()){
00119       s_registry.reset(new ServiceRegistry);
00120    }
00121    return *s_registry;
00122 }

template<class T>
bool edm::ServiceRegistry::isAvailable (  )  const [inline]

Definition at line 75 of file ServiceRegistry.h.

References manager_, and edm::errors::NotFound.

00075                                   {
00076             if(0 == manager_.get()) {
00077                throw edm::Exception(edm::errors::NotFound,"Service")
00078                <<" no ServiceRegistry has been set for this thread";
00079             }
00080             return manager_-> template isAvailable<T>();
00081          }

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.

References manager_.

00079 {
00080    return manager_;
00081 }

edm::ServiceToken ServiceRegistry::setContext ( const ServiceToken iNewToken  )  [private]

Definition at line 61 of file ServiceRegistry.cc.

References edm::ServiceToken::manager_, and manager_.

00062 {
00063    edm::ServiceToken returnValue(manager_);
00064    manager_ = iNewToken.manager_;
00065    return returnValue;
00066 }

void ServiceRegistry::unsetContext ( const ServiceToken iOldToken  )  [private]

Definition at line 69 of file ServiceRegistry.cc.

References edm::ServiceToken::manager_, and manager_.

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

00070 {
00071    manager_ = iOldToken.manager_;
00072 }


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]

Definition at line 92 of file HcalPedestalValidator.cc.

00092                                    {
00093 
00094 // CORAL required variables to be set, even if not needed
00095   if (!::getenv("CORAL_AUTH_USER")) ::putenv("CORAL_AUTH_USER=blaaah");
00096   if (!::getenv("CORAL_AUTH_PASSWORD")) ::putenv("CORAL_AUTH_PASSWORD=blaaah"); 
00097 
00098   Args args;
00099   args.defineParameter ("-p", "raw pedestals");
00100   args.defineParameter ("-w", "raw widths");
00101   args.defineParameter ("-run", "current run number <0>");
00102   args.defineParameter ("-ptag", "raw pedestal tag <NULL>");
00103   args.defineParameter ("-wtag", "raw width tag <ptag>");
00104   args.defineParameter ("-pref", "reference pedestals");
00105   args.defineParameter ("-wref", "reference widths");
00106   args.defineParameter ("-ptagref", "reference pedestal tag <NULL>");
00107   args.defineParameter ("-wtagref", "reference width tag <ptagref>");
00108   args.defineParameter ("-pval", "validated pedestals");
00109   args.defineParameter ("-wval", "validated widths");
00110   args.defineOption ("-help", "this help");
00111 
00112   args.parse (argn, argv);
00113   std::vector<std::string> arguments = args.arguments ();
00114   if (args.optionIsSet ("-help")) {
00115     args.printOptionsHelp ();
00116     return -1;
00117   }
00118 
00119 // read parameters from command line
00120   std::string RawPedSource = args.getParameter("-p");
00121   std::string RawPedWidSource = args.getParameter("-w");
00122   std::string RawPedTag = args.getParameter("-ptag").empty() ? "" : args.getParameter("-ptag");
00123   std::string RawPedWidTag = args.getParameter("-wtag").empty() ? RawPedTag : args.getParameter("-wtag");
00124   int RawPedRun = args.getParameter("-run").empty() ? 0 : (int)strtoll (args.getParameter("-run").c_str(),0,0);
00125   int RawPedWidRun = RawPedRun;
00126   std::string RefPedSource = args.getParameter("-pref");
00127   std::string RefPedWidSource = args.getParameter("-wref");
00128   std::string RefPedTag = args.getParameter("-ptagref").empty() ? "" : args.getParameter("-ptagref");
00129   std::string RefPedWidTag = args.getParameter("-wtagref").empty() ? RefPedTag : args.getParameter("-wtagref");
00130   int RefPedRun = RawPedRun;
00131   int RefPedWidRun = RefPedRun;
00132   std::string outputPedDest = args.getParameter("-pval");
00133   std::string outputPedWidDest = args.getParameter("-wval");
00134   std::string outputPedTag = "";
00135   std::string outputPedWidTag = "";
00136   int outputPedRun = RawPedRun;
00137   int outputPedWidRun = outputPedRun;
00138 
00139 // get reference objects
00140   HcalPedestals* RefPeds = 0;
00141   RefPeds = new HcalPedestals ();
00142   if (!getObject (RefPeds, RefPedSource, RefPedTag, RefPedRun)) {
00143     std::cerr << "HcalPedestalValidator-> Failed to get reference Pedestals" << std::endl;
00144     return 1;
00145   }
00146   HcalPedestalWidths* RefPedWids = 0;
00147   RefPedWids = new HcalPedestalWidths ();
00148   if (!getObject (RefPedWids, RefPedWidSource, RefPedWidTag, RefPedWidRun)) {
00149     std::cerr << "HcalPedestalValidator-> Failed to get reference PedestalWidths" << std::endl;
00150     return 2;
00151   }
00152 
00153 // get input raw objects
00154   HcalPedestals* RawPeds = 0;
00155   RawPeds = new HcalPedestals ();
00156   if (!getObject (RawPeds, RawPedSource, RawPedTag, RawPedRun)) {
00157     std::cerr << "HcalPedestalValidator-> Failed to get raw Pedestals" << std::endl;
00158     return 3;
00159   }
00160   HcalPedestalWidths* RawPedWids = 0;
00161   RawPedWids = new HcalPedestalWidths ();
00162   if (!getObject (RawPedWids, RawPedWidSource, RawPedWidTag, RawPedWidRun)) {
00163     std::cerr << "HcalPedestalValidator-> Failed to get raw PedestalWidths" << std::endl;
00164     return 4;
00165   }
00166 
00167 // make output objects
00168   HcalPedestals* outputPeds = 0;
00169   outputPeds = new HcalPedestals ();
00170   HcalPedestalWidths* outputPedWids = 0;
00171   outputPedWids = new HcalPedestalWidths ();
00172 
00173 // run algorithm
00174   int nstat[4]={2500,2500,2500,2500};
00175   int Flag=HcalPedestalAnalysis::HcalPedVal(nstat,RefPeds,RefPedWids,RawPeds,RawPedWids,outputPeds,outputPedWids);
00176 
00177   delete RefPeds;
00178   delete RefPedWids;
00179   delete RawPeds;
00180   delete RawPedWids;
00181 
00182 
00183 // store new objects if necessary
00184   if (Flag%100000>0) {
00185     if (outputPeds) {
00186       if (!putObject (&outputPeds, outputPedDest, outputPedTag, outputPedRun)) {
00187           std::cerr << "HcalPedestalAnalyzer-> Failed to put output Pedestals" << std::endl;
00188           return 5;
00189         }
00190     }
00191     if (outputPedWids) {
00192         if (!putObject (&outputPedWids, outputPedWidDest, outputPedWidTag, outputPedWidRun)) {
00193         std::cerr << "HcalPedestalAnalyzer-> Failed to put output PedestalWidths" << std::endl;
00194         return 6;
00195       }
00196     }
00197   }
00198   delete outputPeds;
00199   delete outputPedWids;
00200 
00201 return 0;
00202 }

friend class Operate [friend]

Definition at line 60 of file ServiceRegistry.h.


Member Data Documentation

boost::shared_ptr<serviceregistry::ServicesManager> edm::ServiceRegistry::manager_ [private]

Definition at line 154 of file ServiceRegistry.h.

Referenced by get(), isAvailable(), presentToken(), setContext(), and unsetContext().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:44:16 2009 for CMSSW by  doxygen 1.5.4