From 035ac4f164e299e2cd4e25fe6d7061b0a1ad6862 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Tue, 21 Nov 2017 17:04:48 +0100
Subject: [PATCH] add remaining method run helpers

---
 .../abstraction/ValueOperationAbstraction.hpp | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/alib2common/src/abstraction/ValueOperationAbstraction.hpp b/alib2common/src/abstraction/ValueOperationAbstraction.hpp
index 19dde2e605..b25e55e2ca 100644
--- a/alib2common/src/abstraction/ValueOperationAbstraction.hpp
+++ b/alib2common/src/abstraction/ValueOperationAbstraction.hpp
@@ -85,6 +85,16 @@ protected:
 	mutable ext::variant < void, std::reference_wrapper < ReturnType > > m_data;
 
 public:
+	template < typename Callable, typename Object, typename ... Ts, size_t ... Indexes >
+	inline void member_run_helper ( Callable callback, const ext::tuple < Object, Ts ... > & inputs, const std::array < bool, 1 + sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
+		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
+		( void ) inputs;
+		( void ) moves;
+
+		if ( ! isReady ( ) )
+			m_data = std::reference_wrapper < ReturnType > ( callback ( & std::get < 0 > ( inputs )->getValue ( false ), std::get < Indexes + 1 > ( inputs )->getValue ( std::get < Indexes + 1 > ( moves ) ) ... ) );
+	}
+
 	template < typename Callable, typename ... Ts, size_t ... Indexes >
 	inline void run_helper ( Callable callback, const ext::tuple < Ts ... > & inputs, const std::array < bool, sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
 		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
@@ -125,6 +135,16 @@ protected:
 	mutable ext::variant < void, std::reference_wrapper < const ReturnType > > m_data;
 
 public:
+	template < typename Callable, typename Object, typename ... Ts, size_t ... Indexes >
+	inline void member_run_helper ( Callable callback, const ext::tuple < Object, Ts ... > & inputs, const std::array < bool, 1 + sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
+		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
+		( void ) inputs;
+		( void ) moves;
+
+		if ( ! isReady ( ) )
+			m_data = std::reference_wrapper < const ReturnType > ( callback ( & std::get < 0 > ( inputs )->getValue ( false ), std::get < Indexes + 1 > ( inputs )->getValue ( std::get < Indexes + 1 > ( moves ) ) ... ) );
+	}
+
 	template < typename Callable, typename ... Ts, size_t ... Indexes >
 	inline void run_helper ( Callable callback, const ext::tuple < Ts ... > & inputs, const std::array < bool, sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
 		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
@@ -169,6 +189,18 @@ protected:
 	mutable ext::variant < void, std::reference_wrapper < ReturnType > > m_data;
 
 public:
+	template < typename Callable, typename Object, typename ... Ts, size_t ... Indexes >
+	inline void member_run_helper ( Callable callback, const ext::tuple < Object, Ts ... > & inputs, const std::array < bool, 1 + sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
+		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
+		( void ) inputs;
+		( void ) moves;
+
+		if ( ! isReady ( ) ) {
+			ReturnType && res = callback ( & std::get < 0 > ( inputs )->getValue ( false ), std::get < Indexes + 1 > ( inputs )->getValue ( std::get < Indexes + 1 > ( moves ) ) ... );
+			m_data = std::reference_wrapper < ReturnType > ( res );
+		}
+	}
+
 	template < typename Callable, typename ... Ts, size_t ... Indexes >
 	inline void run_helper ( Callable callback, const ext::tuple < Ts ... > & inputs, const std::array < bool, sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
 		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
@@ -211,6 +243,18 @@ protected:
 	mutable ext::variant < void, std::reference_wrapper < const ReturnType > > m_data;
 
 public:
+	template < typename Callable, typename Object, typename ... Ts, size_t ... Indexes >
+	inline void member_run_helper ( Callable callback, const ext::tuple < Object, Ts ... > & inputs, const std::array < bool, 1 + sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
+		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
+		( void ) inputs;
+		( void ) moves;
+
+		if ( ! isReady ( ) ) {
+			const ReturnType && res = callback ( & std::get < 0 > ( inputs )->getValue ( false ), std::get < Indexes + 1 > ( inputs )->getValue ( std::get < Indexes + 1 > ( moves ) ) ... );
+			m_data = std::reference_wrapper < const ReturnType > ( res );
+		}
+	}
+
 	template < typename Callable, typename ... Ts, size_t ... Indexes >
 	inline void run_helper ( Callable callback, const ext::tuple < Ts ... > & inputs, const std::array < bool, sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
 		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
@@ -257,6 +301,16 @@ protected:
 	std::unique_ptr < ReturnType > m_data;
 
 public:
+	template < typename Callable, typename Object, typename ... Ts, size_t ... Indexes >
+	inline void member_run_helper ( Callable callback, const ext::tuple < Object, Ts ... > & inputs, const std::array < bool, 1 + sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
+		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
+		( void ) inputs;
+		( void ) moves;
+
+		if ( ! isReady ( ) )
+			m_data = std::unique_ptr < ReturnType > ( callback ( & std::get < 0 > ( inputs )->getValue ( false ), std::get < Indexes + 1 > ( inputs )->getValue ( std::get < Indexes + 1 > ( moves ) ) ... ) );
+	}
+
 	template < typename Callable, typename ... Ts, size_t ... Indexes >
 	inline void run_helper ( Callable callback, const ext::tuple < Ts ... > & inputs, const std::array < bool, sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
 		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
@@ -290,6 +344,15 @@ public:
 template < >
 class ValueOperationAbstraction < void > : public OperationAbstraction {
 public:
+	template < typename Callable, typename Object, typename ... Ts, size_t ... Indexes >
+	inline void member_run_helper ( Callable callback, const ext::tuple < Object, Ts ... > & inputs, const std::array < bool, 1 + sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) {
+		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
+		( void ) inputs;
+		( void ) moves;
+
+		callback ( & std::get < 0 > ( inputs )->getValue ( false ), std::get < Indexes + 1 > ( inputs )->getValue ( std::get < Indexes + 1 > ( moves ) ) ... );
+	}
+
 	template < typename Callable, typename ... Ts, size_t ... Indexes >
 	inline void run_helper ( Callable callback, const ext::tuple < Ts ... > & inputs, const std::array < bool, sizeof ... ( Indexes ) > moves, std::index_sequence < Indexes ... > ) const {
 		/* make unused parameter warning go away in case of sizeof ... ( Ts ) == 0 */
-- 
GitLab