1 #ifndef GAUDIPLUGINSERVICE_GAUDI_PLUGINSERVICEV2_H
2 #define GAUDIPLUGINSERVICE_GAUDI_PLUGINSERVICEV2_H
21 #include <type_traits>
27 namespace PluginService {
35 template <
typename R,
typename... Args>
36 struct Factory<R( Args... )> {
37 using Traits = Details::Traits<R( Args... )>;
46 return Details::Registry::instance().get<
FactoryType>( Details::stringify_id(
id ) )(
47 std::forward<Args>( args )... );
48 }
catch ( std::bad_any_cast& ) {
84 template <
typename T,
typename F =
typename T::Factory>
89 :
DeclareFactory( Details::demangle<T>(), std::move( f ), std::move( props ) ) {}
92 Details::Registry::Properties props = {} ) {
93 using Details::Registry;
95 if ( props.find(
"ClassName" ) == end( props ) ) props.emplace(
"ClassName", Details::demangle<T>() );
97 Registry::instance().add(
id, {
libraryName(), std::move( f ), std::move( props )} );
111 #define _PS_V2_DECLARE_COMPONENT( type ) \
113 ::Gaudi::PluginService::v2::DeclareFactory<type> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{}; \
116 #define _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id ) \
118 ::Gaudi::PluginService::v2::DeclareFactory<type> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{ \
119 ::Gaudi::PluginService::v2::Details::stringify_id( id )}; \
122 #define _PS_V2_DECLARE_FACTORY( type, factory ) \
124 ::Gaudi::PluginService::v2::DeclareFactory<type, factory> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{}; \
127 #define _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory ) \
129 ::Gaudi::PluginService::v2::DeclareFactory<type, factory> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{ \
130 ::Gaudi::PluginService::v2::Details::stringify_id( id )}; \
133 #if GAUDI_PLUGIN_SERVICE_USE_V2
134 # define DECLARE_COMPONENT( type ) _PS_V2_DECLARE_COMPONENT( type )
135 # define DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id )
136 # define DECLARE_FACTORY( type, factory ) _PS_V2_DECLARE_FACTORY( type, factory )
137 # define DECLARE_FACTORY_WITH_ID( type, id, factory ) _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory )
140 #endif // GAUDIPLUGINSERVICE_GAUDI_PLUGINSERVICEV2_H