switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / PPI / Route.cti
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
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
10 //
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.
14 //
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.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
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.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief Route inline template implementation */
30
31 #include "Route.ih"
32
33 // Custom includes
34
35 #define prefix_ inline
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::ppi::Route<Source,Target>
40
41 template <class Source, class Target>
42 prefix_ senf::ppi::Route<Source,Target>::Route(module::Module & module, Source & source,
43                                                Target & target)
44     : Base(module,source,target)
45 {}
46
47 //-/////////////////////////////////////////////////////////////////////////////////////////////////
48 // senf::ppi::ForwardingRoute
49
50 //-/////////////////////////////////////////////////////////////////////////////////////////////////
51 // protected members
52
53 template <class T>
54 prefix_ void senf::ppi::ForwardingRoute::registerRoute(T & ob)
55 {
56     ob.registerRoute(*this);
57 }
58
59 template <class T>
60 prefix_ void senf::ppi::ForwardingRoute::unregisterRoute(T & ob)
61 {
62     ob.unregisterRoute(*this);
63 }
64
65 template <class T>
66 prefix_ void senf::ppi::ForwardingRoute::notifyThrottle(T & ob)
67 {
68     ob.notifyThrottle();
69 }
70
71 template <class T>
72 prefix_ void senf::ppi::ForwardingRoute::notifyUnthrottle(T & ob)
73 {
74     ob.notifyUnthrottle();
75 }
76
77 //-/////////////////////////////////////////////////////////////////////////////////////////////////
78 // senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>
79
80 template <class Source, class Target, class Base>
81 prefix_ Source & senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::source()
82     const
83 {
84     return *source_;
85 }
86
87 template <class Source, class Target, class Base>
88 prefix_ Target & senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::target()
89     const
90 {
91     return *target_;
92 }
93
94 //-/////////////////////////////////////////////////////////////////////////////////////////////////
95 // protected members
96
97 template <class Source, class Target, class Base>
98 prefix_ senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
99 BaseRouteImplementation(module::Module & module, Source & source, Target & target)
100     : Base(module), source_(&source), target_(&target)
101 {}
102
103 //-/////////////////////////////////////////////////////////////////////////////////////////////////
104 // private members
105
106 template <class Source, class Target, class Base>
107 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
108 v_hasConnector(connector::Connector const & conn)
109     const
110 {
111     return isSame(conn, source()) || isSame(conn, target());
112 }
113
114 template <class Source, class Target, class Base>
115 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
116 v_hasEvent(EventDescriptor const & event)
117     const
118 {
119     return isSame(event, source()) || isSame(event, target());
120 }
121
122 template <class Source, class Target, class Base>
123 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
124 isSame(connector::Connector const & conn, connector::Connector const & other)
125     const
126 {
127     return &conn == &other;
128 }
129
130 template <class Source, class Target, class Base>
131 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
132 isSame(connector::Connector const & conn, EventDescriptor const & other)
133     const
134 {
135     return false;
136 }
137
138 template <class Source, class Target, class Base>
139 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
140 isSame(EventDescriptor const & event, connector::Connector const & other)
141     const
142 {
143     return false;
144 }
145
146 template <class Source, class Target, class Base>
147 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
148 isSame(EventDescriptor const & event, EventDescriptor const & other)
149     const
150 {
151     return &event == &other;
152 }
153
154 //-/////////////////////////////////////////////////////////////////////////////////////////////////
155 // senf::ppi::detail::ForwardingRouteImplementation<Source,Target>
156
157 //-/////////////////////////////////////////////////////////////////////////////////////////////////
158 // protected members
159
160 template <class Source, class Target>
161 prefix_
162 senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
163 ForwardingRouteImplementation(module::Module & module, Source & source, Target & target)
164     : Base(module,source,target)
165 {
166     registerRoute(source);
167     registerRoute(target);
168 }
169
170 template <class Source, class Target>
171 prefix_
172 senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
173 ~ForwardingRouteImplementation()
174 {
175     unregisterRoute(this->source());
176     unregisterRoute(this->target());
177 }
178
179 //-/////////////////////////////////////////////////////////////////////////////////////////////////
180 // private members
181
182 template <class Source, class Target>
183 template <class T>
184 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
185 notifyThrottle(T & ob, boost::mpl::bool_<true> const &)
186 {
187     ForwardingRoute::notifyThrottle(ob);
188 }
189
190 template <class Source, class Target>
191 template <class T>
192 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
193 notifyThrottle(T & ob, boost::mpl::bool_<false> const &)
194 {}
195
196 template <class Source, class Target>
197 template <class T>
198 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
199 notifyUnthrottle(T & ob, boost::mpl::bool_<true> const &)
200 {
201     ForwardingRoute::notifyUnthrottle(ob);
202 }
203
204 template <class Source, class Target>
205 template <class T>
206 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
207 notifyUnthrottle(T & ob, boost::mpl::bool_<false> const &)
208 {}
209
210 template <class Source, class Target>
211 template <class T>
212 prefix_ bool senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
213 throttled(T & ob, boost::mpl::bool_<true> const &)
214     const
215 {
216     return ob.throttled();
217 }
218
219 template <class Source, class Target>
220 template <class T>
221 prefix_ bool senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
222 throttled(T & ob, boost::mpl::bool_<false> const &)
223     const
224 {
225     return false;
226 }
227
228 //-/////////////////////////////////////////////////////////////////////////////////////////////////
229 // senf::ppi::detail::RouteImplementation2<Source,Target>
230
231 //-/////////////////////////////////////////////////////////////////////////////////////////////////
232 // protected members
233
234 template <class Source, class Target>
235 prefix_ senf::ppi::detail::RouteImplementation2<Source,Target>::
236 RouteImplementation2(module::Module & module, Source & source, Target & target)
237     : Base(module,source,target)
238 {}
239
240 //-/////////////////////////////////////////////////////////////////////////////////////////////////
241 // senf::ppi::detail::RouteImplementation<Source,Target>
242
243 //-/////////////////////////////////////////////////////////////////////////////////////////////////
244 // protected members
245
246 template <class Source, class Target>
247 prefix_ senf::ppi::detail::RouteImplementation<Source,Target>::
248 RouteImplementation(module::Module & module, Source & source, Target & target)
249     : Base(module,source,target)
250 {}
251
252 //-/////////////////////////////////////////////////////////////////////////////////////////////////
253 #undef prefix_
254
255 \f
256 // Local Variables:
257 // mode: c++
258 // fill-column: 100
259 // comment-column: 40
260 // c-file-style: "senf"
261 // indent-tabs-mode: nil
262 // ispell-local-dictionary: "american"
263 // compile-command: "scons -u test"
264 // End: