Service implementation returning a provider. More...
#include <ServiceProviderWrappers.h>
Public Types | |
using | concrete_provider_type = PROVIDER |
type of service provider implementation More... | |
using | service_interface_type = INTERFACE |
art service interface class More... | |
using | provider_type = typename service_interface_type::provider_type |
type of service provider interface More... | |
using | Parameters = art::ServiceTable< typename concrete_provider_type::Config > |
Type of configuration parameter (for art description) More... | |
Public Member Functions | |
ServiceProviderImplementationWrapper (Parameters const &config, art::ActivityRegistry &) | |
Constructor (using a configuration table) More... | |
Private Member Functions | |
virtual provider_type const * | do_provider () const override |
Returns a constant pointer to the service provider. More... | |
Private Attributes | |
std::unique_ptr< concrete_provider_type > | prov |
service provider More... | |
Service implementation returning a provider.
INTERFACE | type of art service being implemented |
PROVIDER | type of service provider to be returned |
This class is suitable for a simple art service implementing an interface. This is the case of a service that can have multiple implementations, for example an experiment-specific access to a database. In this case, the art service is described by an interface, and many services can inherit and implement it.
In the factorisation model recommended in LArSoft, this hierarchy of art service implementations derived by a common interface is mirrored in a matching hierarchy of service provider implementation derived by a common service provider interface. In this model, services are basically trivial classes that return a pointer to the provider through a prescribed interface. The only relevant exception is that services may also register framework callbacks.
Given the nature of the service returning a provider, its structure is repetitive. This class implements most of that repetitive frame. The resulting service is not reacting to any framework events.
The configuration of the service is passed directly to the provider.
Given that we want to have a service that implements the service MyServiceInterface
and returns a provider implementation "A" called MyProviderA
, the simplest way to create it with this template is:
#include "larcore/CoreUtils/ServiceProviderWrappers.h" #include "path/to/MyProviderA.h" #include "path/to/MyServiceInterface.h" namespace myprov { using MyServiceA = lar::ServiceProviderImplementationWrapper <MyProviderA, MyServiceInterface>; } DECLARE_ART_SERVICE_INTERFACE_IMPL (myprov::MyServiceA, myprov::MyService, LEGACY)
The class MyServiceInterface
is expected to have been defined via ServiceProviderInterfaceWrapper
. An implementation file is necessary too, that will look like:
#include "path/to/MyServiceA.h" DEFINE_ART_SERVICE_INTERFACE_IMPL (myprov::MyServiceA, myprov::MyService)
If callback registration is needed, a class can derive from this template and still gain a bit of boilerplate facility. That is:
provider_type
definition (required by lar::providerFrom()
)provider()
method to access the provider (required by lar::providerFrom()
)Parameters
definition (used by art to print accepted configuration)concrete_provider_type
definition (that is PROVIDER)service_interface_type
definition (that is INTERFACE)Requirements on the service provider (PROVIDER):
Config
being the configuration object. This is the object wrapped by fhicl::Table
when performing FHiCL validation.Requirements on the service interface (INTERFACE):
provider_type
representing the abstract interface of the service providerdo_provider()
where the retrieval of the provider is expected to happen; this method is overridden Definition at line 235 of file ServiceProviderWrappers.h.
using lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::concrete_provider_type = PROVIDER |
type of service provider implementation
Definition at line 239 of file ServiceProviderWrappers.h.
using lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::Parameters = art::ServiceTable<typename concrete_provider_type::Config> |
Type of configuration parameter (for art description)
Definition at line 249 of file ServiceProviderWrappers.h.
using lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::provider_type = typename service_interface_type::provider_type |
type of service provider interface
Definition at line 245 of file ServiceProviderWrappers.h.
using lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::service_interface_type = INTERFACE |
art service interface class
Definition at line 242 of file ServiceProviderWrappers.h.
|
inline |
Constructor (using a configuration table)
Definition at line 254 of file ServiceProviderWrappers.h.
|
inlineoverrideprivatevirtual |
Returns a constant pointer to the service provider.
Definition at line 263 of file ServiceProviderWrappers.h.
|
private |
service provider
Definition at line 260 of file ServiceProviderWrappers.h.