CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/FWCore/ServiceRegistry/src/ServiceRegistry.cc

Go to the documentation of this file.
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 //
00012 
00013 // user include files
00014 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
00015 #include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"
00016 
00017 // system include files
00018 #include "boost/thread/tss.hpp"
00019 
00020 namespace edm {
00021    //
00022    // constants, enums and typedefs
00023    //
00024 
00025    //
00026    // static data member definitions
00027    //
00028 
00029    //
00030    // constructors and destructor
00031    //
00032    ServiceRegistry::ServiceRegistry() {
00033    }
00034 
00035    // ServiceRegistry::ServiceRegistry(ServiceRegistry const& rhs) {
00036    //    // do actual copying here;
00037    // }
00038 
00039    ServiceRegistry::~ServiceRegistry() {
00040    }
00041 
00042    //
00043    // assignment operators
00044    //
00045    // ServiceRegistry const& ServiceRegistry::operator=(ServiceRegistry const& rhs) {
00046    //   //An exception safe implementation is
00047    //   ServiceRegistry temp(rhs);
00048    //   swap(rhs);
00049    //
00050    //   return *this;
00051    // }
00052 
00053    //
00054    // member functions
00055    //
00056    ServiceToken 
00057    ServiceRegistry::setContext(ServiceToken const& iNewToken) {
00058       ServiceToken returnValue(manager_);
00059       manager_ = iNewToken.manager_;
00060       return returnValue;
00061    }
00062 
00063    void 
00064    ServiceRegistry::unsetContext(ServiceToken const& iOldToken) {
00065       manager_ = iOldToken.manager_;
00066    }
00067 
00068    //
00069    // const member functions
00070    //
00071    ServiceToken 
00072    ServiceRegistry::presentToken() const {
00073       return manager_;
00074    }
00075 
00076    //
00077    // static member functions
00078    //
00079 
00080    ServiceToken
00081    ServiceRegistry::createServicesFromConfig(std::string const& config) {
00082       boost::shared_ptr<ParameterSet> params;
00083       makeParameterSets(config, params);
00084 
00085       std::auto_ptr<std::vector<ParameterSet> > serviceSets = params->popVParameterSet(std::string("services"));
00086       //create the services
00087       return ServiceToken(ServiceRegistry::createSet(*serviceSets));
00088    }
00089 
00090    ServiceToken 
00091    ServiceRegistry::createSet(std::vector<ParameterSet>& iPS) {
00092       using namespace serviceregistry;
00093       boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iPS));
00094       return ServiceToken(returnValue);
00095    }
00096 
00097    ServiceToken 
00098    ServiceRegistry::createSet(std::vector<ParameterSet>& iPS,
00099                                    ServiceToken iToken,
00100                                    serviceregistry::ServiceLegacy iLegacy,
00101                                    bool associate) {
00102       using namespace serviceregistry;
00103       boost::shared_ptr<ServicesManager> returnValue(new ServicesManager(iToken, iLegacy, iPS, associate));
00104       return ServiceToken(returnValue);
00105    }
00106 
00107    ServiceRegistry& 
00108    ServiceRegistry::instance() {
00109       static boost::thread_specific_ptr<ServiceRegistry> s_registry;
00110       if(0 == s_registry.get()){
00111          s_registry.reset(new ServiceRegistry);
00112       }
00113       return *s_registry;
00114    }
00115 }