4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief Setup public header */
31 #ifndef HH_SENF_PPI_Setup_
32 #define HH_SENF_PPI_Setup_ 1
35 #include <boost/type_traits.hpp>
36 #include <boost/utility/enable_if.hpp>
39 //#include "Setup.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 struct DisableStandardInput {};
47 struct DisableStandardOutput {};
48 struct DisableStandardConnect : public DisableStandardInput, public DisableStandardOutput {};
53 /** \brief Connect modules
55 senf::ppi::connect() establishes a connection between two modules or, to be more precise,
56 between two connectors. It will connect any input to any output connector as long as one is
57 active and the other passive.
59 If a module has an output connector called \c output, the module may be directly specified
60 as \a source argument. In the same way, if a module has an input connector called \c input,
61 the module may be given directly as \a target argument. This simplifies the most common case
62 of a module with one input and one output connector.
64 The connect call will check at runtime, whether the two connectors are type-compatible:
65 \li Either or both of the connectors are untyped (they accept/send arbitrary senf::Packet's)
66 \li Both connectors send/accept the exactly same packet type.
68 Depending on the type of input or output, the connect call may require additional
69 arguments. See the respective module documentation for more information
71 \throws connector::IncompatibleConnectorsException if the two connectors are not type
74 \see \ref ppi_connections
76 void connect(connector::OutputConnector & source, connector::InputConnector & target, ...);
80 void connect(connector::GenericActiveOutput & source, connector::GenericPassiveInput & target);
81 void connect(connector::GenericPassiveOutput & source, connector::GenericActiveInput & target);
87 template <class T, class C>
88 void connect(T & source, C & target,
89 typename boost::disable_if< boost::is_base_of<connector::Connector, T> >::type * = 0,
90 typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type * = 0,
91 typename boost::disable_if< boost::is_base_of<detail::DisableStandardOutput, T> >::type * = 0);
93 template <class C, class T>
94 void connect(C & source, T & target,
95 typename boost::enable_if< boost::is_base_of<connector::Connector, C> >::type * = 0,
96 typename boost::disable_if< boost::is_base_of<connector::Connector,T> >::type * = 0,
97 typename boost::disable_if< boost::is_base_of<detail::DisableStandardInput, T> >::type * = 0);
99 template <class T1, class T2>
100 void connect(T1 & source, T2 & target,
101 typename boost::disable_if< boost::is_base_of<connector::Connector, T1> >::type * = 0,
102 typename boost::disable_if< boost::is_base_of<connector::Connector, T2> >::type * = 0,
103 typename boost::disable_if< boost::is_base_of<detail::DisableStandardOutput, T1> >:: type * = 0,
104 typename boost::disable_if< boost::is_base_of<detail::DisableStandardInput, T2> >:: type * = 0);
108 /** \brief Start the network
110 Calling senf::ppi::run() will start processing the network. The main event loop is managed
111 by the Scheduler. Before starting the Scheduler main loop, all Module init() members are
114 senf::ppi::run() will return when no more work is to be done, that is when no events are
115 enabled (Since the events are enabled and disabled by the throttle notifications which
116 depend among other things on the packet queues, this is the same as checking for packets in
117 any queue). It is Ok to call senf::ppi::run() multiple times during the program lifetime.
123 /** \brief Manually initialize the network
125 For debugging purposes, it is sometimes simpler to not use senf::ppi::run() but instead
126 drive the network via explicit calls using the debug modules. However, it is still necessary
127 to initialize the network. This operation is performed by senf::ppi::init().
133 //-/////////////////////////////////////////////////////////////////////////////////////////////////
135 //#include "Setup.ct"
143 // comment-column: 40
144 // c-file-style: "senf"
145 // indent-tabs-mode: nil
146 // ispell-local-dictionary: "american"
147 // compile-command: "scons -u test"