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
std::weak_ptr< edm::serviceregistry::ServicesManager > manager_
Definition: ServiceToken.h:104
void connectTo(ActivityRegistry &)
the argument&#39;s signals are propagated to the Service&#39;s held by the token
Definition: ServiceToken.cc:58
ServiceWeakToken(ServiceToken const &iToken)
Definition: ServiceToken.h:88
ServiceToken(std::shared_ptr< edm::serviceregistry::ServicesManager > iManager)
Definition: ServiceToken.h:76
ServiceWeakToken & operator=(ServiceWeakToken &&)=default
void copySlotsFrom(ActivityRegistry &)
the copy the argument&#39;s slots to the token&#39;s signals
Definition: ServiceToken.cc:74
void copySlotsTo(ActivityRegistry &)
copy our Service&#39;s slots to the argument&#39;s signals
Definition: ServiceToken.cc:69
ServiceWeakToken()=default
ServiceToken lock() const
Definition: ServiceToken.h:101
ServiceWeakToken & operator=(ServiceToken const &iToken)
Definition: ServiceToken.h:96
ServiceToken & operator=(ServiceToken &&)=default
void connect(ActivityRegistry &)
the argument&#39;s signals will forward the token&#39;s signals
Definition: ServiceToken.cc:63
std::shared_ptr< edm::serviceregistry::ServicesManager > manager_
Definition: ServiceToken.h:83
HLT enums.