LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ServiceToken.h
Go to the documentation of this file.
1 #ifndef art_Framework_Services_Registry_ServiceToken_h
2 #define art_Framework_Services_Registry_ServiceToken_h
3 
4 // ======================================================================
5 //
6 // ServiceToken - Token used to denote a 'service set'
7 //
8 // When you request a new 'service set' to be created from the
9 // ServiceRegistry, the ServiceRegistry will return a ServiceToken. When
10 // you want this 'service set' to be used, create a
11 // ServiceRegistry::Operate by passing the ServiceToken via the constructor.
12 //
13 // ======================================================================
14 
17 
18 #include <memory>
19 
20 namespace art {
21  class ActivityRegistry;
22  struct ProcessConfiguration;
23  class ProducingServiceSignals;
24  class ServiceRegistry;
25 
26  class ServiceToken;
27 }
28 
29 // ----------------------------------------------------------------------
30 
32  friend class ServiceRegistry;
33  friend class ServicesManager;
34 
35 public:
36  static auto
38  {
39  return ServiceToken{nullptr};
40  }
41 
42  template <typename T,
43  typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val !=
45  void
46  add(std::unique_ptr<T>&& serv)
47  {
48  manager_->put(std::move(serv));
49  }
50 
51  template <typename T,
52  typename = std::enable_if_t<detail::ServiceHelper<T>::scope_val ==
54  void
55  add(std::vector<std::unique_ptr<T>>&& services)
56  {
57  manager_->put(std::move(services));
58  }
59 
60  void
62  {
63  manager_->forceCreation();
64  }
65 
66  void
68  ProductDescriptions& productsToProduce,
69  ProducingServiceSignals& signals,
70  ProcessConfiguration const& pc)
71  {
72  manager_->registerProducts(mpr, productsToProduce, signals, pc);
73  }
74 
75  void
77  {
78  manager_->getParameterSets(out);
79  }
80 
81 private:
82  explicit ServiceToken(std::shared_ptr<ServicesManager> iManager)
83  : manager_{iManager}
84  {}
85 
86  std::shared_ptr<ServicesManager> manager_;
87 
88 }; // ServiceToken
89 
90 // ======================================================================
91 
92 #endif /* art_Framework_Services_Registry_ServiceToken_h */
93 
94 // Local Variables:
95 // mode: c++
96 // End:
std::vector< fhicl::ParameterSet > ParameterSets
std::shared_ptr< ServicesManager > manager_
Definition: ServiceToken.h:86
std::vector< BranchDescription > ProductDescriptions
void add(std::vector< std::unique_ptr< T >> &&services)
Definition: ServiceToken.h:55
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
void add(std::unique_ptr< T > &&serv)
Definition: ServiceToken.h:46
void registerProducts(MasterProductRegistry &mpr, ProductDescriptions &productsToProduce, ProducingServiceSignals &signals, ProcessConfiguration const &pc)
Definition: ServiceToken.h:67
ServiceToken(std::shared_ptr< ServicesManager > iManager)
Definition: ServiceToken.h:82
HLT enums.
void getParameterSets(ServicesManager::ParameterSets &out) const
Definition: ServiceToken.h:76
static auto createInvalid()
Definition: ServiceToken.h:37