| The Gaudi Framework v32r1 (f65d50dc)

Public Types | Public Member Functions | Static Private Member Functions | List of all members
Gaudi::PluginService::v2::DeclareFactory< T, F > Struct Template Reference

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

`#include <Gaudi/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.

88 {}, Details::Registry::Properties props = {} )
89 : DeclareFactory( Details::demangle<T>(), std::move( f ), std::move( props ) ) {}
Gaudi::PluginService::v2::DeclareFactory::DeclareFactory
DeclareFactory(typename F::FactoryType f=DefaultFactory{}, Details::Registry::Properties props={})
Definition: PluginServiceV2.h:88
std::move
T move(T... args)

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

91 {},
92 Details::Registry::Properties props = {} ) {
93 using Details::Registry;
94
95 if ( props.find( "ClassName" ) == end( props ) ) props.emplace( "ClassName", Details::demangle<T>() );
96
97 Registry::instance().add( id, {libraryName(), std::move( f ), std::move( props )} );
98 }
IOTest.end
def end
Definition: IOTest.py:112
std::move
T move(T... args)
Gaudi::PluginService::v2::DeclareFactory::libraryName
static std::string libraryName()
Helper to record the name of the library that declare the factory.
Definition: PluginServiceV2.h:105

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

101 : DeclareFactory( DefaultFactory{}, std::move( props ) ) {}
Gaudi::PluginService::v2::DeclareFactory::DeclareFactory
DeclareFactory(typename F::FactoryType f=DefaultFactory{}, Details::Registry::Properties props={})
Definition: PluginServiceV2.h:88
Gaudi::PluginService::v2::DeclareFactory::DefaultFactory
Details::DefaultFactory< T, F > DefaultFactory
Definition: PluginServiceV2.h:86
std::move
T move(T... args)

## Member Function Documentation

## ◆ libraryName()

template<typename T , typename F = typename T::Factory>

static std::string Gaudi::PluginService::v2::DeclareFactory< T, F >::libraryName | ( |  | ) |
| inline static private

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

Definition at line 105 of file PluginServiceV2.h.

105 { return Details::getDSONameFor( reinterpret_cast<void*>( libraryName ) ); }
Gaudi::PluginService::v2::Details::getDSONameFor
std::string getDSONameFor(void *fptr)
Definition: PluginServiceV2.cpp:306
Gaudi::PluginService::v2::DeclareFactory::libraryName
static std::string libraryName()
Helper to record the name of the library that declare the factory.
Definition: PluginServiceV2.h:105

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

- GaudiPluginService/Gaudi/PluginServiceV2.h