diff --git a/alib2common/src/core/components.hpp b/alib2common/src/core/components.hpp index e2b2956fb6f338f6f4a4ff6bc66ab4cd6f88d5b5..69c846ebae3d5eea6dccb742872e14e6d5922de6 100644 --- a/alib2common/src/core/components.hpp +++ b/alib2common/src/core/components.hpp @@ -10,6 +10,7 @@ #include <typeinfo> #include <exception/CommonException.h> +#include <abstraction/AlgorithmRegistry.hpp> namespace component { @@ -145,6 +146,12 @@ public: return * this; } + static void registerComponent ( ) { + std::array < std::string, 0 > names; + ComponentType & ( Derived::* method ) ( ) = & Component < Derived, ComponentType, component::Value, ComponentName >::get; + abstraction::AlgorithmRegistry::registerMethod < ComponentName > ( method, "get", names ); + } + }; /** @@ -158,6 +165,9 @@ public: */ template < class T, typename std::enable_if < ! std::is_same < T, T >::value >::type * = nullptr > void accessComponent ( ); + + static void registerComponent ( ) { + } }; /** @@ -186,6 +196,11 @@ public: * Make access method from Components base class part of methods set of this Components class */ using Components < Derived, Next ... >::accessComponent; + + static void registerComponent ( ) { + Component < Derived, ComponentType, ComponentCategory, ComponentName >::registerComponent ( ); + Components < Derived, Next ... >::registerComponent ( ); + } }; /** @@ -214,6 +229,11 @@ public: * Make access method from Components base class part of methods set of this Components class */ using Components < Derived, ComponentType, ComponentCategory, std::tuple < ComponentNames ... >, Next ... >::accessComponent; + + static void registerComponent ( ) { + Component < Derived, ComponentType, ComponentCategory, ComponentName >::registerComponent ( ); + Components < Derived, ComponentType, ComponentCategory, std::tuple < ComponentNames ... >, Next ... >::registerComponent ( ); + } }; /** @@ -236,6 +256,10 @@ public: * Make access method from Components base class part of methods set of this Components class */ using Components < Derived, Next ... >::accessComponent; + + static void registerComponent ( ) { + Components < Derived, Next ... >::registerComponent ( ); + } }; } /* namespace alib */ diff --git a/alib2common/src/core/components/setComponents.hpp b/alib2common/src/core/components/setComponents.hpp index 1746248c0c19372141ab0dd61077dc40fcfb737d..f24dd9cb287edf55b45df0935f5dd3af7e0e864e 100644 --- a/alib2common/src/core/components/setComponents.hpp +++ b/alib2common/src/core/components/setComponents.hpp @@ -11,6 +11,7 @@ #include <algorithm> #include <typeinfo> #include <exception/CommonException.h> +#include <abstraction/AlgorithmRegistry.hpp> namespace component { @@ -229,6 +230,12 @@ public: Component ( ) { } + + static void registerComponent ( ) { + std::array < std::string, 0 > names; + ComponentType & ( Derived::* method ) ( ) = & SetComponent < Derived, ComponentType, typename ComponentType::value_type, ComponentName >::get; + abstraction::AlgorithmRegistry::registerMethod < ComponentName > ( method, "get", names ); + } }; } /* namespace alib */ diff --git a/alib2common/src/registration/ComponentRegistration.hpp b/alib2common/src/registration/ComponentRegistration.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0482c7f716488dcca80c91437d0a4b0a7caf8f97 --- /dev/null +++ b/alib2common/src/registration/ComponentRegistration.hpp @@ -0,0 +1,17 @@ +#ifndef _COMPONENT_REGISTRATION_HPP_ +#define _COMPONENT_REGISTRATION_HPP_ + +namespace registration { + +template < class ObjectType > +class ComponentRegister { +public: + ComponentRegister ( ) { + ObjectType::registerComponent ( ); + } + +}; + +} /* namespace registration */ + +#endif /* _COMPONENT_REGISTRATION_HPP_ */ diff --git a/alib2data/src/automaton/FSM/CompactNFA.cpp b/alib2data/src/automaton/FSM/CompactNFA.cpp index 714e6cee9fe16cee4233d4919975c63b36db0fa8..b619700abda2a8d953722ebaf636bba71cd7a36b 100644 --- a/alib2data/src/automaton/FSM/CompactNFA.cpp +++ b/alib2data/src/automaton/FSM/CompactNFA.cpp @@ -12,9 +12,12 @@ #include <registration/ValuePrinterRegistration.hpp> #include <registration/XmlRegistration.hpp> #include <registration/CastRegistration.hpp> +#include <registration/ComponentRegistration.hpp> namespace { +static auto components = registration::ComponentRegister < automaton::CompactNFA < > > ( ); + static auto valuePrinter = registration::ValuePrinterRegister < automaton::CompactNFA < > > ( ); static auto xmlWrite = registration::XmlWriterRegister < automaton::Automaton, automaton::CompactNFA < > > ( );