7#ifndef ASG_TOOLS__ASG_COMPONENT_FACTORIES_H
8#define ASG_TOOLS__ASG_COMPONENT_FACTORIES_H
34 StatusCode registerComponentFactory (
const std::string&
type,
const std::function<std::unique_ptr<AsgComponent>(
const std::string& name)>& factory);
37 const std::function<std::unique_ptr<AsgComponent>(
const std::string& name)> *getComponentFactory (
const std::string&
type);
45 template<
typename T> StatusCode registerToolFactory (
const std::string&
type)
47 return registerComponentFactory (
type, [] (
const std::string& name) -> std::unique_ptr<AsgComponent> {
return std::make_unique<T> (name); });
49 template<
typename T>
StatusCode registerServiceFactory (
const std::string& type)
51 return registerComponentFactory (type, [] (
const std::string& name) -> std::unique_ptr<AsgComponent> {
return std::make_unique<T> (name,
nullptr); });
53 template<
typename T>
StatusCode registerAlgorithmFactory (
const std::string& type)
55 return registerComponentFactory (type, [] (
const std::string& name) -> std::unique_ptr<AsgComponent> {
return std::make_unique<T> (name,
nullptr); });
57 template<
typename T>
StatusCode registerELModuleFactory (
const std::string& type)
59 return registerComponentFactory (type, [] (
const std::string& name) -> std::unique_ptr<AsgComponent> {
return std::make_unique<T> (name); });
65 template<
typename T>
requires std::is_base_of_v<AsgTool,T>
66 StatusCode registerGenericComponentFactory (
const std::string& type)
68 return registerToolFactory<T> (type);
70 template<
typename T>
requires std::is_base_of_v<EL::AnaAlgorithm,T> || std::is_base_of_v<EL::AnaReentrantAlgorithm,T>
71 StatusCode registerGenericComponentFactory (
const std::string& type)
73 return registerAlgorithmFactory<T> (type);
75 template<
typename T>
requires std::is_base_of_v<AsgService,T>
76 StatusCode registerGenericComponentFactory (
const std::string& type)
78 return registerServiceFactory<T> (type);
80 template<
typename T>
requires std::is_base_of_v<EL::Detail::Module,T>
81 StatusCode registerGenericComponentFactory (
const std::string& type)
83 return registerELModuleFactory<T> (type);
91 template<
typename T>
class AutoRegisterComponentFactory
final
94 AutoRegisterComponentFactory (
const std::string& name)
96 using namespace asg::msgComponentConfig;
97 if (!asg::registerGenericComponentFactory<T>(name).isSuccess())
99 ANA_MSG_FATAL(
"Failed to register component factory for " << name);
107 #define DECLARE_COMPONENT_JOIN(x,y) DECLARE_COMPONENT_JOIN2(x,y)
108 #define DECLARE_COMPONENT_JOIN2(x,y) x ## y
109 #define DECLARE_COMPONENT(TYPE) \
111 asg::AutoRegisterComponentFactory<TYPE> DECLARE_COMPONENT_JOIN(autoRegisterComponent,__LINE__) (#TYPE); \
115 std::vector<std::string> getLoadedComponentFactoryTypes ();
118 void loadComponentFactoryModule (
const std::string& moduleName,
const std::string& modulePath =
"");
121 void loadComponentFactoryMap (
const std::string& path);
the (new) base class for EventLoop algorithms
the base class for EventLoop reentrant algorithms
the base class for EventLoop instrumentation module
This module defines the arguments passed from the BATCH driver to the BATCH worker.
::StatusCode StatusCode
StatusCode definition for legacy code.