LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ServiceHelper.h
Go to the documentation of this file.
1 #ifndef art_Framework_Services_Registry_detail_ServiceHelper_h
2 #define art_Framework_Services_Registry_detail_ServiceHelper_h
3 
5 // ServiceHelperBase
6 // ServiceImplHelper
7 // ServiceInterfaceImplHelper
8 // ServiceInterfaceHelper
9 // ServiceLGMHelper
10 // ServicePSMHelper
11 // ServiceLGRHelper
12 // ServicePSRHelper
13 // ServiceHelper
14 //
15 // The ServiceHelper class and associated interface classes to simplify
16 // the service cache in the face of pre-made and per-schedule services,
17 // and services implementing interfaces.
18 //
19 // LG = Legacy/Global M = make R = retrieve
20 // PS = Per-schedule M = make R = retrieve
22 
27 
28 #include <memory>
29 
30 namespace fhicl {
31  class ParameterSet;
32 }
33 
34 namespace art {
35  namespace detail {
36  struct ServiceHelperBase;
37  struct ServiceImplHelper;
38  struct ServiceInterfaceImplHelper;
39  struct ServiceInterfaceHelper;
40  struct ServiceLGMHelper;
41  struct ServicePSMHelper;
42  struct ServiceLGRHelper;
43  struct ServicePSRHelper;
44  template <typename SERVICE>
45  struct ServiceHelper;
46  }
47 
48  class ActivityRegistry;
49 }
50 
51 // Base class. Note virtual inheritance below.
53  virtual ~ServiceHelperBase() noexcept = default;
54  virtual TypeID get_typeid() const = 0;
55  virtual ServiceScope scope() const = 0;
56  virtual bool is_interface() const = 0;
57  virtual bool is_interface_impl() const = 0;
58 };
59 
60 // For a "real" service (not an interface).
62  : public virtual art::detail::ServiceHelperBase {
63  bool
64  is_interface() const override
65  {
66  return false;
67  } // Not necessarily final.
68 };
69 
70 // For a service implementing an interface.
73  bool
74  is_interface_impl() const final override
75  {
76  return true;
77  }
78  virtual TypeID get_interface_typeid() const = 0;
79 
80  virtual std::unique_ptr<ServiceWrapperBase> convert(
81  std::shared_ptr<ServiceWrapperBase> const& swb) const = 0;
82 };
83 
84 // For the service interface itself.
86  : public virtual art::detail::ServiceHelperBase {
87  bool
88  is_interface() const final override
89  {
90  return true;
91  }
92  bool
93  is_interface_impl() const final override
94  {
95  return false;
96  }
97 };
98 
99 // For a per-schedule service.
100 struct art::detail::ServicePSMHelper { // PerScheduleMaker
101  virtual ~ServicePSMHelper() noexcept = default;
102  virtual std::unique_ptr<ServiceWrapperBase> make(
103  fhicl::ParameterSet const& cfg,
104  ActivityRegistry& reg,
105  size_t nSchedules) const = 0;
106 };
107 
108 struct art::detail::ServicePSRHelper { // PerScheduleRetriever
109  virtual ~ServicePSRHelper() noexcept = default;
110  virtual void* retrieve(std::shared_ptr<ServiceWrapperBase>& swb,
111  ScheduleID sID) const = 0;
112 };
113 
114 // For a global or legacy service
115 struct art::detail::ServiceLGMHelper { // LegacyOrGlobalMaker
116  virtual ~ServiceLGMHelper() noexcept = default;
117  virtual std::unique_ptr<ServiceWrapperBase> make(
118  fhicl::ParameterSet const& cfg,
119  ActivityRegistry& reg) const = 0;
120 };
121 
122 struct art::detail::ServiceLGRHelper { // LegacyOrGlobalRetriever
123  virtual ~ServiceLGRHelper() noexcept = default;
124  virtual void* retrieve(std::shared_ptr<ServiceWrapperBase>& swb) const = 0;
125 };
126 
127 #endif /* art_Framework_Services_Registry_detail_ServiceHelper_h */
128 
129 // Local Variables:
130 // mode: c++
131 // End:
ServiceScope
Definition: ServiceScope.h:5
parameter set interface
bool is_interface() const override
Definition: ServiceHelper.h:64
bool is_interface_impl() const final override
Definition: ServiceHelper.h:93
bool is_interface() const final override
Definition: ServiceHelper.h:88
bool is_interface_impl() const final override
Definition: ServiceHelper.h:74
HLT enums.