diff --git a/alib2common/src/core/components.hpp b/alib2common/src/core/components.hpp index 160c08587b97b77e0f299e3912973dcf48869bc3..395ac54f38f8183bd52181fe54adc3f7edcd5666 100644 --- a/alib2common/src/core/components.hpp +++ b/alib2common/src/core/components.hpp @@ -390,18 +390,19 @@ class Components; /** * Auxiliary class allowing simple access to the alphabets. */ -template < class Derived, class DataType, class SetTypesPack, class ElementTypesPack > -class Components < Derived, DataType, SetTypesPack, ElementTypesPack > : public ComponentAux < Derived, DataType, SetTypesPack >, public ElementAux < Derived, DataType, ElementTypesPack > { +template < class Derived > +class Components < Derived > { public: /** * Construct an alphabet pack from two alphabets. */ - template < class RealSetTypes, class RealElementTypes > - Components ( RealSetTypes params1, RealElementTypes params2 ) : ComponentAux < Derived, DataType, SetTypesPack > ( std::move ( params1 ), std::make_index_sequence < std::tuple_size < SetTypesPack >::value > { } ), ElementAux < Derived, DataType, ElementTypesPack > ( std::move ( params2 ), std::make_index_sequence < std::tuple_size < ElementTypesPack >::value > { } ) { - ComponentAux < Derived, DataType, SetTypesPack >::checkState ( ); - - ElementAux < Derived, DataType, ElementTypesPack >::checkState ( ); + Components ( ) { } + + template < class T, typename std::enable_if < ! std::is_same < T, T >::value >::type * = nullptr > + void accessComponent ( ); + template < class T, typename std::enable_if < ! std::is_same < T, T >::value >::type * = nullptr > + void accessElement ( ); }; /** @@ -427,6 +428,63 @@ public: using Components < Derived, NextGroup ... >::accessElement; }; +/** + * Auxiliary class allowing simple access to the alphabets. + */ +template < class Derived, class DataType, class ElementTypesPack, class ... NextGroup > +class Components < Derived, DataType, std::tuple < >, ElementTypesPack, NextGroup ... > : public ElementAux < Derived, DataType, ElementTypesPack >, public Components < Derived, NextGroup ... > { +public: + /** + * Construct an alphabet pack from two alphabets. + */ + template < class RealElementTypes, class ... NextRealTypes > + Components ( const std::tuple < > & , RealElementTypes params2, NextRealTypes ... nextParams ) : ElementAux < Derived, DataType, ElementTypesPack > ( std::move ( params2 ), std::make_index_sequence < std::tuple_size < ElementTypesPack >::value > { } ), Components < Derived, NextGroup ... > ( std::move ( nextParams ) ... ) { + ElementAux < Derived, DataType, ElementTypesPack >::checkState ( ); + } + + using ElementAux < Derived, DataType, ElementTypesPack >::accessElement; + + using Components < Derived, NextGroup ... >::accessComponent; + using Components < Derived, NextGroup ... >::accessElement; +}; + +/** + * Auxiliary class allowing simple access to the alphabets. + */ +template < class Derived, class DataType, class SetTypesPack, class ... NextGroup > +class Components < Derived, DataType, SetTypesPack, std::tuple < >, NextGroup ... > : public ComponentAux < Derived, DataType, SetTypesPack >, public Components < Derived, NextGroup ... > { +public: + /** + * Construct an alphabet pack from two alphabets. + */ + template < class RealSetTypes, class ... NextRealTypes > + Components ( RealSetTypes params1, const std::tuple < > & , NextRealTypes ... nextParams ) : ComponentAux < Derived, DataType, SetTypesPack > ( std::move ( params1 ), std::make_index_sequence < std::tuple_size < SetTypesPack >::value > { } ), Components < Derived, NextGroup ... > ( std::move ( nextParams ) ... ) { + ComponentAux < Derived, DataType, SetTypesPack >::checkState ( ); + } + + using ComponentAux < Derived, DataType, SetTypesPack >::accessComponent; + + using Components < Derived, NextGroup ... >::accessComponent; + using Components < Derived, NextGroup ... >::accessElement; +}; + +/** + * Auxiliary class allowing simple access to the alphabets. + */ +template < class Derived, class DataType, class ... NextGroup > +class Components < Derived, DataType, std::tuple < >, std::tuple < >, NextGroup ... > : public Components < Derived, NextGroup ... > { +public: + /** + * Construct an alphabet pack from two alphabets. + */ + template < class ... NextRealTypes > + Components ( const std::tuple < > & , const std::tuple < > & , NextRealTypes ... nextParams ) : Components < Derived, NextGroup ... > ( std::move ( nextParams ) ... ) { + } + + using Components < Derived, NextGroup ... >::accessComponent; + using Components < Derived, NextGroup ... >::accessElement; +}; + } /* namespace std */ #endif /* COMPONENTS2_HPP_ */