00001 // -*- C++ -*- 00002 // 00003 // Package: ServiceRegistry 00004 // Class : ServiceRegistry 00005 // 00006 // Implementation: 00007 // <Notes on implementation> 00008 // 00009 // Original Author: Chris Jones 00010 // Created: Mon Sep 5 13:33:19 EDT 2005 00011 // $Id: ServiceRegistry.cc,v 1.5 2007/06/29 03:43:25 wmtan Exp $ 00012 // 00013 00014 // system include files 00015 #include "boost/thread/tss.hpp" 00016 00017 // user include files 00018 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h" 00019 #include "FWCore/ParameterSet/interface/MakeParameterSets.h" 00020 00021 // 00022 // constants, enums and typedefs 00023 // 00024 00025 // 00026 // static data member definitions 00027 // 00028 00029 // 00030 // constructors and destructor 00031 // 00032 edm::ServiceRegistry::ServiceRegistry() 00033 { 00034 } 00035 00036 // ServiceRegistry::ServiceRegistry(const ServiceRegistry& rhs) 00037 // { 00038 // // do actual copying here; 00039 // } 00040 00041 edm::ServiceRegistry::~ServiceRegistry() 00042 { 00043 } 00044 00045 // 00046 // assignment operators 00047 // 00048 // const ServiceRegistry& ServiceRegistry::operator=(const ServiceRegistry& rhs) 00049 // { 00050 // //An exception safe implementation is 00051 // ServiceRegistry temp(rhs); 00052 // swap(rhs); 00053 // 00054 // return *this; 00055 // } 00056 00057 // 00058 // member functions 00059 // 00060 edm::ServiceToken 00061 edm::ServiceRegistry::setContext(const edm::ServiceToken& iNewToken) 00062 { 00063 edm::ServiceToken returnValue(manager_); 00064 manager_ = iNewToken.manager_; 00065 return returnValue; 00066 } 00067 00068 void 00069 edm::ServiceRegistry::unsetContext(const ServiceToken& iOldToken) 00070 { 00071 manager_ = iOldToken.manager_; 00072 } 00073 00074 // 00075 // const member functions 00076 // 00077 edm::ServiceToken 00078 edm::ServiceRegistry::presentToken() const 00079 { 00080 return manager_; 00081 } 00082 00083 // 00084 // static member functions 00085 // 00086 00087 edm::ServiceToken 00088 edm::ServiceRegistry::createServicesFromConfig(std::string const& config) { 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 } 00096 00097 edm::ServiceToken 00098 edm::ServiceRegistry::createSet(const std::vector<ParameterSet>& iPS) 00099 { 00100 using namespace edm::serviceregistry; 00101 boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iPS)); 00102 return edm::ServiceToken(returnValue); 00103 } 00104 edm::ServiceToken 00105 edm::ServiceRegistry::createSet(const std::vector<ParameterSet>& iPS, 00106 ServiceToken iToken, 00107 serviceregistry::ServiceLegacy iLegacy) 00108 { 00109 using namespace edm::serviceregistry; 00110 boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iToken,iLegacy,iPS)); 00111 return edm::ServiceToken(returnValue); 00112 } 00113 00114 edm::ServiceRegistry& 00115 edm::ServiceRegistry::instance() 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 }