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

register cast algorithms in abstraction

parent 85bd30cb
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -73,6 +73,20 @@ public: ...@@ -73,6 +73,20 @@ public:
registerCast < TargetType, ParamType > ( target, param, normalize ); registerCast < TargetType, ParamType > ( target, param, normalize );
} }
   
template < class TargetType, class ParamType >
static void registerCastAlgorithm ( std::string target, std::string param, TargetType ( * callback ) ( const ParamType & ), bool normalize ) {
if ( ! getEntries ( ).insert ( std::make_pair ( std::make_pair ( target, param ), std::unique_ptr < Entry > ( new AlgorithmEntryImpl < TargetType, const ParamType & > ( callback, normalize ) ) ) ).second )
throw ::exception::CommonException ( "Entry from " + param + " to " + target + " already registered." );
}
template < class TargetType, class ParamType >
static void registerCastAlgorithm ( TargetType ( * callback ) ( const ParamType & ), bool normalize ) {
std::string target = ext::to_string < TargetType > ( );
std::string param = ext::to_string < ParamType > ( );
registerCastAlgorithm < TargetType, ParamType > ( target, param, callback, normalize );
}
template < class TargetType, class ParamType > template < class TargetType, class ParamType >
static void registerCastAlgorithm ( std::string target, std::string param, TargetType ( * callback ) ( ParamType ), bool normalize ) { static void registerCastAlgorithm ( std::string target, std::string param, TargetType ( * callback ) ( ParamType ), bool normalize ) {
if ( ! getEntries ( ).insert ( std::make_pair ( std::make_pair ( target, param ), std::unique_ptr < Entry > ( new AlgorithmEntryImpl < TargetType, ParamType > ( callback, normalize ) ) ) ).second ) if ( ! getEntries ( ).insert ( std::make_pair ( std::make_pair ( target, param ), std::unique_ptr < Entry > ( new AlgorithmEntryImpl < TargetType, ParamType > ( callback, normalize ) ) ) ).second )
......
...@@ -25,6 +25,9 @@ public: ...@@ -25,6 +25,9 @@ public:
alib::castApi::getCastPool < To > ( ).template add < From > ( castFunction ); alib::castApi::getCastPool < To > ( ).template add < From > ( castFunction );
   
introspection::Casts::registerCast < From, To > ( ); introspection::Casts::registerCast < From, To > ( );
bool normalize = registration::NormalizationRegister < To > ( ).requireNormalization ( );
abstraction::CastRegistry::registerCastAlgorithm < To, From > ( castFunction, normalize );
} }
}; };
   
......
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