All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE > Class Template Reference

Service implementation returning a provider. More...

#include <ServiceProviderWrappers.h>

Inheritance diagram for lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >:

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...
 

Detailed Description

template<typename PROVIDER, typename INTERFACE>
class lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >

Service implementation returning a provider.


Template Parameters
INTERFACEtype of art service being implemented
PROVIDERtype of service provider to be returned
See Also
ServiceProviderInterfaceWrapper

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:

Requirements on the service provider (PROVIDER):

Requirements on the service interface (INTERFACE):

Definition at line 235 of file ServiceProviderWrappers.h.

Member Typedef Documentation

template<typename PROVIDER , typename INTERFACE >
using lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::concrete_provider_type = PROVIDER

type of service provider implementation

Definition at line 239 of file ServiceProviderWrappers.h.

template<typename PROVIDER , typename INTERFACE >
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.

template<typename PROVIDER , typename INTERFACE >
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.

template<typename PROVIDER , typename INTERFACE >
using lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::service_interface_type = INTERFACE

art service interface class

Definition at line 242 of file ServiceProviderWrappers.h.

Constructor & Destructor Documentation

template<typename PROVIDER , typename INTERFACE >
lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::ServiceProviderImplementationWrapper ( Parameters const &  config,
art::ActivityRegistry &   
)
inline

Constructor (using a configuration table)

Definition at line 254 of file ServiceProviderWrappers.h.

255  : prov(std::make_unique<concrete_provider_type>(config()))
256  {}
std::unique_ptr< concrete_provider_type > prov
service provider

Member Function Documentation

template<typename PROVIDER , typename INTERFACE >
virtual provider_type const* lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::do_provider ( ) const
inlineoverrideprivatevirtual

Returns a constant pointer to the service provider.

Definition at line 263 of file ServiceProviderWrappers.h.

264  { return prov.get(); }
std::unique_ptr< concrete_provider_type > prov
service provider

Member Data Documentation

template<typename PROVIDER , typename INTERFACE >
std::unique_ptr<concrete_provider_type> lar::ServiceProviderImplementationWrapper< PROVIDER, INTERFACE >::prov
private

service provider

Definition at line 260 of file ServiceProviderWrappers.h.


The documentation for this class was generated from the following file: