PPI: Add support for multiple notify sources per notify target
[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() const;
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         bool throttled() const;
70         
71     protected:
72         ForwardingRoute(module::Module & module);
73
74         // Called to register this route with the connectors forwarding information base
75         template <class T> void registerRoute(T & ob);
76
77         template <class T> void notifyThrottle(T & ob);
78         template <class T> void notifyUnthrottle(T & ob);
79
80     private:
81         // called to forward a throttling notification along the route
82         void notifyThrottle();
83         void notifyUnthrottle();
84
85         // Implemented in the derived classes to forward throttling notifications
86         virtual void v_notifyThrottle() = 0;
87         virtual void v_notifyUnthrottle() = 0;
88         virtual bool v_throttled() const = 0;
89
90         bool autoThrottling_;
91
92         friend class connector::ActiveConnector;
93     };
94
95 }}
96
97 // We need detail::RouteImplementation here ...
98 #include "Route.ih"
99
100 namespace senf {
101 namespace ppi {
102
103     /** \brief Route descriptor
104         
105         Route instances are created by Module::route statements. The Route class provides an
106         interface to manipulate the flow processing.
107      */
108     template <class Source, class Target>
109     class Route
110         : public detail::RouteImplementation<Source,Target>
111     {
112         typedef detail::RouteImplementation<Source,Target> Base;
113     private:
114         typedef detail::RouteImplementation<Source,Target> Implementation;
115         
116         Route(module::Module & module, Source & source, Target & target);
117
118         friend class module::Module;
119     };
120
121 }}
122
123 ///////////////////////////////hh.e////////////////////////////////////////
124 #include "Route.cci"
125 #include "Route.ct"
126 #include "Route.cti"
127 #endif
128
129 \f
130 // Local Variables:
131 // mode: c++
132 // fill-column: 100
133 // c-file-style: "senf"
134 // indent-tabs-mode: nil
135 // ispell-local-dictionary: "american"
136 // compile-command: "scons -u test"
137 // comment-column: 40
138 // End: