Restructure SENFSCons.Object helper
[senf.git] / PPI / MultiConnectorMixin.cti
index 4b563e0..3df16d8 100644 (file)
@@ -37,6 +37,15 @@ senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,KeyType_,ContainerTy
     return connectors_;
 }
 
+template <class Self_, class ConnectorType_, class KeyType_, class ContainerType_>
+prefix_ ContainerType_ const &
+senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,KeyType_,ContainerType_>::
+connectors()
+    const
+{
+    return connectors_;
+}
+
 template <class Self_, class ConnectorType_, class ContainerType_>
 prefix_ ContainerType_ &
 senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>::connectors()
@@ -44,6 +53,56 @@ senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>
     return connectors_;
 }
 
+#ifdef DOXYGEN
+
+// Only for exposition
+// Other implementations with 0..SENF_MULTI_CONNECTOR_MAX_ARGS arguments accordingly
+
+template <class Self_, class ConnectorType_, class KeyType_, class ContainerType_>
+template <class A1>
+prefix_ ConnectorType_ &
+senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,KeyType_,ContainerType_>::
+newConnector(A1 const & a1)
+{
+    std::auto_ptr<ConnectorType_> conn (new ConnectorType_);
+    KeyType_ key (static_cast<Self_*>(this)->connectorSetup(*conn, a1));
+    return * connectors_.insert(key, conn).first->second;
+}
+
+template <class Self_, class ConnectorType_, class ContainerType_>
+template <class A1>
+prefix_ ConnectorType_ &
+senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>::
+newConnector(A1 const & a1)
+{
+    connectors_.push_back(new ConnectorType_);
+    ConnectorType_ & conn (connectors_.back());
+    try { static_cast<Self_*>(this)->connectorSetup(conn , a1); }
+    catch (...) { connectors_.pop_back(); throw; }
+    return conn;
+}
+
+template <class Source, class Target , class A1>
+typename boost::enable_if<
+    boost::is_base_of<senf::ppi::connector::OutputConnector, typename Source::ConnectorType>,
+    typename Source::ConnectorType & >::type
+senf::ppi::connect(Source & source, Target & target , A1 const & a1)
+{
+    connect(source.newConnector(a1), target);
+}
+
+template <class Source, class Target , class A1>
+typename boost::enable_if<
+    boost::is_base_of<senf::ppi::connector::InputConnector, typename Target::ConnectorType>,
+    typename Target::ConnectorType & >::type
+senf::ppi::connect(Source & source, Target & target , A1 const & a1)
+{
+    connect(source, target.newConnector(a1));
+}
+
+#else
+
+// Include 'Implementation' from MultiConnectorMixin.mpp
 #define BOOST_PP_ITERATION_PARAMS_1 (4, ( \
             0, \
             SENF_MULTI_CONNECTOR_MAX_ARGS, \
@@ -51,6 +110,8 @@ senf::ppi::module::MultiConnectorMixin<Self_,ConnectorType_,void,ContainerType_>
             3 ))
 #include BOOST_PP_ITERATE()
 
+#endif
+
 ///////////////////////////////cti.e///////////////////////////////////////
 #undef prefix_