DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Public Types | Public Member Functions | Static Private Member Functions | List of all members
Gaudi::PluginService::v2::DeclareFactory< T, F > Struct Template Reference

#include <PluginServiceV2.h>

Public Types

using DefaultFactory = Details::DefaultFactory< T, F >
 

Public Member Functions

 DeclareFactory (typename F::FactoryType f=DefaultFactory{}, Details::Registry::Properties props={})
 
 DeclareFactory (const std::string &id, typename F::FactoryType f=DefaultFactory{}, Details::Registry::Properties props={})
 
 DeclareFactory (Details::Registry::Properties props)
 

Static Private Member Functions

static std::string libraryName ()
 Helper to record the name of the library that declare the factory. More...
 

Detailed Description

template<typename T, typename F = typename T::Factory>
struct Gaudi::PluginService::v2::DeclareFactory< T, F >

Helper to declare the factory implementation for a user defined type T.

The basic use is:

namespace {
Gaudi::PluginService::DeclareFactory<MyComponent> __some_random_name;
}

which is the equivalent of DECLARE_COMPONENT( MyComponent ).

It's possible to specify a custom factory type (instead of the default type alias MyComponent::Factory):

namespace {
using namespace Gaudi::PluginService;
DeclareFactory<MyComponent, Factory<MyBase*( int, int )>> __some_random_name;
}

We can pass arguments to the constructor to use a custom factory function, or a special id, or properties:

namespace {
using namespace Gaudi::PluginService;
DeclareFactory<MyComponent> __some_random_name( "special-id",
[]() -> MyComponent::Factory::ReturnType {
return std::make_unique<MyComponent>( "special-id" );
},
{{"MyProperty", "special"}} );
}

Definition at line 85 of file PluginServiceV2.h.

Member Typedef Documentation

◆ DefaultFactory

template<typename T , typename F = typename T::Factory>
using Gaudi::PluginService::v2::DeclareFactory< T, F >::DefaultFactory = Details::DefaultFactory<T, F>

Definition at line 86 of file PluginServiceV2.h.

Constructor & Destructor Documentation

◆ DeclareFactory() [1/3]

template<typename T , typename F = typename T::Factory>
Gaudi::PluginService::v2::DeclareFactory< T, F >::DeclareFactory ( typename F::FactoryType  f = DefaultFactory{},
Details::Registry::Properties  props = {} 
)
inline

Definition at line 88 of file PluginServiceV2.h.

◆ DeclareFactory() [2/3]

template<typename T , typename F = typename T::Factory>
Gaudi::PluginService::v2::DeclareFactory< T, F >::DeclareFactory ( const std::string &  id,
typename F::FactoryType  f = DefaultFactory{},
Details::Registry::Properties  props = {} 
)
inline

Definition at line 91 of file PluginServiceV2.h.

◆ DeclareFactory() [3/3]

template<typename T , typename F = typename T::Factory>
Gaudi::PluginService::v2::DeclareFactory< T, F >::DeclareFactory ( Details::Registry::Properties  props)
inline

Definition at line 100 of file PluginServiceV2.h.

Member Function Documentation

◆ libraryName()

template<typename T , typename F = typename T::Factory>
static std::string Gaudi::PluginService::v2::DeclareFactory< T, F >::libraryName ( )
inlinestaticprivate

Helper to record the name of the library that declare the factory.

Definition at line 105 of file PluginServiceV2.h.


The documentation for this struct was generated from the following file:
Gaudi::PluginService
See GaudiPluginService-readme.
Definition: PluginServiceDetailsV1.h:28
Gaudi::PluginService::v2::DeclareFactory::DeclareFactory
DeclareFactory(typename F::FactoryType f=DefaultFactory{}, Details::Registry::Properties props={})
Definition: PluginServiceV2.h:88