From 43086443acb6314087e5b46fa169673bf1fd2351 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Tue, 15 Aug 2017 19:23:29 +0200
Subject: [PATCH] use string param names in abstraction of algos

---
 .../src/ast/statements/SingleStatement.cpp    |  2 +-
 .../src/abstraction/AlgorithmRegistry.hpp     | 20 +++++++++----------
 alib2common/src/abstraction/Registry.cpp      |  4 ++--
 alib2common/src/abstraction/Registry.h        |  4 ++--
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/alib2cli/src/ast/statements/SingleStatement.cpp b/alib2cli/src/ast/statements/SingleStatement.cpp
index d7ce1f3cb0..e54cf10168 100644
--- a/alib2cli/src/ast/statements/SingleStatement.cpp
+++ b/alib2cli/src/ast/statements/SingleStatement.cpp
@@ -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;
diff --git a/alib2common/src/abstraction/AlgorithmRegistry.hpp b/alib2common/src/abstraction/AlgorithmRegistry.hpp
index 9323d7c5c9..a1baf85101 100644
--- a/alib2common/src/abstraction/AlgorithmRegistry.hpp
+++ b/alib2common/src/abstraction/AlgorithmRegistry.hpp
@@ -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;
 		}
 	}
diff --git a/alib2common/src/abstraction/Registry.cpp b/alib2common/src/abstraction/Registry.cpp
index 93fd9259bf..bcd193558d 100644
--- a/alib2common/src/abstraction/Registry.cpp
+++ b/alib2common/src/abstraction/Registry.cpp
@@ -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 );
 }
 
diff --git a/alib2common/src/abstraction/Registry.h b/alib2common/src/abstraction/Registry.h
index 955a42c71e..6e32c1cece 100644
--- a/alib2common/src/abstraction/Registry.h
+++ b/alib2common/src/abstraction/Registry.h
@@ -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 );
-- 
GitLab