LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ServiceProviderWrappers.h
Go to the documentation of this file.
1 
20 #ifndef LARCORE_COREUTILS_SERVICEPROVIDERWRAPPERS_H
21 #define LARCORE_COREUTILS_SERVICEPROVIDERWRAPPERS_H 1
22 
23 
24 // LArSoft libraries
25 #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom() (for includers)
26 
27 // framework and support libraries
29 #include "art/Framework/Services/Registry/ServiceMacros.h" // (for includers)
30 
31 // C/C++ standard libraries
32 #include <memory> // std::unique_ptr<>
33 
34 
35 // forward declarations
36 namespace art { class ActivityRegistry; }
37 namespace fhicl { class ParameterSet; }
38 
39 
40 namespace lar {
41 
89  template <class PROVIDER>
91 
92  public:
93  using provider_type = PROVIDER;
94 
97 
98 
102  : prov(std::make_unique<provider_type>(config()))
103  {}
104 
105 
107  provider_type const* provider() const { return prov.get(); }
108 
109 
110  private:
111 
112  std::unique_ptr<provider_type> prov;
113 
114  }; // SimpleServiceProviderWrapper<>
115 
116 
117 
133  template <class PROVIDER>
135 
136  public:
137  using provider_type = PROVIDER;
138 
140  virtual ~ServiceProviderInterfaceWrapper() = default;
141 
142 
144  provider_type const* provider() const { return do_provider(); }
145 
146 
147  protected:
148 
150  virtual provider_type const* do_provider() const = 0;
151 
152  }; // ServiceProviderInterfaceWrapper<>
153 
154 
155 
237  template <typename PROVIDER, typename INTERFACE>
238  class ServiceProviderImplementationWrapper: public INTERFACE {
239 
240  public:
242  using concrete_provider_type = PROVIDER;
243 
245  using service_interface_type = INTERFACE;
246 
248  using provider_type = typename service_interface_type::provider_type;
249 
251  using Parameters
253 
254 
258  : prov(std::make_unique<concrete_provider_type>(config()))
259  {}
260 
261 
262  private:
263  std::unique_ptr<concrete_provider_type> prov;
264 
266  virtual provider_type const* do_provider() const override
267  { return prov.get(); }
268 
269  }; // ServiceProviderImplementationWrapper
270 
271 
272 } // namespace lar
273 
274 
275 #endif // LARCORE_COREUTILS_SERVICEPROVIDERWRAPPERS_H
Utilities related to art service access.
PROVIDER concrete_provider_type
type of service provider implementation
typename service_interface_type::provider_type provider_type
type of service provider interface
INTERFACE service_interface_type
art service interface class
parameter set interface
PROVIDER provider_type
type of the service provider
virtual provider_type const * do_provider() const override
Returns a constant pointer to the service provider.
LArSoft-specific namespace.
provider_type const * provider() const
Returns a constant pointer to the service provider interface.
provider_type const * provider() const
Returns a constant pointer to the service provider.
std::unique_ptr< concrete_provider_type > prov
service provider
HLT enums.
std::unique_ptr< provider_type > prov
service provider
Service implementation returning a provider.
Service returning a provider interface.
Service returning a provider.
PROVIDER provider_type
type of the service provider