Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:13:03

0001 // -*- C++ -*-
0002 //
0003 // Package:     ServiceRegistry
0004 // Class  :     ServiceRegistry
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Mon Sep  5 13:33:19 EDT 2005
0011 //
0012 
0013 // user include files
0014 #include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
0015 
0016 // system include files
0017 
0018 namespace edm {
0019   //
0020   // constants, enums and typedefs
0021   //
0022 
0023   //
0024   // static data member definitions
0025   //
0026 
0027   //
0028   // constructors and destructor
0029   //
0030   ServiceRegistry::ServiceRegistry() {}
0031 
0032   // ServiceRegistry::ServiceRegistry(ServiceRegistry const& rhs) {
0033   //    // do actual copying here;
0034   // }
0035 
0036   ServiceRegistry::~ServiceRegistry() {}
0037 
0038   //
0039   // assignment operators
0040   //
0041   // ServiceRegistry const& ServiceRegistry::operator=(ServiceRegistry const& rhs) {
0042   //   //An exception safe implementation is
0043   //   ServiceRegistry temp(rhs);
0044   //   swap(rhs);
0045   //
0046   //   return *this;
0047   // }
0048 
0049   //
0050   // member functions
0051   //
0052   ServiceToken ServiceRegistry::setContext(ServiceToken const& iNewToken) {
0053     ServiceToken returnValue(manager_);
0054     manager_ = iNewToken.manager_;
0055     return returnValue;
0056   }
0057 
0058   void ServiceRegistry::unsetContext(ServiceToken const& iOldToken) { manager_ = iOldToken.manager_; }
0059 
0060   //
0061   // const member functions
0062   //
0063   ServiceToken ServiceRegistry::presentToken() const { return manager_; }
0064 
0065   //
0066   // static member functions
0067   //
0068 
0069   ServiceToken ServiceRegistry::createServicesFromConfig(std::unique_ptr<ParameterSet> params) {
0070     auto serviceSets = params->popVParameterSet(std::string("services"));
0071     //create the services
0072     return ServiceToken(ServiceRegistry::createSet(serviceSets));
0073   }
0074 
0075   ServiceToken ServiceRegistry::createSet(std::vector<ParameterSet>& iPS) {
0076     using namespace serviceregistry;
0077     auto returnValue = std::make_shared<ServicesManager>(iPS);
0078     return ServiceToken(returnValue);
0079   }
0080 
0081   ServiceToken ServiceRegistry::createSet(std::vector<ParameterSet>& iPS,
0082                                           ServiceToken iToken,
0083                                           serviceregistry::ServiceLegacy iLegacy,
0084                                           bool associate) {
0085     using namespace serviceregistry;
0086     auto returnValue = std::make_shared<ServicesManager>(iToken, iLegacy, iPS, associate);
0087     return ServiceToken(returnValue);
0088   }
0089 
0090   ServiceRegistry& ServiceRegistry::instance() {
0091     static thread_local ServiceRegistry s_registry;
0092     return s_registry;
0093   }
0094 }  // namespace edm