PPI: Complete connector implementation
[senf.git] / PPI / Route.cci
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Route inline non-template implementation */
25
26 // Custom includes
27 #include "Connectors.hh"
28 #include "Events.hh"
29
30 #define prefix_ inline
31 ///////////////////////////////cci.p///////////////////////////////////////
32
33 ///////////////////////////////////////////////////////////////////////////
34 // senf::ppi::RouteBase
35
36 prefix_ senf::ppi::RouteBase::~RouteBase()
37 {}
38
39 ////////////////////////////////////////
40 // protected members
41
42 prefix_ senf::ppi::RouteBase::RouteBase(module::Module & module)
43     : module_(&module)
44 {}
45
46 ///////////////////////////////////////////////////////////////////////////
47 // senf::ppi::ForwardingRoute
48
49 prefix_ bool senf::ppi::ForwardingRoute::autoThrottling()
50 {
51     return autoThrottling_;
52 }
53
54 prefix_ void senf::ppi::ForwardingRoute::autoThrottling(bool state)
55 {
56     autoThrottling_ = state;
57 }
58
59 ////////////////////////////////////////
60 // protected members
61
62 prefix_ senf::ppi::ForwardingRoute::ForwardingRoute(module::Module & module)
63     : RouteBase(module), autoThrottling_(false)
64 {}
65
66 prefix_ void senf::ppi::ForwardingRoute::registerRoute(connector::ActiveConnector & connector)
67 {
68     connector.registerRoute(*this);
69 }
70
71 ////////////////////////////////////////
72 // private members
73
74 prefix_ void senf::ppi::ForwardingRoute::notifyThrottle()
75 {
76     v_notifyThrottle();
77 }
78
79 prefix_ void senf::ppi::ForwardingRoute::notifyUnthrottle()
80 {
81     v_notifyUnthrottle();
82 }
83
84 ///////////////////////////////////////////////////////////////////////////
85 // senf::ppi::detail::NonForwardingRouteImplementation
86
87 prefix_ senf::ppi::detail::NonForwardingRouteImplementation::
88 NonForwardingRouteImplementation(module::Module & module, connector::InputConnector & source,
89                                  connector::OutputConnector & target)
90     : RouteBase(module), source_(&source), target_(&target)
91 {}
92
93 ///////////////////////////////////////////////////////////////////////////
94 // senf::ppi::detail::NonForwardingRouteToEventImplementation
95
96 prefix_
97 senf::ppi::detail::NonForwardingRouteToEventImplementation::
98 NonForwardingRouteToEventImplementation(module::Module & module,
99                                         connector::InputConnector & source,
100                                         EventDescriptor & target)
101     : RouteBase(module), source_(&source), target_(&target)
102 {}
103
104 ///////////////////////////////////////////////////////////////////////////
105 // senf::ppi::detail::NonForwardingRouteFromEventImplementation
106
107 prefix_
108 senf::ppi::detail::NonForwardingRouteFromEventImplementation::
109 NonForwardingRouteFromEventImplementation(module::Module & module, EventDescriptor & source,
110                                           connector::OutputConnector & target)
111     : RouteBase(module), source_(&source), target_(&target)
112 {}
113
114 ///////////////////////////////////////////////////////////////////////////
115 // senf::ppi::detail::ForwardForwardingRouteImplementation
116
117 prefix_
118 senf::ppi::detail::ForwardForwardingRouteImplementation::
119 ForwardForwardingRouteImplementation(module::Module & module, connector::ActiveInput & source,
120                                      connector::PassiveOutput & target)
121     : ForwardingRoute(module), source_(&source), target_(&target)
122 {
123     registerRoute(*source_);
124 }
125
126 prefix_ void senf::ppi::detail::ForwardForwardingRouteImplementation::v_notifyThrottle()
127 {
128     if (autoThrottling())
129         target_->notifyThrottle();
130 }
131
132 prefix_ void senf::ppi::detail::ForwardForwardingRouteImplementation::v_notifyUnthrottle()
133 {
134     if (autoThrottling())
135         target_->notifyUnthrottle();
136 }
137
138 ///////////////////////////////////////////////////////////////////////////
139 // senf::ppi::detail::BackwardForwardingRouteImplementation
140
141 prefix_
142 senf::ppi::detail::BackwardForwardingRouteImplementation::
143 BackwardForwardingRouteImplementation(module::Module & module,
144                                       connector::PassiveInput & source,
145                                       connector::ActiveOutput & target)
146     : ForwardingRoute(module), source_(&source), target_(&target)
147 {
148     registerRoute(*target_);
149 }
150
151 prefix_ void senf::ppi::detail::BackwardForwardingRouteImplementation::v_notifyThrottle()
152
153     if (autoThrottling())
154         source_->notifyThrottle();
155 }
156
157 prefix_ void senf::ppi::detail::BackwardForwardingRouteImplementation::v_notifyUnthrottle()
158 {
159     if (autoThrottling())
160         source_->notifyUnthrottle();
161 }
162
163 ///////////////////////////////////////////////////////////////////////////
164 // senf::ppi::detail::ForwardForwardingRouteToEventImplementation
165
166 prefix_
167 senf::ppi::detail::ForwardForwardingRouteToEventImplementation::
168 ForwardForwardingRouteToEventImplementation(module::Module & module,
169                                             connector::ActiveInput & source,
170                                             EventDescriptor & target)
171     : ForwardingRoute(module), source_(&source), target_(&target)
172 {
173     registerRoute(*source_);
174 }
175
176 prefix_ void senf::ppi::detail::ForwardForwardingRouteToEventImplementation::v_notifyThrottle()
177 {
178     if (autoThrottling())
179         target_->enabled(false);
180 }
181
182 prefix_ void
183 senf::ppi::detail::ForwardForwardingRouteToEventImplementation::v_notifyUnthrottle()
184 {
185     if (autoThrottling())
186         target_->enabled(true);
187 }
188
189 ///////////////////////////////////////////////////////////////////////////
190 //senf::ppi::detail::BackwardForwardingRouteFromEventImplementation
191
192 prefix_
193 senf::ppi::detail::BackwardForwardingRouteFromEventImplementation::
194 BackwardForwardingRouteFromEventImplementation(module::Module & module,
195                                                EventDescriptor & source,
196                                                connector::ActiveOutput & target)
197     : ForwardingRoute(module), source_(&source), target_(&target)
198 {
199     registerRoute(*target_);
200 }
201
202 prefix_ void
203 senf::ppi::detail::BackwardForwardingRouteFromEventImplementation::v_notifyThrottle()
204 {
205     if (autoThrottling())
206         source_->enabled(false);
207 }
208
209 prefix_ void
210 senf::ppi::detail::BackwardForwardingRouteFromEventImplementation::v_notifyUnthrottle()
211
212     if (autoThrottling())
213         source_->enabled(true);
214 }
215
216 ///////////////////////////////////////////////////////////////////////////
217 // senf::ppi::detail::RouteImplementation<connector::ActiveInput, connector::PassiveOutput, 
218 //                                        false, false>
219
220 prefix_
221 senf::ppi::detail::RouteImplementation<senf::ppi::connector::ActiveInput, 
222                                        senf::ppi::connector::PassiveOutput, 
223                                        false, false>::
224 RouteImplementation(module::Module & module, connector::ActiveInput & source,
225                     connector::PassiveOutput & target)
226     : ForwardForwardingRouteImplementation(module, source, target)
227 {}
228
229 ////////////////////////////////////////////////////////////////////////////
230 // senf::ppi::detail::RouteImplementation<connector::PassiveInput, connector::ActiveOutput, 
231 //                                        false, false>
232
233 prefix_
234 senf::ppi::detail::RouteImplementation<senf::ppi::connector::PassiveInput, 
235                                        senf::ppi::connector::ActiveOutput, 
236                                        false, false>::
237 RouteImplementation(module::Module & module, connector::PassiveInput & source,
238                     connector::ActiveOutput & target)
239     : BackwardForwardingRouteImplementation(module, source, target)
240 {}
241
242 ///////////////////////////////cci.e///////////////////////////////////////
243 #undef prefix_
244
245 \f
246 // Local Variables:
247 // mode: c++
248 // fill-column: 100
249 // comment-column: 40
250 // c-file-style: "senf"
251 // indent-tabs-mode: nil
252 // ispell-local-dictionary: "american"
253 // compile-command: "scons -u test"
254 // End: