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

use string param names in abstraction of algos

parent 12264829
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ std::shared_ptr < abstraction::OperationAbstraction > SingleStatement::translate
 
ext::vector < ext::type_index > paramTypes;
for ( const std::shared_ptr < abstraction::OperationAbstraction > & param : params ) {
paramTypes.push_back ( param->getReturnTypeIndex ( ) );
paramTypes.push_back ( param->getReturnType ( ) );
}
 
bool downcast = false;
......
......@@ -60,8 +60,8 @@ class AlgorithmRegistry {
virtual std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( ) const override;
};
 
static ext::map < std::string, ext::map < ext::vector < ext::type_index >, std::unique_ptr < Entry > > > & getEntries ( ) {
static ext::map < std::string, ext::map < ext::vector < ext::type_index >, std::unique_ptr < Entry > > > algorithmGroups;
static ext::map < std::string, ext::map < ext::vector < std::string >, std::unique_ptr < Entry > > > & getEntries ( ) {
static ext::map < std::string, ext::map < ext::vector < std::string >, std::unique_ptr < Entry > > > algorithmGroups;
return algorithmGroups;
};
 
......@@ -70,14 +70,14 @@ public:
static void registerAlgorithm ( ReturnType ( * callback ) ( ParamTypes ... ), bool downcast, bool normalize ) {
std::string algorithm = ext::to_string < Algo > ( );
 
ext::vector < ext::type_index > params;
( void ) std::initializer_list < int > { ( params.push_back ( ext::type_index ( typeid ( typename std::decay < ParamTypes >::type ) ) ), 0 ) ... };
ext::vector < std::string > params;
( void ) std::initializer_list < int > { ( params.push_back ( ext::to_string < typename std::decay < ParamTypes >::type > ( ) ), 0 ) ... };
 
if ( ! getEntries ( ) [ algorithm ].insert ( std::make_pair ( params, std::unique_ptr < Entry > ( new EntryImpl < ReturnType, ParamTypes ... > ( callback, downcast, normalize ) ) ) ).second )
throw ::exception::CommonException ( "Callback for " + algorithm + " already registered." );
}
 
static std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( const std::string & name, const ext::vector < ext::type_index > & paramTypes, bool & downcast, bool & normalize ) {
static std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( const std::string & name, const ext::vector < std::string > & paramTypes, bool & downcast, bool & normalize ) {
auto group = getEntries ( ).find ( name );
if ( group == getEntries ( ).end ( ) )
throw exception::CommonException ( "Entry " + name + " not available" );
......@@ -96,14 +96,14 @@ public:
return overload->second->getAbstraction ( );
}
 
static std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( const std::string & name, const ext::vector < ext::type_index > & paramTypes ) {
static std::shared_ptr < abstraction::OperationAbstraction > getAbstraction ( const std::string & name, const ext::vector < std::string > & paramTypes ) {
bool downcast;
bool normalize;
return getAbstraction ( name, paramTypes, downcast, normalize );
}
 
static void listGroup ( const std::string & group ) {
for ( const std::pair < const std::string, ext::map < ext::vector < ext::type_index >, std::unique_ptr < Entry > > > & entry : getEntries ( ) ) {
for ( const std::pair < const std::string, ext::map < ext::vector < std::string >, std::unique_ptr < Entry > > > & entry : getEntries ( ) ) {
if ( entry.first.find ( group ) == 0 ) //found at the begining
std::cout << entry.first << std::endl;
}
......@@ -114,15 +114,15 @@ public:
if ( group == getEntries ( ).end ( ) )
throw exception::CommonException ( "Entry " + algorithm + " not available" );
 
for ( const std::pair < const ext::vector < ext::type_index >, std::unique_ptr < Entry > > & overloads : group->second ) {
for ( const ext::type_index & param : overloads.first ) {
for ( const std::pair < const ext::vector < std::string >, std::unique_ptr < Entry > > & overloads : group->second ) {
for ( const std::string & param : overloads.first ) {
std::cout << param << " " << std::endl;
}
}
}
 
static void list ( ) {
for ( const std::pair < const std::string, ext::map < ext::vector < ext::type_index >, std::unique_ptr < Entry > > > & entry : getEntries ( ) ) {
for ( const std::pair < const std::string, ext::map < ext::vector < std::string >, std::unique_ptr < Entry > > > & entry : getEntries ( ) ) {
std::cout << entry.first << std::endl;
}
}
......
......@@ -30,11 +30,11 @@ void Registry::listAlgorithms ( ) {
AlgorithmRegistry::list ( );
}
 
std::shared_ptr < abstraction::OperationAbstraction > Registry::getAlgorithmAbstraction ( const std::string & name, const ext::vector < ext::type_index > & paramTypes ) {
std::shared_ptr < abstraction::OperationAbstraction > Registry::getAlgorithmAbstraction ( const std::string & name, const ext::vector < std::string > & paramTypes ) {
return AlgorithmRegistry::getAbstraction ( name, paramTypes );
}
 
std::shared_ptr < abstraction::OperationAbstraction > Registry::getAlgorithmAbstraction ( const std::string & name, const ext::vector < ext::type_index > & paramTypes, bool & unwrap, bool & normalize ) {
std::shared_ptr < abstraction::OperationAbstraction > Registry::getAlgorithmAbstraction ( const std::string & name, const ext::vector < std::string > & paramTypes, bool & unwrap, bool & normalize ) {
return AlgorithmRegistry::getAbstraction ( name, paramTypes, unwrap, normalize );
}
 
......
......@@ -18,8 +18,8 @@ public:
static void listAlgorithmOverloads ( const std::string & algorithm );
static void listAlgorithms ( );
 
static std::shared_ptr < abstraction::OperationAbstraction > getAlgorithmAbstraction ( const std::string & name, const ext::vector < ext::type_index > & paramTypes );
static std::shared_ptr < abstraction::OperationAbstraction > getAlgorithmAbstraction ( const std::string & name, const ext::vector < ext::type_index > & paramTypes, bool & unwrap, bool & normalize );
static std::shared_ptr < abstraction::OperationAbstraction > getAlgorithmAbstraction ( const std::string & name, const ext::vector < std::string > & paramTypes );
static std::shared_ptr < abstraction::OperationAbstraction > getAlgorithmAbstraction ( const std::string & name, const ext::vector < std::string > & paramTypes, bool & unwrap, bool & normalize );
static std::shared_ptr < abstraction::OperationAbstraction > getCastAbstraction ( const std::string & target, const std::string & param, bool & normalize );
static std::shared_ptr < abstraction::OperationAbstraction > getImmediateAbstraction ( const std::string & result, std::string value );
static std::shared_ptr < abstraction::OperationAbstraction > getNormalizeAbstraction ( const std::string & param );
......
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