diff --git a/alib2common/src/abstraction/ValueOperationAbstraction.hpp b/alib2common/src/abstraction/ValueOperationAbstraction.hpp index 19dde2e605373c1ccf295eaa32c6bb08c7deac53..b25e55e2ca4b20c5c7740487fb09de4a6cdf4881 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 */