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

modify registrations

parent 2d5e1c3a
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
#include <introspection/Algorithms.hpp> #include <introspection/Algorithms.hpp>
#include <core/multipleDispatch.hpp> #include <core/multipleDispatch.hpp>
   
#include <abstraction/AlgorithmRegistry.hpp>
#include <abstraction/NormalizeRegistry.hpp>
#include <abstraction/DowncastRegistry.hpp>
namespace registration { namespace registration {
   
template < class Algorithm, class RealReturnType, class ... RealParameterTypeBases > template < class Algorithm, class RealReturnType, class ... RealParameterTypeBases >
...@@ -18,6 +22,45 @@ public: ...@@ -18,6 +22,45 @@ public:
} }
}; };
   
template < class Type, typename enable = void >
struct RequireNormalization : std::false_type {
};
template < class Type >
struct RequireNormalization < Type, typename std::enable_if < std::has_normalize < Type >::value && ! std::is_same < Type, typename Type::normalized_type >::value >::type > : public std::true_type {
};
template < class Type, typename enable = void >
struct RequireDowncast : std::false_type {
};
template < class Type >
struct RequireDowncast < Type *, typename std::enable_if < ! std::is_final < Type >::value >::type > : public std::true_type {
};
template < class Algorithm, class ReturnType, class ... ParameterTypes >
class AbstractRegister {
template < class Type, typename std::enable_if < RequireNormalization < Type >::value >::type * = nullptr >
void registerNormalize ( ) {
abstraction::NormalizeRegistry::registerNormalize < ReturnType > ( );
}
template < class Type, typename std::enable_if < ! RequireNormalization < Type >::value >::type * = nullptr >
void registerNormalize ( ) {
}
public:
AbstractRegister ( ReturnType ( * callback ) ( ParameterTypes ... ) ) {
bool normalize = RequireNormalization < ReturnType >::value;
bool downcast = RequireDowncast < ReturnType >::value;
abstraction::AlgorithmRegistry::registerAlgorithm < Algorithm, ReturnType, ParameterTypes ... > ( callback, downcast, normalize );
registerNormalize < ReturnType > ( );
}
};
} /* namespace registration */ } /* namespace registration */
   
#endif // _ALGO_REGISTRATION_HPP_ #endif // _ALGO_REGISTRATION_HPP_
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
   
#include <core/castApi.hpp> #include <core/castApi.hpp>
#include <introspection/Casts.hpp> #include <introspection/Casts.hpp>
#include <abstraction/CastRegistry.hpp>
   
namespace registration { namespace registration {
   
...@@ -13,6 +14,8 @@ public: ...@@ -13,6 +14,8 @@ public:
alib::castApi::getCastPool < To > ( ).template add < From > ( ); alib::castApi::getCastPool < To > ( ).template add < From > ( );
   
introspection::Casts::registerCast < From, To > ( ); introspection::Casts::registerCast < From, To > ( );
abstraction::CastRegistry::registerCast < To, From > ( );
} }
   
CastRegister ( To ( * castFunction ) ( const From & ) ) { CastRegister ( To ( * castFunction ) ( const From & ) ) {
......
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
#include <core/xmlApi.hpp> #include <core/xmlApi.hpp>
#include <introspection/DataTypes.hpp> #include <introspection/DataTypes.hpp>
   
#include <abstraction/XmlFileWriterRegistry.hpp>
#include <abstraction/XmlParserRegistry.hpp>
#include <abstraction/ValuePrinterRegistry.hpp>
#include <abstraction/DowncastRegistry.hpp>
namespace registration { namespace registration {
   
template < class Group, class Type > template < class Group, class Type >
...@@ -13,6 +18,12 @@ public: ...@@ -13,6 +18,12 @@ public:
alib::xmlApi < Group >::template registerType < Type > ( ); alib::xmlApi < Group >::template registerType < Type > ( );
introspection::DataTypes::registerTypeInGroup < Type, Group > ( ); introspection::DataTypes::registerTypeInGroup < Type, Group > ( );
introspection::DataTypes::registerGroup < Group > ( ); introspection::DataTypes::registerGroup < Group > ( );
abstraction::XmlFileWriterRegistry::registerXmlFileWriter < Type > ( );
abstraction::XmlParserRegistry::registerXmlParser < Type > ( );
abstraction::ValuePrinterRegistry::registerValuePrinter < Type > ( );
abstraction::DowncastRegistry::registerDowncast < Type, typename std::decay < decltype ( std::declval < Group > ( ).getData ( ) ) >::type > ( );
} }
}; };
   
......
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