From: g0dil Date: Tue, 8 Sep 2009 13:02:36 +0000 (+0000) Subject: PPI: Implement a more sane multi-connector connect API X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=0584aff454ea331f482f830c3ee16d4fdafb3ffb;p=senf.git PPI: Implement a more sane multi-connector connect API git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1399 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/AnnotationRouter.test.cc b/senf/PPI/AnnotationRouter.test.cc index 670d929..e832403 100644 --- a/senf/PPI/AnnotationRouter.test.cc +++ b/senf/PPI/AnnotationRouter.test.cc @@ -60,10 +60,10 @@ BOOST_AUTO_UNIT_TEST(annotationRouter) senf::ppi::module::AnnotationRouter router; senf::ppi::connect(source, router); - senf::ppi::connect(router, sink1, 1); - senf::ppi::connect(router, sink2, 2); + senf::ppi::connect(router, 1, sink1); + senf::ppi::connect(router, 2, sink2); - BOOST_CHECK_THROW( senf::ppi::connect(router, sink2, 2), + BOOST_CHECK_THROW( senf::ppi::connect(router, 2, sink2), senf::ppi::module::AnnotationRouter::DuplicateKeyException); senf::ppi::init(); diff --git a/senf/PPI/MultiConnectorMixin.cti b/senf/PPI/MultiConnectorMixin.cti index 1a79cf7..3df16d8 100644 --- a/senf/PPI/MultiConnectorMixin.cti +++ b/senf/PPI/MultiConnectorMixin.cti @@ -110,14 +110,6 @@ senf::ppi::connect(Source & source, Target & target , A1 const & a1) 3 )) #include BOOST_PP_ITERATE() -// Include 'senf::ppi::detail implementation' from MultiConnectorMixin.mpp -#define BOOST_PP_ITERATION_PARAMS_1 (4, ( \ - 0, \ - 2*SENF_MULTI_CONNECTOR_MAX_ARGS, \ - SENF_ABSOLUTE_INCLUDE_PATH(PPI/MultiConnectorMixin.mpp), \ - 7 )) -#include BOOST_PP_ITERATE() - #endif ///////////////////////////////cti.e/////////////////////////////////////// diff --git a/senf/PPI/MultiConnectorMixin.hh b/senf/PPI/MultiConnectorMixin.hh index 996722c..f0d3102 100644 --- a/senf/PPI/MultiConnectorMixin.hh +++ b/senf/PPI/MultiConnectorMixin.hh @@ -88,13 +88,6 @@ namespace ppi { 2 )) # 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), \ - 6 )) -# include BOOST_PP_ITERATE() - #endif namespace module { diff --git a/senf/PPI/MultiConnectorMixin.ih b/senf/PPI/MultiConnectorMixin.ih index 72121b2..5207def 100644 --- a/senf/PPI/MultiConnectorMixin.ih +++ b/senf/PPI/MultiConnectorMixin.ih @@ -43,13 +43,6 @@ 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 diff --git a/senf/PPI/MultiConnectorMixin.mpp b/senf/PPI/MultiConnectorMixin.mpp index 6beca75..78a3f8f 100644 --- a/senf/PPI/MultiConnectorMixin.mpp +++ b/senf/PPI/MultiConnectorMixin.mpp @@ -114,7 +114,7 @@ typename boost::enable_if< senf::ppi::module::detail::IsMulticonnectorSource, boost::mpl::not_< senf::ppi::module::detail::IsMulticonnectorTarget > >, typename Source::ConnectorType & >::type -connect(Source & source, Target & target mpp_FnParamsKomma()); +connect(Source & source mpp_FnParamsKomma(), Target & target); template typename boost::enable_if< @@ -132,32 +132,17 @@ connect(Source & source, Target & target mpp_FnParamsKomma()); #include BOOST_PP_ITERATE() // //////////////////////////////////////////////////////////////////////// -#elif BOOST_PP_ITERATION_FLAGS()==6 // //////////////////////////////////// +#elif BOOST_PP_ITERATION_FLAGS()==4 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -// senf::ppi namespace member declaration 1..2*MAX_ARGS +// senf::ppi namespace member declaration 1..MAX_ARGS x 1..MAX_ARGS -template +template typename boost::enable_if< boost::mpl::and_< boost::is_base_of, boost::is_base_of >, boost::tuple >::type -connect(Source & source, Target & target mpp_FnParamsKomma()); - -// //////////////////////////////////////////////////////////////////////// -#elif BOOST_PP_ITERATION_FLAGS()==4 // //////////////////////////////////// -// //////////////////////////////////////////////////////////////////////// -// senf::ppi namespace member declaration 1..MAX_ARGS x 1..MAX_ARGS - -namespace detail { - -template -typename boost::enable_if_c< - senf::function_arity::value == BOOST_PP_ITERATION()+1, - boost::tuple >::type -connect_(Fn, Source & source, Target & target mpp_FnParamsKomma() mpp_FnParamsKomma2()); - -} +connect(Source & source mpp_FnParamsKomma(), Target & target mpp_FnParamsKomma2()); // //////////////////////////////////////////////////////////////////////// #elif BOOST_PP_ITERATION_FLAGS()==8 // //////////////////////////////////// @@ -169,15 +154,6 @@ 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 boost::tuple -connect(Source & source, Target & target mpp_FnParamsKomma()); - -// //////////////////////////////////////////////////////////////////////// #elif BOOST_PP_ITERATION_FLAGS()==3 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// // Implementation 1..MAX_ARGS @@ -236,7 +212,7 @@ typename boost::enable_if< 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()) +senf::ppi::connect(Source & source mpp_FnParamsKomma(), Target & target) { typename Source::ConnectorType & c ( module::detail::MultiConnectorMixinAccess::newConnector(source mpp_CallParamsKomma())); @@ -276,87 +252,18 @@ senf::ppi::module::detail::MultiConnectorMixinAccess::newConnector( 5 )) #include BOOST_PP_ITERATE() +//////////////////////////////////////////////////////////////////////// +#elif BOOST_PP_ITERATION_FLAGS()==5 // //////////////////////////////////// // //////////////////////////////////////////////////////////////////////// -#elif BOOST_PP_ITERATION_FLAGS()==7 // //////////////////////////////////// -// //////////////////////////////////////////////////////////////////////// -// Implementation 1..2*MAX_ARGS - -//////////////////////////////////////// -// Map container - -template -template -boost::tuple -senf::ppi::module::MultiConnectorMixin:: -connect_(Source & source, Target & target mpp_FnParamsKomma()) -{ - return senf::ppi::detail::connect_( - & Self_::connectorSetup, source, target mpp_CallParamsKomma()); -} - -//////////////////////////////////////// -// Vector container - -template -template -boost::tuple -senf::ppi::module::MultiConnectorMixin:: -connect_(Source & source, Target & target mpp_FnParamsKomma()) -{ - return senf::ppi::detail::connect_( - & Self_::connectorSetup, source, target mpp_CallParamsKomma()); -} - -//////////////////////////////////////// -// User container - -template -template -boost::tuple -senf::ppi::module::MultiConnectorMixin:: -connect_(Source & source, Target & target mpp_FnParamsKomma()) -{ - return senf::ppi::detail::connect_( - & Self_::connectorSetup, source, target mpp_CallParamsKomma()); -} - -//////////////////////////////////////// -// senf::ppi::connect +// Implementation 1..MAX_ARGS x 1..MAX_ARGS -template +template typename boost::enable_if< boost::mpl::and_< boost::is_base_of, boost::is_base_of >, boost::tuple >::type -senf::ppi::connect(Source & source, Target & target mpp_FnParamsKomma()) -{ - return module::detail::MultiConnectorMixinAccess::connect( - source, target mpp_CallParamsKomma()); -} - -//////////////////////////////////////// -// senf::ppi::module::detail::MultiConnectorMixinAccess members - -template -boost::tuple -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, - boost::tuple >::type -senf::ppi::detail::connect_(Fn, Source & source, Target & target - mpp_FnParamsKomma() mpp_FnParamsKomma2()) +senf::ppi::connect(Source & source mpp_FnParamsKomma(), Target & target mpp_FnParamsKomma2()) { typename Source::ConnectorType & s ( module::detail::MultiConnectorMixinAccess::newConnector(source mpp_CallParamsKomma())); diff --git a/senf/PPI/MultiConnectorMixin.test.cc b/senf/PPI/MultiConnectorMixin.test.cc index 158be13..84fcbaf 100644 --- a/senf/PPI/MultiConnectorMixin.test.cc +++ b/senf/PPI/MultiConnectorMixin.test.cc @@ -123,7 +123,7 @@ BOOST_AUTO_UNIT_TEST(multiConnectorMixin_multipleModules) ppi::connect(source, join1); ppi::connect(join1, router); - ppi::connect(router, join2, 1); + ppi::connect(router, 1, join2); ppi::connect(join2, module); ppi::connect(module, sink);