From 0c73f2da0d2bd006750b743be4d2510667229da1 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <jan.travnicek@.fit.cvut.cz> Date: Fri, 14 Jun 2019 12:47:11 +0200 Subject: [PATCH] reorganize code --- .../AnyaryOperationAbstraction.hpp | 2 +- .../abstraction/NaryOperationAbstraction.hpp | 6 +-- .../src/abstraction/WrapperAbstraction.hpp | 6 +-- .../src/common/AbstractionHelpers.hpp | 53 +++++++++---------- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.hpp b/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.hpp index 641635837b..be14d6b09e 100644 --- a/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.hpp +++ b/alib2abstraction/src/abstraction/AnyaryOperationAbstraction.hpp @@ -31,7 +31,7 @@ private: if ( input == nullptr ) return false; - if ( checkInput && ! abstraction::CheckInput < ValueProvider < ParamType > >::checkInput ( input, 0 /* Note: yes index zero */ ) ) + if ( checkInput && ! abstraction::checkInput < ValueProvider < ParamType > > ( input, 0 /* Note: yes index zero */ ) ) return false; if ( m_params.size ( ) < index + 1 ) diff --git a/alib2abstraction/src/abstraction/NaryOperationAbstraction.hpp b/alib2abstraction/src/abstraction/NaryOperationAbstraction.hpp index 7b3f0a5bd0..0d84d97d37 100644 --- a/alib2abstraction/src/abstraction/NaryOperationAbstraction.hpp +++ b/alib2abstraction/src/abstraction/NaryOperationAbstraction.hpp @@ -35,7 +35,7 @@ private: if ( input == nullptr ) return false; - if ( checkInput && ! abstraction::CheckInput < ValueProvider < ParamTypes > ... >::checkInput ( input, index ) ) + if ( checkInput && ! abstraction::checkInput < ValueProvider < ParamTypes > ... > ( input, index ) ) return false; m_params [ index ].first = input; @@ -89,11 +89,11 @@ public: } ext::type_index getParamTypeIndex ( size_t index ) const override { - return abstraction::ParamType < ParamTypes ... >::paramType ( index ); + return abstraction::paramType < ParamTypes ... > ( index ); } ext::set < abstraction::ParamQualifiers::ParamQualifier > getParamTypeQualifiers ( size_t index ) const override { - return abstraction::ParamType < ParamTypes ... >::paramTypeQualifiers ( index ); + return abstraction::paramTypeQualifiers < ParamTypes ... > ( index ); } }; diff --git a/alib2abstraction/src/abstraction/WrapperAbstraction.hpp b/alib2abstraction/src/abstraction/WrapperAbstraction.hpp index ed30b15a1b..3e6b815d6e 100644 --- a/alib2abstraction/src/abstraction/WrapperAbstraction.hpp +++ b/alib2abstraction/src/abstraction/WrapperAbstraction.hpp @@ -49,7 +49,7 @@ private: if ( input == nullptr ) return false; - if ( checkInput && ! CheckInput < ValueProvider < ParamTypes > ... >::checkInput ( input, index ) ) + if ( checkInput && ! abstraction::checkInput < ValueProvider < ParamTypes > ... > ( input, index ) ) return false; m_params [ index ].first = input; @@ -105,11 +105,11 @@ public: } ext::type_index getParamTypeIndex ( size_t index ) const override { - return ParamType < ParamTypes ... >::paramType ( index ); + return abstraction::paramType < ParamTypes ... > ( index ); } ext::set < abstraction::ParamQualifiers::ParamQualifier > getParamTypeQualifiers ( size_t index ) const override { - return ParamType < ParamTypes ... >::paramTypeQualifiers ( index ); + return abstraction::paramTypeQualifiers < ParamTypes ... > ( index ); } std::shared_ptr < abstraction::OperationAbstraction > getProxyAbstraction ( ) override { diff --git a/alib2abstraction/src/common/AbstractionHelpers.hpp b/alib2abstraction/src/common/AbstractionHelpers.hpp index f4e84c11bb..891cbe8d51 100644 --- a/alib2abstraction/src/common/AbstractionHelpers.hpp +++ b/alib2abstraction/src/common/AbstractionHelpers.hpp @@ -35,46 +35,43 @@ constexpr decltype ( auto ) apply ( F && f, Tuple && t ) { } template < class ... Params > -struct CheckInput { - static bool checkInput ( const std::shared_ptr < OperationAbstraction > & operation, unsigned index ) { - bool res = false; +bool checkInput ( const std::shared_ptr < OperationAbstraction > & operation, unsigned index ) { + bool res = false; - auto lambda = [ & ] ( auto I ) { - res = ( bool ) std::dynamic_pointer_cast < std::decay_t < std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > > > ( operation->getProxyAbstraction ( ) ); - }; + auto lambda = [ & ] ( auto I ) { + res = ( bool ) std::dynamic_pointer_cast < std::decay_t < std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > > > ( operation->getProxyAbstraction ( ) ); + }; - ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda ); + ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda ); - return res; - } -}; + return res; +} template < class ... Params > -struct ParamType { - static ext::type_index paramType ( unsigned index ) { - ext::type_index res ( typeid ( void ) ); +static ext::type_index paramType ( unsigned index ) { + ext::type_index res ( typeid ( void ) ); - auto lambda = [ & ] ( auto I ) { - res = ext::type_index ( typeid ( std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > ) ); - }; + auto lambda = [ & ] ( auto I ) { + res = ext::type_index ( typeid ( std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > ) ); + }; - ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda ); + ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda ); - return res; - } + return res; +} - static ext::set < abstraction::ParamQualifiers::ParamQualifier > paramTypeQualifiers ( unsigned index ) { - ext::set < abstraction::ParamQualifiers::ParamQualifier > res; +template < class ... Params > +ext::set < abstraction::ParamQualifiers::ParamQualifier > paramTypeQualifiers ( unsigned index ) { + ext::set < abstraction::ParamQualifiers::ParamQualifier > res; - auto lambda = [ & ] ( auto I ) { - res = abstraction::ParamQualifiers::paramQualifiers < std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > > ( ); - }; + auto lambda = [ & ] ( auto I ) { + res = abstraction::ParamQualifiers::paramQualifiers < std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > > ( ); + }; - ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda ); + ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda ); - return res; - } -}; + return res; +} } /* namespace abstraction */ -- GitLab