From: g0dil Date: Tue, 1 Sep 2009 07:10:26 +0000 (+0000) Subject: PPI: double MultiConnectorMixin connect comments and cleanup X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=089c4afe6d7ccd9c586557a2d574cc6a20db4aab;p=senf.git PPI: double MultiConnectorMixin connect comments and cleanup git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1361 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/MultiConnectorMixin.cti b/senf/PPI/MultiConnectorMixin.cti index eabe309..1a79cf7 100644 --- a/senf/PPI/MultiConnectorMixin.cti +++ b/senf/PPI/MultiConnectorMixin.cti @@ -113,7 +113,7 @@ senf::ppi::connect(Source & source, Target & target , A1 const & a1) // Include 'senf::ppi::detail implementation' from MultiConnectorMixin.mpp #define BOOST_PP_ITERATION_PARAMS_1 (4, ( \ 0, \ - SENF_MULTI_CONNECTOR_MAX_ARGS2, \ + 2*SENF_MULTI_CONNECTOR_MAX_ARGS, \ SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \ 7 )) #include BOOST_PP_ITERATE() diff --git a/senf/PPI/MultiConnectorMixin.hh b/senf/PPI/MultiConnectorMixin.hh index 4e248ee..996722c 100644 --- a/senf/PPI/MultiConnectorMixin.hh +++ b/senf/PPI/MultiConnectorMixin.hh @@ -36,7 +36,6 @@ #ifndef SENF_MULTI_CONNECTOR_MAX_ARGS #define SENF_MULTI_CONNECTOR_MAX_ARGS 3 -#define SENF_MULTI_CONNECTOR_MAX_ARGS2 6 #endif #include "MultiConnectorMixin.mpp" @@ -91,7 +90,7 @@ namespace ppi { # define BOOST_PP_ITERATION_PARAMS_1 (4, ( \ 0, \ - SENF_MULTI_CONNECTOR_MAX_ARGS2, \ + 2*SENF_MULTI_CONNECTOR_MAX_ARGS, \ SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \ 6 )) # include BOOST_PP_ITERATE() @@ -277,7 +276,7 @@ namespace module { # define BOOST_PP_ITERATION_PARAMS_1 (4, ( \ 0, \ - SENF_MULTI_CONNECTOR_MAX_ARGS2, \ + 2*SENF_MULTI_CONNECTOR_MAX_ARGS, \ SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \ 9 )) # include BOOST_PP_ITERATE() @@ -337,7 +336,7 @@ namespace module { # define BOOST_PP_ITERATION_PARAMS_1 (4, ( \ 0, \ - SENF_MULTI_CONNECTOR_MAX_ARGS2, \ + 2*SENF_MULTI_CONNECTOR_MAX_ARGS, \ SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \ 9 )) # include BOOST_PP_ITERATE() @@ -388,7 +387,7 @@ namespace module { # define BOOST_PP_ITERATION_PARAMS_1 (4, ( \ 0, \ - SENF_MULTI_CONNECTOR_MAX_ARGS2, \ + 2*SENF_MULTI_CONNECTOR_MAX_ARGS, \ SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \ 9 )) # include BOOST_PP_ITERATE() diff --git a/senf/PPI/MultiConnectorMixin.ih b/senf/PPI/MultiConnectorMixin.ih index eff8769..72121b2 100644 --- a/senf/PPI/MultiConnectorMixin.ih +++ b/senf/PPI/MultiConnectorMixin.ih @@ -43,6 +43,13 @@ namespace detail { SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \ 8 )) # include BOOST_PP_ITERATE() + +# define BOOST_PP_ITERATION_PARAMS_1 (4, ( \ + 0, \ + 2*SENF_MULTI_CONNECTOR_MAX_ARGS, \ + SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \ + 10 )) +# include BOOST_PP_ITERATE() }; template @@ -68,48 +75,44 @@ namespace detail { ppi::detail::DisableStandardInput, ppi::detail::DisableStandardOutput > {}; - template senf::mpl::rv<0> is_multiconnector_(T *, ...); - template senf::mpl::rv<1> is_multiconnector_( - T *, + template senf::mpl::rv<0> isMulticonnector(...); + template senf::mpl::rv<1> isMulticonnector( typename boost::enable_if, - int>::type); - template senf::mpl::rv<2> is_multiconnector_( - T *, + int>::type); + template senf::mpl::rv<2> isMulticonnector( typename boost::enable_if, - int>::type); + int>::type); template - struct is_multiconnector_source_ + struct IsMulticonnectorSource_ : public boost::false_type {}; template - struct is_multiconnector_source_ + struct IsMulticonnectorSource_ : public boost::true_type {}; template - struct is_multiconnector_source - : public is_multiconnector_source_< - T, SENF_MPL_RV(is_multiconnector_(static_cast(0),0))> + struct IsMulticonnectorSource + : public IsMulticonnectorSource_(0))> {}; template - struct is_multiconnector_target_ + struct IsMulticonnectorTarget_ : public boost::false_type {}; template - struct is_multiconnector_target_ + struct IsMulticonnectorTarget_ : public boost::true_type {}; template - struct is_multiconnector_target - : public is_multiconnector_target_< - T, SENF_MPL_RV(is_multiconnector_(static_cast(0),0))> + struct IsMulticonnectorTarget + : public IsMulticonnectorTarget_(0))> {}; diff --git a/senf/PPI/MultiConnectorMixin.mpp b/senf/PPI/MultiConnectorMixin.mpp index ac56abe..0a85d3f 100644 --- a/senf/PPI/MultiConnectorMixin.mpp +++ b/senf/PPI/MultiConnectorMixin.mpp @@ -44,30 +44,37 @@ // //////////////////////////////////////////////////////////////////////// // Local Macros +// => template #define mpp_TplParams() \ - BOOST_PP_IF( \ - BOOST_PP_ITERATION(), \ - mpp_TplParams_, \ - BOOST_PP_EMPTY)() + BOOST_PP_IF(BOOST_PP_ITERATION(), mpp_TplParams_, BOOST_PP_EMPTY)() #define mpp_TplParams_() \ template - + +// => , class A0, class A1, ... #define mpp_TplParamsKomma() \ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), class A) + +// => A0 const & a0, A1 const & a1, ... #define mpp_FnParams() \ BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), A, const & a) + +// => , A0 const & a0, A1 const & a1, ... #define mpp_FnParamsKomma() \ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_ITERATION(), A, const & a) + +// => a0, a1, ... #define mpp_CallParams() \ BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), a) + +// => , a0, a1, ... #define mpp_CallParamsKomma() \ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), a) -// Same as above but for outer loop in nested loops +// Same as above but for outer iteration (in nested file iteration) #define mpp_TplParamsKomma2() \ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_FRAME_ITERATION(1), class B) #define mpp_FnParams2() \ - BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_FRAME_ITERATION(1), B, const & a) + BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_FRAME_ITERATION(1), B, cont & b) #define mpp_FnParamsKomma2() \ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_FRAME_ITERATION(1), B, const & b) #define mpp_CallParams2() \ @@ -78,15 +85,15 @@ // //////////////////////////////////////////////////////////////////////// #if BOOST_PP_ITERATION_FLAGS()==1 // ////////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -// MultiConnectorMixin member declaration +// senf::ppi::module::MultiConnectorMixin member declaration 1..MAX_ARGS mpp_TplParams() ConnectorType_ & newConnector( mpp_FnParams() ); // //////////////////////////////////////////////////////////////////////// -#elif BOOST_PP_ITERATION_FLAGS()==9 // ////////////////////////////////////// +#elif BOOST_PP_ITERATION_FLAGS()==9 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -// MultiConnectorMixin member declaration +// senf::ppi::module::MultiConnectorMixin member declaration 1..2*MAX_ARGS template static std::pair @@ -95,7 +102,7 @@ connect_(Source & source, Target & target mpp_FnParamsKomma()); // //////////////////////////////////////////////////////////////////////// #elif BOOST_PP_ITERATION_FLAGS()==2 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -// senf::ppi namespace member declaration +// senf::ppi namespace member declaration 1..MAX_ARGS // Here the reference to Source::ConnectorType / Target::ConnectorType // works like enable_if, since only MultiConnector modules have those members @@ -103,16 +110,16 @@ connect_(Source & source, Target & target mpp_FnParamsKomma()); template typename boost::enable_if< boost::mpl::and_< - senf::ppi::module::detail::is_multiconnector_source, - boost::mpl::not_< senf::ppi::module::detail::is_multiconnector_target > >, + senf::ppi::module::detail::IsMulticonnectorSource, + boost::mpl::not_< senf::ppi::module::detail::IsMulticonnectorTarget > >, typename Source::ConnectorType & >::type connect(Source & source, Target & target mpp_FnParamsKomma()); template typename boost::enable_if< boost::mpl::and_< - boost::mpl::not_< senf::ppi::module::detail::is_multiconnector_source >, - senf::ppi::module::detail::is_multiconnector_target >, + boost::mpl::not_< senf::ppi::module::detail::IsMulticonnectorSource >, + senf::ppi::module::detail::IsMulticonnectorTarget >, typename Target::ConnectorType & >::type connect(Source & source, Target & target mpp_FnParamsKomma()); @@ -126,7 +133,7 @@ connect(Source & source, Target & target mpp_FnParamsKomma()); // //////////////////////////////////////////////////////////////////////// #elif BOOST_PP_ITERATION_FLAGS()==6 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -// senf::ppi namespace member declaration (nested) +// senf::ppi namespace member declaration 1..2*MAX_ARGS template typename boost::enable_if< @@ -139,7 +146,7 @@ connect(Source & source, Target & target mpp_FnParamsKomma()); // //////////////////////////////////////////////////////////////////////// #elif BOOST_PP_ITERATION_FLAGS()==4 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -// senf::ppi::detail namespace member declaration (nested iteration) +// senf::ppi namespace member declaration 1..MAX_ARGS x 1..MAX_ARGS namespace detail { @@ -152,9 +159,27 @@ connect_(Fn, Source & source, Target & target mpp_FnParamsKomma() mpp_FnParamsKo } // //////////////////////////////////////////////////////////////////////// +#elif BOOST_PP_ITERATION_FLAGS()==8 // //////////////////////////////////// +// //////////////////////////////////////////////////////////////////////// +// senf::ppi::module::detail::MultiConnectorMixinAccess member declaration 1..MAX_ARGS + +template +static typename Module::ConnectorType & +newConnector(Module & module mpp_FnParamsKomma()); + +// //////////////////////////////////////////////////////////////////////// +#elif BOOST_PP_ITERATION_FLAGS()==10 // /////////////////////////////////// +// //////////////////////////////////////////////////////////////////////// +// senf::ppi::module::detail::MultiConnectorMixinAccess member declaration 1..2*MAX_ARGS + +template +static std::pair +connect(Source & source, Target & target mpp_FnParamsKomma()); + +// //////////////////////////////////////////////////////////////////////// #elif BOOST_PP_ITERATION_FLAGS()==3 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -// Implementation +// Implementation 1..MAX_ARGS //////////////////////////////////////// // Map container @@ -202,32 +227,13 @@ newConnector(mpp_FnParams()) } //////////////////////////////////////// -// senf::ppi::module::detail::MultiConnectorMixinAccess members - -template -typename Module::ConnectorType & -senf::ppi::module::detail::MultiConnectorMixinAccess::newConnector( - Module & module mpp_FnParamsKomma()) -{ - return module.newConnector(mpp_CallParams()); -} - -template -std::pair -senf::ppi::module::detail::MultiConnectorMixinAccess::connect( - Source & source, Target & target mpp_FnParamsKomma()) -{ - return Source::connect_(source, target mpp_CallParamsKomma()); -} - -//////////////////////////////////////// // senf::ppi::connect template typename boost::enable_if< boost::mpl::and_< - senf::ppi::module::detail::is_multiconnector_source, - boost::mpl::not_< senf::ppi::module::detail::is_multiconnector_target > >, + senf::ppi::module::detail::IsMulticonnectorSource, + boost::mpl::not_< senf::ppi::module::detail::IsMulticonnectorTarget > >, typename Source::ConnectorType & >::type senf::ppi::connect(Source & source, Target & target mpp_FnParamsKomma()) { @@ -240,8 +246,8 @@ senf::ppi::connect(Source & source, Target & target mpp_FnParamsKomma()) template typename boost::enable_if< boost::mpl::and_< - boost::mpl::not_< senf::ppi::module::detail::is_multiconnector_source >, - senf::ppi::module::detail::is_multiconnector_target >, + boost::mpl::not_< senf::ppi::module::detail::IsMulticonnectorSource >, + senf::ppi::module::detail::IsMulticonnectorTarget >, typename Target::ConnectorType & >::type senf::ppi::connect(Source & source, Target & target mpp_FnParamsKomma()) { @@ -251,6 +257,17 @@ senf::ppi::connect(Source & source, Target & target mpp_FnParamsKomma()) return c; } +//////////////////////////////////////// +// senf::ppi::module::detail::MultiConnectorMixinAccess members + +template +typename Module::ConnectorType & +senf::ppi::module::detail::MultiConnectorMixinAccess::newConnector( + Module & module mpp_FnParamsKomma()) +{ + return module.newConnector(mpp_CallParams()); +} + #define BOOST_PP_ITERATION_PARAMS_2 (4, (\ 0, \ SENF_MULTI_CONNECTOR_MAX_ARGS, \ @@ -259,29 +276,12 @@ senf::ppi::connect(Source & source, Target & target mpp_FnParamsKomma()) #include BOOST_PP_ITERATE() // //////////////////////////////////////////////////////////////////////// -#elif BOOST_PP_ITERATION_FLAGS()==5 // //////////////////////////////////// -// //////////////////////////////////////////////////////////////////////// -// Implementation for nested iteration - -template -typename boost::enable_if_c< - senf::function_arity::value == BOOST_PP_ITERATION()+1, - std::pair >::type -senf::ppi::detail::connect_(Fn, Source & source, Target & target - mpp_FnParamsKomma() mpp_FnParamsKomma2()) -{ - typename Source::ConnectorType & s ( - module::detail::MultiConnectorMixinAccess::newConnector(source mpp_CallParamsKomma())); - typename Target::ConnectorType & t ( - module::detail::MultiConnectorMixinAccess::newConnector(target mpp_CallParamsKomma2())); - connect(s,t); - return std::pair(s,t); -} - -// //////////////////////////////////////////////////////////////////////// #elif BOOST_PP_ITERATION_FLAGS()==7 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -// Implementation +// Implementation 1..2*MAX_ARGS + +//////////////////////////////////////// +// Map container template template @@ -293,6 +293,9 @@ connect_(Source & source, Target & target mpp_FnParamsKomma()) & Self_::connectorSetup, source, target mpp_CallParamsKomma()); } +//////////////////////////////////////// +// Vector container + template template std::pair @@ -303,6 +306,9 @@ connect_(Source & source, Target & target mpp_FnParamsKomma()) & Self_::connectorSetup, source, target mpp_CallParamsKomma()); } +//////////////////////////////////////// +// User container + template template std::pair @@ -313,6 +319,9 @@ connect_(Source & source, Target & target mpp_FnParamsKomma()) & Self_::connectorSetup, source, target mpp_CallParamsKomma()); } +//////////////////////////////////////// +// senf::ppi::connect + template typename boost::enable_if< boost::mpl::and_< @@ -325,18 +334,36 @@ senf::ppi::connect(Source & source, Target & target mpp_FnParamsKomma()) source, target mpp_CallParamsKomma()); } -// //////////////////////////////////////////////////////////////////////// -#elif BOOST_PP_ITERATION_FLAGS()==8 // //////////////////////////////////// -// //////////////////////////////////////////////////////////////////////// +//////////////////////////////////////// // senf::ppi::module::detail::MultiConnectorMixinAccess members -template -static typename Module::ConnectorType & -newConnector(Module & module mpp_FnParamsKomma()); - template -static std::pair -connect(Source & source, Target & target mpp_FnParamsKomma()); +std::pair +senf::ppi::module::detail::MultiConnectorMixinAccess::connect( + Source & source, Target & target mpp_FnParamsKomma()) +{ + return Source::connect_(source, target mpp_CallParamsKomma()); +} + +//////////////////////////////////////////////////////////////////////// +#elif BOOST_PP_ITERATION_FLAGS()==5 // //////////////////////////////////// +// //////////////////////////////////////////////////////////////////////// +// Implementation 1..MAX_ARGS x 1..MAX_ARGS + +template +typename boost::enable_if_c< + senf::function_arity::value == BOOST_PP_ITERATION()+1, + std::pair >::type +senf::ppi::detail::connect_(Fn, Source & source, Target & target + mpp_FnParamsKomma() mpp_FnParamsKomma2()) +{ + typename Source::ConnectorType & s ( + module::detail::MultiConnectorMixinAccess::newConnector(source mpp_CallParamsKomma())); + typename Target::ConnectorType & t ( + module::detail::MultiConnectorMixinAccess::newConnector(target mpp_CallParamsKomma2())); + connect(s,t); + return std::pair(s,t); +} // //////////////////////////////////////////////////////////////////////// #endif // ///////////////////////////////////////////////////////////////// diff --git a/senf/PPI/MultiConnectorMixin.test.cc b/senf/PPI/MultiConnectorMixin.test.cc index 44d6402..158be13 100644 --- a/senf/PPI/MultiConnectorMixin.test.cc +++ b/senf/PPI/MultiConnectorMixin.test.cc @@ -91,13 +91,6 @@ namespace { { os << value.value; return os; } } -BOOST_AUTO_UNIT_TEST(multiConnectorTraits) -{ - BOOST_STATIC_ASSERT( senf::ppi::module::detail::is_multiconnector_source::value ); - BOOST_STATIC_ASSERT( ! senf::ppi::module::detail::is_multiconnector_target::value ); -} - - BOOST_AUTO_UNIT_TEST(multiConnectorMixin_userContainer) { debug::ActiveSource source;