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 <memory>
14 
15 namespace art {
16 
17  class ActivityRegistry;
18  class ModuleDescription;
19  class ProducingServiceSignals;
20 
21  namespace detail {
22  class SharedResources;
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  SharedResources& resources,
39  ServiceStack& creationOrder) const;
40 
42  SharedResources& resources) const;
43  fhicl::ParameterSet const& getParameterSet() const;
44 
45  template <typename T>
46  T& get(ActivityRegistry& reg,
47  SharedResources& resources,
48  ServiceStack& creationOrder) const;
49 
50  void registerProducts(ProductDescriptions& productsToProduce,
51  ProducingServiceSignals& signals,
52  ModuleDescription const& md);
53 
54  bool is_impl() const;
55  bool is_interface() const;
56  ServiceScope serviceScope() const;
57 
58  private:
59  std::shared_ptr<ServiceWrapperBase> makeService(
60  ActivityRegistry& reg,
61  SharedResources& resources) const;
62 
64  SharedResources& resources,
65  ServiceStack& creationOrder) const;
66 
67  std::shared_ptr<ServiceWrapperBase> convertService() const;
68 
70  std::unique_ptr<ServiceHelperBase> helper_;
71  mutable std::shared_ptr<ServiceWrapperBase> service_{};
73  };
74 
75  template <typename T>
76  T&
78  SharedResources& resources,
79  ServiceStack& creationOrder) const
80  {
81  auto swb = getService(reg, resources, creationOrder);
82  return *reinterpret_cast<T*>(
83  dynamic_cast<ServiceLGRHelper&>(*helper_).retrieve(swb));
84  }
85 
86  } // namespace detail
87 } // namespace art
88 
89 #endif /* art_Framework_Services_Registry_detail_ServiceCacheEntry_h */
90 
91 // Local Variables:
92 // mode: c++
93 // End:
std::shared_ptr< ServiceWrapperBase > makeService(ActivityRegistry &reg, SharedResources &resources) const
fhicl::ParameterSet const & getParameterSet() 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::shared_ptr< ServiceWrapperBase > getService(ActivityRegistry &reg, SharedResources &resources, ServiceStack &creationOrder) const
std::vector< BranchDescription > ProductDescriptions
std::stack< WrapperBase_ptr > ServiceStack
Definition: ServiceStack.h:12
void forceCreation(ActivityRegistry &reg, SharedResources &resources) const
ServiceCacheEntry(fhicl::ParameterSet const &pset, std::unique_ptr< ServiceHelperBase > &&helper)
std::unique_ptr< ServiceHelperBase > helper_
void createService(ActivityRegistry &reg, SharedResources &resources, ServiceStack &creationOrder) const
T & get(ActivityRegistry &reg, SharedResources &resources, ServiceStack &creationOrder) const
std::shared_ptr< ServiceWrapperBase > convertService() const
cet::registry_via_id< success_t, val > reg
cet::exempt_ptr< ServiceCacheEntry const > const interface_impl_
std::shared_ptr< ServiceWrapperBase > service_