CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ServiceRegistry.h
Go to the documentation of this file.
1 #ifndef ServiceRegistry_ServiceRegistry_h
2 #define ServiceRegistry_ServiceRegistry_h
3 // -*- C++ -*-
4 //
5 // Package: ServiceRegistry
6 // Class : ServiceRegistry
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Mon Sep 5 13:33:00 EDT 2005
19 //
20 
21 // user include files
26 
27 // system include files
28 #include <vector>
29 
30 // forward declarations
31 namespace edm {
32  class FwkImpl;
33  namespace serviceregistry {
34  template< typename T> class ServiceWrapper;
35  }
36 
38  public:
39 
40  class Operate {
41  public:
42  Operate(ServiceToken const& iToken) :
46  }
47 
48  //override operator new to stop use on heap?
49  private:
50  Operate(Operate const&); //stop default
51  Operate const& operator=(Operate const&); //stop default
53  };
54 
55  friend class edm::FwkImpl;
56  friend int main(int argc, char* argv[]);
57  friend class Operate;
58 
59  virtual ~ServiceRegistry();
60 
61  // ---------- const member functions ---------------------
62  template<typename T>
63  T& get() const {
64  if(0 == manager_.get()) {
66  "Service"
67  " no ServiceRegistry has been set for this thread");
68  }
69  return manager_-> template get<T>();
70  }
71 
72  template<typename T>
73  bool isAvailable() const {
74  if(0 == manager_.get()) {
76  "Service"
77  " no ServiceRegistry has been set for this thread");
78  }
79  return manager_-> template isAvailable<T>();
80  }
84  ServiceToken presentToken() const;
85  // ---------- static member functions --------------------
86  static ServiceRegistry& instance();
87 
88  // ---------- member functions ---------------------------
89 
91 
92  public: // Made public (temporarily) at the request of Emilio Meschi.
93  static ServiceToken createSet(std::vector<ParameterSet>&);
94  static ServiceToken createSet(std::vector<ParameterSet>&,
97  bool associate = true);
99  template<typename T>
100  static ServiceToken createContaining(std::auto_ptr<T> iService){
101  std::vector<edm::ParameterSet> config;
102  boost::shared_ptr<serviceregistry::ServicesManager> manager(new serviceregistry::ServicesManager(config));
103  boost::shared_ptr<serviceregistry::ServiceWrapper<T> >
105  manager->put(wrapper);
106  return manager;
107  }
108  template<typename T>
109  static ServiceToken createContaining(std::auto_ptr<T> iService,
110  ServiceToken iToken,
112  std::vector<edm::ParameterSet> config;
113  boost::shared_ptr<serviceregistry::ServicesManager> manager(new serviceregistry::ServicesManager(iToken,
114  iLegacy,
115  config));
116  boost::shared_ptr<serviceregistry::ServiceWrapper<T> >
118  manager->put(wrapper);
119  return manager;
120  }
122  template<typename T>
123  static ServiceToken createContaining(boost::shared_ptr<serviceregistry::ServiceWrapper<T> > iWrapper) {
124  std::vector<edm::ParameterSet> config;
125  boost::shared_ptr<serviceregistry::ServicesManager> manager(new serviceregistry::ServicesManager(config));
126  manager->put(iWrapper);
127  return manager;
128  }
129  template<typename T>
131  ServiceToken iToken,
133  std::vector<edm::ParameterSet> config;
134  boost::shared_ptr<serviceregistry::ServicesManager> manager(new serviceregistry::ServicesManager(iToken,
135  iLegacy,
136  config));
137  manager->put(iWrapper);
138  return manager;
139  }
140 
141 private:
142  //returns old token
143  ServiceToken setContext(ServiceToken const& iNewToken);
144  void unsetContext(ServiceToken const& iOldToken);
145 
146  ServiceRegistry();
147  ServiceRegistry(ServiceRegistry const&); // stop default
148 
149  ServiceRegistry const& operator=(ServiceRegistry const&); // stop default
150 
151  // ---------- member data --------------------------------
152  boost::shared_ptr<serviceregistry::ServicesManager> manager_;
153  };
154 }
155 
156 #endif
ServiceToken setContext(ServiceToken const &iNewToken)
boost::shared_ptr< serviceregistry::ServicesManager > manager_
ServiceToken presentToken() const
static ServiceToken createContaining(std::auto_ptr< T > iService)
create a service token that holds the service defined by iService
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
static ServiceToken createContaining(boost::shared_ptr< serviceregistry::ServiceWrapper< T > > iWrapper, ServiceToken iToken, serviceregistry::ServiceLegacy iLegacy)
static ServiceToken createServicesFromConfig(std::string const &config)
ServiceRegistry const & operator=(ServiceRegistry const &)
void unsetContext(ServiceToken const &iOldToken)
static ServiceRegistry & instance()
Operate(ServiceToken const &iToken)
friend int main(int argc, char *argv[])
static ServiceToken createSet(std::vector< ParameterSet > &)
static ServiceToken createContaining(std::auto_ptr< T > iService, ServiceToken iToken, serviceregistry::ServiceLegacy iLegacy)
tuple argc
Definition: dir2webdir.py:38
bool isAvailable() const
friend class edm::FwkImpl
static ServiceToken createContaining(boost::shared_ptr< serviceregistry::ServiceWrapper< T > > iWrapper)
create a service token that holds the service held by iWrapper
long double T
Operate const & operator=(Operate const &)
static HepMC::HEPEVT_Wrapper wrapper