ServiceCacheEntry.h
Go to the documentation of this file.
1 #ifndef art_Framework_Services_Registry_detail_ServiceCacheEntry_h
2 #define art_Framework_Services_Registry_detail_ServiceCacheEntry_h
3 // vim: set sw=2 expandtab :
4 
10 #include "cetlib/exempt_ptr.h"
11 #include "fhiclcpp/ParameterSet.h"
12 
13 #include <cassert>
14 #include <memory>
15 
16 namespace art {
17 
18  class ActivityRegistry;
19  class ModuleDescription;
20  class ProducingServiceSignals;
21 
22  namespace detail {
23 
25  public:
27  std::unique_ptr<ServiceHelperBase>&& helper);
28 
30  std::unique_ptr<ServiceHelperBase>&& helper,
31  ServiceCacheEntry const& impl);
32 
33  ServiceCacheEntry(std::shared_ptr<ServiceWrapperBase> premade_service,
34  std::unique_ptr<ServiceHelperBase>&& helper);
35 
36  std::shared_ptr<ServiceWrapperBase> getService(
38  ServiceStack& creationOrder) const;
39 
40  void forceCreation(art::ActivityRegistry& reg) const;
41  fhicl::ParameterSet const& getParameterSet() const;
42 
43  template <typename T>
44  T& get(art::ActivityRegistry& reg, ServiceStack& creationOrder) const;
45 
46  void registerProducts(ProductDescriptions& productsToProduce,
47  ProducingServiceSignals& signals,
48  ModuleDescription const& md);
49 
50  bool is_impl() const;
51  bool is_interface() const;
52  ServiceScope serviceScope() const;
53 
54  private:
55  std::shared_ptr<ServiceWrapperBase> makeService(
56  art::ActivityRegistry& reg) const;
57 
59  ServiceStack& creationOrder) const;
60 
61  std::shared_ptr<ServiceWrapperBase> convertService() const;
62 
64  std::unique_ptr<ServiceHelperBase> helper_;
65  mutable std::shared_ptr<ServiceWrapperBase> service_{};
67  };
68 
69  template <typename T>
70  T&
72  ServiceStack& creationOrder) const
73  {
74  std::shared_ptr<ServiceWrapperBase> swb = getService(reg, creationOrder);
75  return *reinterpret_cast<T*>(
76  dynamic_cast<ServiceLGRHelper&>(*helper_).retrieve(swb));
77  }
78 
79  } // namespace detail
80 } // namespace art
81 
82 #endif /* art_Framework_Services_Registry_detail_ServiceCacheEntry_h */
83 
84 // Local Variables:
85 // mode: c++
86 // End:
std::shared_ptr< ServiceWrapperBase > getService(art::ActivityRegistry &reg, ServiceStack &creationOrder) const
ServiceScope
Definition: ServiceScope.h:7
void registerProducts(ProductDescriptions &productsToProduce, ProducingServiceSignals &signals, ModuleDescription const &md)
virtual void * retrieve(std::shared_ptr< ServiceWrapperBase > &swb) const =0
ServiceScope serviceScope() const
std::vector< BranchDescription > ProductDescriptions
std::stack< WrapperBase_ptr > ServiceStack
Definition: ServiceStack.h:12
std::shared_ptr< ServiceWrapperBase > convertService() const
ServiceCacheEntry(fhicl::ParameterSet const &pset, std::unique_ptr< ServiceHelperBase > &&helper)
void createService(art::ActivityRegistry &reg, ServiceStack &creationOrder) const
std::shared_ptr< ServiceWrapperBase > makeService(art::ActivityRegistry &reg) const
std::unique_ptr< ServiceHelperBase > helper_
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
void forceCreation(art::ActivityRegistry &reg) const
double T
Definition: Xdiff_gwt.C:5
cet::exempt_ptr< ServiceCacheEntry const > const interface_impl_
std::shared_ptr< ServiceWrapperBase > service_
T & get(art::ActivityRegistry &reg, ServiceStack &creationOrder) const
fhicl::ParameterSet const & getParameterSet() const