Skip to content
Snippets Groups Projects
Commit 7a96c2dc authored by Jan Trávníček's avatar Jan Trávníček
Browse files

get operation on components as method abstraction

parent 487cc5b3
No related branches found
No related tags found
No related merge requests found
......@@ -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 */
......
......@@ -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 */
......
#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_ */
......@@ -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 < > > ( );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment