2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief Module public header
30 #include <boost/utility.hpp>
31 #include <boost/ptr_container/ptr_vector.hpp>
32 #include "Scheduler/ClockService.hh"
35 //#include "Module.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
42 /** \brief Module baseclass
44 senf::ppi::Module is the baseclass of all PPI modules. It provides the module implementation
45 with interfaces to several PPI facilities:
47 \li Connector management
48 \li Flow management (routing)
51 To provide internal bookkeeping, most access to the PPI infrastructure is managed through
54 Instances of this class may be allocated either statically or dynamically. Dynamic instances
55 are automatically managed using the dynamicModule adaptor.
66 template <class Source, class Target>
67 Route<Source, Target> & route(Source & source, Target & target);
68 ///< Define flow information
69 /**< Using the route() and noroute() members, the
70 information flow within the module is defined. Routing
71 may be specified either between inputs, outputs and
72 events. The routing information is used to perform
73 automatic throttling. The throttling behavior may
74 however be controlled manually.
76 Even if no automatic throttling is desired <em>it is
77 vital to define the flow information for all inputs and
78 outputs</em>. Without flow information important
79 internal state of the module cannot be
80 initialized. This includes, explicitly defining
81 terminal inputs and outputs using noroute. Event
82 routing however is optional.
84 The return value may be used to alter routing
85 parameters like throttling parameters.
87 \param[in] source Data source, object which controls
89 \param[in] target Data target, object which controls
91 \returns Route instance describing this route */
93 void noroute(connector::Connector & connector); ///< Define terminal connectors
94 /**< The noroute() member explicitly declares, that a
95 connector is terminal and does not directly
96 receive/forward data from/to some other
97 connector. <em>It is mandatory to define routing
98 information for terminal connectors</em>.
100 See the route() documentation for more on routing
102 \param[in] connector Terminal connector to declare */
104 template <class Target, class Descriptor>
105 void registerEvent(Target target, Descriptor & descriptor);
106 ///< Register an external event
107 /**< The \a target argument may be either an arbitrary
108 callable object or it may be a member function pointer
109 pointing to a member function of the Module derived
110 classed. The handler may \e optionally take an Argument
111 of type <tt>typename Descriptor::Event const
112 &</tt>. This object allows to access detailed
113 information on the event delivered.
115 The \a descriptor describes the event to signal. This
117 may be a timer event or some type of I/O event on a
118 file descriptor or socket.
120 \param[in] target The handler to call whenever the
122 \param[in] descriptor The type of event to register */
124 ClockService::clock_type eventTime(); ///< Return timestamp of the currently processing
130 virtual void macro_SENF_PPI_MODULE_missing() = 0;
136 EventManager & eventManager();
137 ModuleManager & moduleManager();
139 void registerConnector(connector::Connector & connector);
140 RouteBase & addRoute(std::auto_ptr<RouteBase> route);
142 typedef std::vector<connector::Connector *> ConnectorRegistry;
143 ConnectorRegistry connectorRegistry_;
145 typedef boost::ptr_vector<RouteBase> RouteInfoBase;
146 RouteInfoBase routes_;
148 template <class Source, class Target>
149 friend class detail::RouteHelper;
150 friend class senf::ppi::ModuleManager;
153 # define SENF_PPI_MODULE(name) \
155 ~ name() { destroy(); } \
156 void macro_SENF_PPI_MODULE_missing() {} \
161 ///////////////////////////////hh.e////////////////////////////////////////
162 #include "Module.cci"
164 //#include "Module.cti"
171 // c-file-style: "senf"
172 // indent-tabs-mode: nil
173 // ispell-local-dictionary: "american"
174 // compile-command: "scons -u test"
175 // comment-column: 40