From 185894d12121868d8a4318bafe0fc723e1da1eda Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sat, 15 Dec 2018 14:34:20 +0100
Subject: [PATCH] Abstraction: remove isReady and inputsReady functions

---
 .../AnyaryOperationAbstraction.hpp            |  8 ---
 .../abstraction/NaryOperationAbstraction.hpp  |  8 ---
 .../src/abstraction/OperationAbstraction.hpp  |  2 -
 .../src/abstraction/PackingAbstraction.hpp    | 12 -----
 .../abstraction/ValueOperationAbstraction.hpp | 54 ++++++-------------
 .../src/abstraction/ValueProvider.hpp         | 10 ----
 .../src/abstraction/WrapperAbstraction.hpp    | 20 ++-----
 7 files changed, 19 insertions(+), 95 deletions(-)

diff --git a/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.hpp b/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.hpp
index fd705dc40a..ffec9d0171 100644
--- a/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.hpp
@@ -51,14 +51,6 @@ public:
 	AnyaryOperationAbstraction ( ) {
 	}
 
-	virtual bool inputsReady ( ) const override {
-		for ( const std::pair < std::shared_ptr < OperationAbstraction >, bool > & param : m_params )
-			if ( ! ( bool ) param.first || ! param.first->isReady ( ) )
-				return false;
-
-		return true;
-	}
-
 	virtual bool inputsAttached ( ) const override {
 		for ( const std::pair < std::shared_ptr < OperationAbstraction >, bool > & param : m_params )
 			if ( ! ( bool ) param.first )
diff --git a/alib2abstraction/src/abstraction/NaryOperationAbstraction.hpp b/alib2abstraction/src/abstraction/NaryOperationAbstraction.hpp
index 625962c3f8..6558523359 100644
--- a/alib2abstraction/src/abstraction/NaryOperationAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/NaryOperationAbstraction.hpp
@@ -58,14 +58,6 @@ public:
 		}
 	}
 
-	virtual bool inputsReady ( ) const override {
-		for ( const std::pair < std::shared_ptr < OperationAbstraction >, bool > & param : m_params )
-			if ( ! param.first || ! param.first->isReady ( ) )
-				return false;
-
-		return true;
-	}
-
 	virtual bool inputsAttached ( ) const override {
 		for ( const std::pair < std::shared_ptr < OperationAbstraction >, bool > & param : m_params )
 			if ( ! param.first )
diff --git a/alib2abstraction/src/abstraction/OperationAbstraction.hpp b/alib2abstraction/src/abstraction/OperationAbstraction.hpp
index 64b73fa944..6334afdfae 100644
--- a/alib2abstraction/src/abstraction/OperationAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/OperationAbstraction.hpp
@@ -25,12 +25,10 @@ public:
 	virtual ~OperationAbstraction ( ) noexcept {
 	}
 
-	virtual bool inputsReady ( ) const = 0;
 	virtual bool inputsAttached ( ) const = 0;
 	virtual bool eval ( ) = 0;
 	virtual unsigned numberOfParams ( ) const = 0;
 	virtual bool cached ( ) const = 0;
-	virtual bool isReady ( ) const = 0;
 
 	virtual ext::type_index getParamTypeIndex ( unsigned index ) const = 0;
 	virtual ext::type_index getReturnTypeIndex ( ) const = 0;
diff --git a/alib2abstraction/src/abstraction/PackingAbstraction.hpp b/alib2abstraction/src/abstraction/PackingAbstraction.hpp
index 9f9ab75764..30a416db5b 100644
--- a/alib2abstraction/src/abstraction/PackingAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/PackingAbstraction.hpp
@@ -66,14 +66,6 @@ private:
 		return res;
 	}
 public:
-	virtual bool inputsReady ( ) const override {
-		for ( const std::shared_ptr < abstraction::OperationAbstraction > & operation : m_abstractions )
-			if ( operation->inputsReady ( ) == false )
-				return false;
-
-		return true;
-	}
-
 	virtual bool inputsAttached ( ) const override {
 		for ( const std::shared_ptr < abstraction::OperationAbstraction > & operation : m_abstractions )
 			if ( operation->inputsAttached ( ) == false )
@@ -100,10 +92,6 @@ public:
 		return NumberOfParams;
 	}
 
-	virtual bool isReady ( ) const override {
-		return m_abstractions [ m_resultId ]->isReady ( );
-	}
-
 	virtual bool cached ( ) const override {
 		return m_abstractions [ m_resultId ]->cached ( );
 	}
diff --git a/alib2abstraction/src/abstraction/ValueOperationAbstraction.hpp b/alib2abstraction/src/abstraction/ValueOperationAbstraction.hpp
index e2d8cdbe14..642da81011 100644
--- a/alib2abstraction/src/abstraction/ValueOperationAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/ValueOperationAbstraction.hpp
@@ -38,27 +38,23 @@ protected:
 public:
 	template < typename ... ParamTypes, typename Callable >
 	inline void run_helper ( Callable callback, const ext::array < std::pair < std::shared_ptr < OperationAbstraction >, bool >, sizeof ... ( ParamTypes ) > & inputs ) {
-		if ( ! isReady ( ) )
+		if ( ! cached ( ) )
 			m_data = abstraction::apply < ParamTypes ... > ( callback, inputs );
 	}
 
-	virtual bool isReady ( ) const override {
-		return ( bool ) m_data;
-	}
-
 	virtual ext::type_index getReturnTypeIndex ( ) const override {
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
 	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( isReady ( ) )
+		if ( cached ( ) )
 			return ext::type_index ( typeid ( getData ( ) ) );
 		else
 			throw std::domain_error ( "Runtime type unknown before evaluation." );
 	}
 
 	virtual bool cached ( ) const override {
-		return isReady ( );
+		return ( bool ) m_data;
 	}
 };
 
@@ -78,27 +74,23 @@ protected:
 public:
 	template < typename ... ParamTypes, typename Callable >
 	inline void run_helper ( Callable callback, const ext::array < std::pair < std::shared_ptr < OperationAbstraction >, bool >, sizeof ... ( ParamTypes ) > & inputs ) {
-		if ( ! isReady ( ) )
+		if ( ! cached ( ) )
 			m_data = std::reference_wrapper < ReturnType > ( abstraction::apply < ParamTypes ... > ( callback, inputs ) );
 	}
 
-	virtual bool isReady ( ) const override {
-		return ( bool ) m_data;
-	}
-
 	virtual ext::type_index getReturnTypeIndex ( ) const override {
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
 	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( isReady ( ) )
+		if ( cached ( ) )
 			return ext::type_index ( typeid ( getData ( ) ) );
 		else
 			throw std::domain_error ( "Runtime type unknown before evaluation." );
 	}
 
 	virtual bool cached ( ) const override {
-		return isReady ( );
+		return ( bool ) m_data;
 	}
 };
 
@@ -114,27 +106,23 @@ protected:
 public:
 	template < typename ... ParamTypes, typename Callable >
 	inline void run_helper ( Callable callback, const ext::array < std::pair < std::shared_ptr < OperationAbstraction >, bool >, sizeof ... ( ParamTypes ) > & inputs ) {
-		if ( ! isReady ( ) )
+		if ( ! cached ( ) )
 			m_data = std::reference_wrapper < const ReturnType > ( abstraction::apply < ParamTypes ... > ( callback, inputs ) );
 	}
 
-	virtual bool isReady ( ) const override {
-		return ( bool ) m_data;
-	}
-
 	virtual ext::type_index getReturnTypeIndex ( ) const override {
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
 	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( isReady ( ) )
+		if ( cached ( ) )
 			return ext::type_index ( typeid ( getConstData ( ) ) );
 		else
 			throw std::domain_error ( "Runtime type unknown before evaluation." );
 	}
 
 	virtual bool cached ( ) const override {
-		return isReady ( );
+		return ( bool ) m_data;
 	}
 };
 
@@ -154,29 +142,25 @@ protected:
 public:
 	template < typename ... ParamTypes, typename Callable >
 	inline void run_helper ( Callable callback, const ext::array < std::pair < std::shared_ptr < OperationAbstraction >, bool >, sizeof ... ( ParamTypes ) > & inputs ) {
-		if ( ! isReady ( ) ) {
+		if ( ! cached ( ) ) {
 			ReturnType && res = abstraction::apply < ParamTypes ... > ( callback, inputs );
 			m_data = std::reference_wrapper < ReturnType > ( res );
 		}
 	}
 
-	virtual bool isReady ( ) const override {
-		return ( bool ) m_data;
-	}
-
 	virtual ext::type_index getReturnTypeIndex ( ) const override {
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
 	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( isReady ( ) )
+		if ( cached ( ) )
 			return ext::type_index ( typeid ( getData ( ) ) );
 		else
 			throw std::domain_error ( "Runtime type unknown before evaluation." );
 	}
 
 	virtual bool cached ( ) const override {
-		return isReady ( );
+		return ( bool ) m_data;
 	}
 };
 
@@ -192,29 +176,25 @@ protected:
 public:
 	template < typename ... ParamTypes, typename Callable >
 	inline void run_helper ( Callable callback, const ext::array < std::pair < std::shared_ptr < OperationAbstraction >, bool >, sizeof ... ( ParamTypes ) > & inputs ) {
-		if ( ! isReady ( ) ) {
+		if ( ! cached ( ) ) {
 			const ReturnType && res = abstraction::apply < ParamTypes ... > ( callback, inputs );
 			m_data = std::reference_wrapper < const ReturnType > ( res );
 		}
 	}
 
-	virtual bool isReady ( ) const override {
-		return ( bool ) m_data;
-	}
-
 	virtual ext::type_index getReturnTypeIndex ( ) const override {
 		return ext::type_index ( typeid ( ReturnType ) );
 	}
 
 	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( isReady ( ) )
+		if ( cached ( ) )
 			return ext::type_index ( typeid ( getConstData ( ) ) );
 		else
 			throw std::domain_error ( "Runtime type unknown before evaluation." );
 	}
 
 	virtual bool cached ( ) const override {
-		return isReady ( );
+		return ( bool ) m_data;
 	}
 };
 
@@ -226,10 +206,6 @@ public:
 		abstraction::apply < ParamTypes ... > ( callback, inputs );
 	}
 
-	virtual bool isReady ( ) const override {
-		return true;
-	}
-
 	virtual ext::type_index getReturnTypeIndex ( ) const override {
 		return ext::type_index ( typeid ( void ) );
 	}
diff --git a/alib2abstraction/src/abstraction/ValueProvider.hpp b/alib2abstraction/src/abstraction/ValueProvider.hpp
index 6bc7a301d5..5966731609 100644
--- a/alib2abstraction/src/abstraction/ValueProvider.hpp
+++ b/alib2abstraction/src/abstraction/ValueProvider.hpp
@@ -53,8 +53,6 @@ public:
 	}
 
 	virtual bool eval ( ) = 0;
-
-	virtual bool isReady ( ) const = 0;
 };
 
 template < class Type >
@@ -72,8 +70,6 @@ public:
 	}
 
 	virtual bool eval ( ) = 0;
-
-	virtual bool isReady ( ) const = 0;
 };
 
 template < class Type >
@@ -91,8 +87,6 @@ public:
 	}
 
 	virtual bool eval ( ) = 0;
-
-	virtual bool isReady ( ) const = 0;
 };
 
 template < class Type >
@@ -113,8 +107,6 @@ public:
 	}
 
 	virtual bool eval ( ) = 0;
-
-	virtual bool isReady ( ) const = 0;
 };
 
 template < class Type >
@@ -135,8 +127,6 @@ public:
 	}
 
 	virtual bool eval ( ) = 0;
-
-	virtual bool isReady ( ) const = 0;
 };
 
 } /* namespace abstraction */
diff --git a/alib2abstraction/src/abstraction/WrapperAbstraction.hpp b/alib2abstraction/src/abstraction/WrapperAbstraction.hpp
index b32bfb3ad7..47f050ffe7 100644
--- a/alib2abstraction/src/abstraction/WrapperAbstraction.hpp
+++ b/alib2abstraction/src/abstraction/WrapperAbstraction.hpp
@@ -57,14 +57,6 @@ private:
 	}
 
 public:
-	virtual bool inputsReady ( ) const override {
-		for ( const std::pair < std::shared_ptr < OperationAbstraction >, bool > & param : m_params )
-			if ( ! param.first || ! param.first->isReady ( ) )
-				return false;
-
-		return true;
-	}
-
 	virtual bool inputsAttached ( ) const override {
 		for ( const std::pair < std::shared_ptr < OperationAbstraction >, bool > & param : m_params )
 			if ( ! param.first )
@@ -92,12 +84,8 @@ public:
 		return sizeof ... ( ParamTypes );
 	}
 
-	virtual bool isReady ( ) const override {
-		return ( bool ) m_abstraction && m_abstraction->isReady ( );
-	}
-
 	virtual bool cached ( ) const override {
-		return isReady ( );
+		return ( bool ) m_abstraction && m_abstraction->cached ( );
 	}
 
 	virtual ext::type_index getParamTypeIndex ( unsigned index ) const override {
@@ -105,7 +93,7 @@ public:
 	}
 
 	virtual std::shared_ptr < abstraction::OperationAbstraction > getProxyAbstraction ( ) override {
-		if ( this->isReady ( ) )
+		if ( this->cached ( ) )
 			return this->m_abstraction->getProxyAbstraction ( );
 		else
 			throw std::domain_error ( "Proxy abstraction not avaiable before evaluation." );
@@ -142,7 +130,7 @@ public:
 	}
 
 	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( this->isReady ( ) )
+		if ( this->cached ( ) )
 			return ext::type_index ( typeid ( ReturnType ) );
 		else
 			throw std::domain_error ( "Runtime type unknown before evaluation." );
@@ -169,7 +157,7 @@ public:
 	}
 
 	virtual ext::type_index getRuntimeReturnTypeIndex ( ) const override {
-		if ( this->isReady ( ) )
+		if ( this->cached ( ) )
 			return this->m_abstraction->getProxyAbstraction ( )->getRuntimeReturnTypeIndex ( );
 		else
 			throw std::domain_error ( "Runtime type unknown before evaluation." );
-- 
GitLab