CMS 3D CMS Logo

ServiceToken.h
Go to the documentation of this file.
1 #ifndef ServiceRegistry_ServiceToken_h
2 #define ServiceRegistry_ServiceToken_h
3 // -*- C++ -*-
4 //
5 // Package: ServiceRegistry
6 // Class : ServiceToken
7 //
18 //
19 // Original Author: Chris Jones
20 // Created: Tue Sep 6 18:31:44 EDT 2005
21 //
22 
23 // system include files
24 #include <memory>
25 
26 // user include files
27 
28 // forward declarations
29 class testServicesManager;
30 class TestServicesManagerOrder;
31 
32 namespace edm {
33  class ServiceRegistry;
34  class ActivityRegistry;
35 
36  namespace serviceregistry {
37  class ServicesManager;
38  }
39 
40  class ServiceWeakToken;
41 
42  class ServiceToken {
43  friend class edm::ServiceRegistry;
45  //for testing
46  friend class ::testServicesManager;
47  friend class ::TestServicesManagerOrder;
48 
49  public:
51  //virtual ~ServiceToken();
52  ServiceToken(ServiceToken&&) = default;
53  ServiceToken(ServiceToken const&) = default;
54  ServiceToken& operator=(ServiceToken&&) = default;
55  ServiceToken& operator=(ServiceToken const&) = default;
56 
57  // ---------- const member functions ---------------------
58 
59  // ---------- static member functions --------------------
60 
61  // ---------- member functions ---------------------------
62 
67 
72 
73  friend class ServiceWeakToken;
74 
75  private:
76  ServiceToken(std::shared_ptr<edm::serviceregistry::ServicesManager> iManager) : manager_(iManager) {}
77 
78  //ServiceToken(const ServiceToken&); // stop default
79 
80  //const ServiceToken& operator=(const ServiceToken&); // stop default
81 
82  // ---------- member data --------------------------------
83  std::shared_ptr<edm::serviceregistry::ServicesManager> manager_;
84  };
85 
87  public:
88  ServiceWeakToken(ServiceToken const& iToken) : manager_(iToken.manager_) {}
89  ServiceWeakToken() = default;
90 
92  ServiceWeakToken(ServiceWeakToken const&) = default;
94  ServiceWeakToken& operator=(ServiceWeakToken const&) = default;
95 
97  manager_ = iToken.manager_;
98  return *this;
99  }
100 
101  ServiceToken lock() const { return ServiceToken(manager_.lock()); }
102 
103  private:
104  std::weak_ptr<edm::serviceregistry::ServicesManager> manager_;
105  };
106 } // namespace edm
107 
108 #endif
edm::ServiceToken::copySlotsFrom
void copySlotsFrom(ActivityRegistry &)
the copy the argument's slots to the token's signals
Definition: ServiceToken.cc:74
edm::ServiceWeakToken
Definition: ServiceToken.h:86
edm::ServiceToken::copySlotsTo
void copySlotsTo(ActivityRegistry &)
copy our Service's slots to the argument's signals
Definition: ServiceToken.cc:69
ActivityRegistry
edm::ServiceToken::ServiceToken
ServiceToken()
Definition: ServiceToken.h:50
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ServiceWeakToken::ServiceWeakToken
ServiceWeakToken(ServiceToken const &iToken)
Definition: ServiceToken.h:88
ServiceRegistry
edm::serviceregistry::ServicesManager
Definition: ServicesManager.h:44
edm::ServiceToken::operator=
ServiceToken & operator=(ServiceToken &&)=default
edm::ServiceToken::connectTo
void connectTo(ActivityRegistry &)
the argument's signals are propagated to the Service's held by the token
Definition: ServiceToken.cc:58
edm::ServiceWeakToken::operator=
ServiceWeakToken & operator=(ServiceWeakToken &&)=default
edm::ServiceToken
Definition: ServiceToken.h:42
edm::ServiceWeakToken::ServiceWeakToken
ServiceWeakToken()=default
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
edm::ServiceToken::connect
void connect(ActivityRegistry &)
the argument's signals will forward the token's signals
Definition: ServiceToken.cc:63
edm::ServiceWeakToken::operator=
ServiceWeakToken & operator=(ServiceToken const &iToken)
Definition: ServiceToken.h:96
edm::ServiceToken::ServiceToken
ServiceToken(std::shared_ptr< edm::serviceregistry::ServicesManager > iManager)
Definition: ServiceToken.h:76
edm::ServiceWeakToken::lock
ServiceToken lock() const
Definition: ServiceToken.h:101
ServicesManager
edm::ServiceToken::manager_
std::shared_ptr< edm::serviceregistry::ServicesManager > manager_
Definition: ServiceToken.h:83
edm::ServiceRegistry
Definition: ServiceRegistry.h:38
edm::ServiceWeakToken::manager_
std::weak_ptr< edm::serviceregistry::ServicesManager > manager_
Definition: ServiceToken.h:104