7 #ifndef ASG_TOOLS__ASG_COMPONENT_FACTORIES_H
8 #define ASG_TOOLS__ASG_COMPONENT_FACTORIES_H
27 #ifdef XAOD_STANDALONE
30 StatusCode registerComponentFactory (
const std::string&
type,
const std::function<std::unique_ptr<AsgComponent>(
const std::string&
name)>& factory);
33 const std::function<std::unique_ptr<AsgComponent>(
const std::string&
name)> *getComponentFactory (
const std::string&
type);
41 template<
typename T>
StatusCode registerToolFactory (
const std::string&
type)
43 return registerComponentFactory (
type, [] (
const std::string&
name) -> std::unique_ptr<AsgComponent> {
return std::make_unique<T> (
name); });
45 template<
typename T>
StatusCode registerServiceFactory (
const std::string&
type)
47 return registerComponentFactory (
type, [] (
const std::string&
name) -> std::unique_ptr<AsgComponent> {
return std::make_unique<T> (
name,
nullptr); });
49 template<
typename T>
StatusCode registerAlgorithmFactory (
const std::string&
type)
51 return registerComponentFactory (
type, [] (
const std::string&
name) -> std::unique_ptr<AsgComponent> {
return std::make_unique<T> (
name,
nullptr); });
57 template<
typename T>
requires std::is_base_of_v<AsgTool,T>
58 StatusCode registerGenericComponentFactory (
const std::string&
type)
60 return registerToolFactory<T> (
type);
62 template<
typename T>
requires std::is_base_of_v<EL::AnaAlgorithm,T> || std::is_base_of_v<EL::AnaReentrantAlgorithm,T>
63 StatusCode registerGenericComponentFactory (
const std::string&
type)
65 return registerAlgorithmFactory<T> (
type);
67 template<
typename T>
requires std::is_base_of_v<AsgService,T>
68 StatusCode registerGenericComponentFactory (
const std::string&
type)
70 return registerServiceFactory<T> (
type);
78 template<
typename T>
class AutoRegisterComponentFactory
final
81 AutoRegisterComponentFactory (
const std::string&
name)
83 using namespace asg::msgComponentConfig;
84 if (!asg::registerGenericComponentFactory<T>(
name).isSuccess())
94 #define DECLARE_COMPONENT_JOIN(x,y) DECLARE_COMPONENT_JOIN2(x,y)
95 #define DECLARE_COMPONENT_JOIN2(x,y) x ## y
96 #define DECLARE_COMPONENT(TYPE) \
98 asg::AutoRegisterComponentFactory<TYPE> DECLARE_COMPONENT_JOIN(autoRegisterComponent,__LINE__) (#TYPE); \
102 std::vector<std::string> getLoadedComponentFactoryTypes ();
105 void loadComponentFactoryModule (
const std::string& moduleName,
const std::string& modulePath =
"");
108 void loadComponentFactoryMap (
const std::string&
path);