PPI: Implement DebugEvent
[senf.git] / PPI / Route.hh
1 // Copyright (C) 2007 
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
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.
10 //
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.
15 //
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.
20
21 /** \file
22     \brief Route public header */
23
24 #ifndef HH_Route_
25 #define HH_Route_ 1
26
27 // Custom includes
28 #include <boost/type_traits.hpp>
29 #include "predecl.hh"
30
31 //#include "Route.mpp"
32 ///////////////////////////////hh.p////////////////////////////////////////
33
34 namespace senf {
35 namespace ppi {
36
37     class RouteBase
38     {
39     public:
40         virtual ~RouteBase();
41
42     protected:
43         RouteBase(module::Module & module);
44
45     private:
46         module::Module * module_;
47     };
48
49     class ForwardingRoute
50         : public RouteBase
51     {
52     public:
53         bool autoThrottling();
54         void autoThrottling(bool state); ///< Change automatic throttle notification forwarding
55                                         /**< By default, throttle notifications are automatically
56                                              forwarded from active to passive connectors. This may
57                                              be disabled by setting the authoThrottling state to \c
58                                              false.
59                                              
60                                              Routing from/to an event to/from a passive connector
61                                              will automatically create throttling notifications on
62                                              the connector whenever the event is disabled. Routing
63                                              form/to an event to/from an active connector will
64                                              disable the event whenever a throttling notification
65                                              comes in. Respective for unthrottle notifications.
66
67                                              \param[in] state New throttle forwarding state */
68         
69     protected:
70         ForwardingRoute(module::Module & module);
71
72         // Called to register this route with the connectors forwarding information base
73         void registerRoute(connector::ActiveConnector & connector);
74
75         template <class T> void notifyThrottle(T & ob);
76         template <class T> void notifyUnthrottle(T & ob);
77
78     private:
79         // called to forward a throttling notification along the route
80         void notifyThrottle();
81         void notifyUnthrottle();
82
83         // Implemented in the derived classes to forward throttling notifications
84         virtual void v_notifyThrottle() = 0;
85         virtual void v_notifyUnthrottle() = 0;
86
87         bool autoThrottling_;
88
89         friend class connector::ActiveConnector;
90     };
91
92 }}
93
94 // We need detail::RouteImplementation here ...
95 #include "Route.ih"
96
97 namespace senf {
98 namespace ppi {
99
100     /** \brief Route descriptor
101         
102         Route instances are created by Module::route statements. The Route class provides an
103         interface to manipulate the flow processing.
104      */
105     template <class Source, class Target>
106     class Route
107         : public detail::RouteImplementation<Source,Target>
108     {
109         typedef detail::RouteImplementation<Source,Target> Base;
110     private:
111         typedef detail::RouteImplementation<Source,Target> Implementation;
112         
113         Route(module::Module & module, Source & source, Target & target);
114
115         friend class module::Module;
116     };
117
118 }}
119
120 ///////////////////////////////hh.e////////////////////////////////////////
121 #include "Route.cci"
122 #include "Route.ct"
123 #include "Route.cti"
124 #endif
125
126 \f
127 // Local Variables:
128 // mode: c++
129 // fill-column: 100
130 // c-file-style: "senf"
131 // indent-tabs-mode: nil
132 // ispell-local-dictionary: "american"
133 // compile-command: "scons -u test"
134 // comment-column: 40
135 // End: