From f9474fddb6c7b1d7e78466ee05a1e39cca741c89 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Fri, 8 Feb 2019 09:51:42 +0100
Subject: [PATCH] merge runtimeReturnType and ReturnType

---
 .../src/abstraction/OperationAbstraction.hpp  |  5 --
 .../src/abstraction/PackingAbstraction.hpp    |  4 --
 .../abstraction/ValueOperationAbstraction.hpp | 46 -------------------
 .../src/abstraction/WrapperAbstraction.hpp    | 15 +-----
 alib2cli/src/environment/Environment.h        |  4 +-
 5 files changed, 4 insertions(+), 70 deletions(-)

diff --git a/alib2abstraction/src/abstraction/OperationAbstraction.hpp b/alib2abstraction/src/abstraction/OperationAbstraction.hpp
index f5c122d622..491a4ae263 100644
--- a/alib2abstraction/src/abstraction/OperationAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/OperationAbstraction.hpp
@@ -33,7 +33,6 @@ public:
 
 	virtual ext::type_index getParamTypeIndex ( unsigned index ) const = 0;
 	virtual ext::type_index getReturnTypeIndex ( ) const = 0;
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const = 0;
 
 	std::string getParamType ( unsigned index ) const {
 		return ext::to_string ( getParamTypeIndex ( index ) );
@@ -43,10 +42,6 @@ public:
 		return ext::to_string ( getReturnTypeIndex ( ) );
 	}
 
-	std::string getRuntimeReturnType ( ) const {
-		return ext::to_string ( getRuntimeReturnTypeIndex ( ) );
-	}
-
 	virtual std::shared_ptr < abstraction::OperationAbstraction > getProxyAbstraction ( ) {
 		return shared_from_this();
 	}
diff --git a/alib2abstraction/src/abstraction/PackingAbstraction.hpp b/alib2abstraction/src/abstraction/PackingAbstraction.hpp
index d5981c6e4e..37abbd7a2b 100644
--- a/alib2abstraction/src/abstraction/PackingAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/PackingAbstraction.hpp
@@ -109,10 +109,6 @@ public:
 		return m_abstractions [ m_resultId ]->getReturnTypeIndex ( );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		return m_abstractions [ m_resultId ]->getRuntimeReturnTypeIndex ( );
-	}
-
 	virtual std::shared_ptr < abstraction::OperationAbstraction > getProxyAbstraction ( ) override {
 		return m_abstractions [ m_resultId ]->getProxyAbstraction ( );
 	}
diff --git a/alib2abstraction/src/abstraction/ValueOperationAbstraction.hpp b/alib2abstraction/src/abstraction/ValueOperationAbstraction.hpp
index d2787e679c..2eac4cb455 100644
--- a/alib2abstraction/src/abstraction/ValueOperationAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/ValueOperationAbstraction.hpp
@@ -58,13 +58,6 @@ public:
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( cached ( ) )
-			return ext::type_index ( typeid ( getData ( ) ) );
-		else
-			throw std::domain_error ( "Runtime type unknown before evaluation." );
-	}
-
 	virtual bool cached ( ) const override {
 		return ( bool ) m_data;
 	}
@@ -110,13 +103,6 @@ public:
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( cached ( ) )
-			return ext::type_index ( typeid ( getData ( ) ) );
-		else
-			throw std::domain_error ( "Runtime type unknown before evaluation." );
-	}
-
 	virtual bool cached ( ) const override {
 		return ( bool ) m_data;
 	}
@@ -162,13 +148,6 @@ public:
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( cached ( ) )
-			return ext::type_index ( typeid ( getData ( ) ) );
-		else
-			throw std::domain_error ( "Runtime type unknown before evaluation." );
-	}
-
 	virtual bool cached ( ) const override {
 		return ( bool ) m_data;
 	}
@@ -214,13 +193,6 @@ public:
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( cached ( ) )
-			return ext::type_index ( typeid ( getConstData ( ) ) );
-		else
-			throw std::domain_error ( "Runtime type unknown before evaluation." );
-	}
-
 	virtual bool cached ( ) const override {
 		return ( bool ) m_data;
 	}
@@ -268,13 +240,6 @@ public:
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( cached ( ) )
-			return ext::type_index ( typeid ( getData ( ) ) );
-		else
-			throw std::domain_error ( "Runtime type unknown before evaluation." );
-	}
-
 	virtual bool cached ( ) const override {
 		return ( bool ) m_data;
 	}
@@ -322,13 +287,6 @@ public:
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( cached ( ) )
-			return ext::type_index ( typeid ( getConstData ( ) ) );
-		else
-			throw std::domain_error ( "Runtime type unknown before evaluation." );
-	}
-
 	virtual bool cached ( ) const override {
 		return ( bool ) m_data;
 	}
@@ -350,10 +308,6 @@ public:
 		return ext::type_index ( typeid ( void ) );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		return ext::type_index ( typeid ( void ) );
-	}
-
 	virtual bool cached ( ) const override {
 		return false;
 	}
diff --git a/alib2abstraction/src/abstraction/WrapperAbstraction.hpp b/alib2abstraction/src/abstraction/WrapperAbstraction.hpp
index c397b27317..0b2fc58e7c 100644
--- a/alib2abstraction/src/abstraction/WrapperAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/WrapperAbstraction.hpp
@@ -133,13 +133,6 @@ public:
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( this->cached ( ) )
-			return ext::type_index ( typeid ( ReturnType ) );
-		else
-			throw std::domain_error ( "Runtime type unknown before evaluation." );
-	}
-
 };
 
 template < class ... ParamTypes >
@@ -157,14 +150,10 @@ public:
 	}
 
 	virtual ext::type_index getReturnTypeIndex ( ) const override {
-		return getRuntimeReturnTypeIndex ( );
-	}
-
-	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
 		if ( this->cached ( ) )
-			return this->m_abstraction->getProxyAbstraction ( )->getRuntimeReturnTypeIndex ( );
+			return this->m_abstraction->getProxyAbstraction ( )->getReturnTypeIndex ( );
 		else
-			throw std::domain_error ( "Runtime type unknown before evaluation." );
+			throw std::domain_error ( "Return type unknown before evaluation." );
 	}
 
 };
diff --git a/alib2cli/src/environment/Environment.h b/alib2cli/src/environment/Environment.h
index c5a590de23..3bb565188f 100644
--- a/alib2cli/src/environment/Environment.h
+++ b/alib2cli/src/environment/Environment.h
@@ -81,7 +81,7 @@ public:
 	const T & getVariable ( const std::string & name ) const {
 		std::shared_ptr < abstraction::ValueProvider < const T & > > ptr = abstraction::translateParam < const T & > ( getVariableInt ( name ) );
 		if ( ! ptr )
-			throw exception::CommonException ( "Invalid variable type. Requested: " + ext::to_string < T > ( ) + ", actual : " + getVariableInt ( name )->getRuntimeReturnType ( ) );
+			throw exception::CommonException ( "Invalid variable type. Requested: " + ext::to_string < T > ( ) + ", actual : " + getVariableInt ( name )->getReturnType ( ) );
 		return ptr->getConstValueReference ( );
 	}
 
@@ -124,7 +124,7 @@ public:
 			if ( ptr3 )
 				return ! ptr3->getValue ( false );
 
-			throw exception::CommonException ( "Invalid result type. Provided: " + m_result->getRuntimeReturnType ( ) );
+			throw exception::CommonException ( "Invalid result type. Provided: " + m_result->getReturnType ( ) );
 		} else {
 			return 0;
 		}
-- 
GitLab