Route.cti
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Route inline template implementation */
16 
17 #include "Route.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::ppi::Route<Source,Target>
26 
27 template <class Source, class Target>
28 prefix_ senf::ppi::Route<Source,Target>::Route(Source & source, Target & target)
29  : Base(source,target)
30 {}
31 
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33 // senf::ppi::ForwardingRoute
34 
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36 // protected members
37 
38 template <class T>
39 prefix_ void senf::ppi::ForwardingRoute::registerRoute(T & ob)
40 {
41  ob.registerRoute(*this);
42 }
43 
44 template <class T>
45 prefix_ void senf::ppi::ForwardingRoute::unregisterRoute(T & ob)
46 {
47  ob.unregisterRoute(*this);
48 }
49 
50 template <class T>
51 prefix_ void senf::ppi::ForwardingRoute::notifyThrottle(T & ob)
52 {
53  ob.notifyThrottle();
54 }
55 
56 template <class T>
57 prefix_ void senf::ppi::ForwardingRoute::notifyUnthrottle(T & ob)
58 {
59  ob.notifyUnthrottle();
60 }
61 
62 //-/////////////////////////////////////////////////////////////////////////////////////////////////
63 // senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>
64 
65 template <class Source, class Target, class Base>
66 prefix_ Source & senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::source()
67  const
68 {
69  return *source_;
70 }
71 
72 template <class Source, class Target, class Base>
73 prefix_ Target & senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::target()
74  const
75 {
76  return *target_;
77 }
78 
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
80 // protected members
81 
82 template <class Source, class Target, class Base>
83 prefix_ senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
84 BaseRouteImplementation(Source & source, Target & target)
85  : source_(&source), target_(&target)
86 {}
87 
88 //-/////////////////////////////////////////////////////////////////////////////////////////////////
89 // private members
90 
91 template <class Source, class Target, class Base>
92 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
93 v_hasConnector(connector::Connector const & conn)
94  const
95 {
96  return isSame(conn, source()) || isSame(conn, target());
97 }
98 
99 template <class Source, class Target, class Base>
100 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
101 v_hasEvent(EventDescriptor const & event)
102  const
103 {
104  return isSame(event, source()) || isSame(event, target());
105 }
106 
107 template <class Source, class Target, class Base>
108 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
109 isSame(connector::Connector const & conn, connector::Connector const & other)
110  const
111 {
112  return &conn == &other;
113 }
114 
115 template <class Source, class Target, class Base>
116 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
117 isSame(connector::Connector const & conn, EventDescriptor const & other)
118  const
119 {
120  return false;
121 }
122 
123 template <class Source, class Target, class Base>
124 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
125 isSame(EventDescriptor const & event, connector::Connector const & other)
126  const
127 {
128  return false;
129 }
130 
131 template <class Source, class Target, class Base>
132 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
133 isSame(EventDescriptor const & event, EventDescriptor const & other)
134  const
135 {
136  return &event == &other;
137 }
138 
139 //-/////////////////////////////////////////////////////////////////////////////////////////////////
140 // senf::ppi::detail::ForwardingRouteImplementation<Source,Target>
141 
142 //-/////////////////////////////////////////////////////////////////////////////////////////////////
143 // protected members
144 
145 template <class Source, class Target>
146 prefix_
147 senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
148 ForwardingRouteImplementation(Source & source, Target & target)
149  : Base(source,target)
150 {
151  Base::registerRoute(source);
152  Base::registerRoute(target);
153 }
154 
155 template <class Source, class Target>
156 prefix_
157 senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
158 ~ForwardingRouteImplementation()
159 {
160  Base::unregisterRoute(this->source());
161  Base::unregisterRoute(this->target());
162 }
163 
164 //-/////////////////////////////////////////////////////////////////////////////////////////////////
165 // private members
166 
167 template <class Source, class Target>
168 template <class T>
169 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
170 notifyThrottle(T & ob, boost::mpl::bool_<true> const &)
171 {
172  ForwardingRoute::notifyThrottle(ob);
173 }
174 
175 template <class Source, class Target>
176 template <class T>
177 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
178 notifyThrottle(T & ob, boost::mpl::bool_<false> const &)
179 {}
180 
181 template <class Source, class Target>
182 template <class T>
183 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
184 notifyUnthrottle(T & ob, boost::mpl::bool_<true> const &)
185 {
186  ForwardingRoute::notifyUnthrottle(ob);
187 }
188 
189 template <class Source, class Target>
190 template <class T>
191 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
192 notifyUnthrottle(T & ob, boost::mpl::bool_<false> const &)
193 {}
194 
195 template <class Source, class Target>
196 template <class T>
197 prefix_ bool senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
198 throttled(T & ob, boost::mpl::bool_<true> const &)
199  const
200 {
201  return ob.throttled();
202 }
203 
204 template <class Source, class Target>
205 template <class T>
206 prefix_ bool senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
207 throttled(T & ob, boost::mpl::bool_<false> const &)
208  const
209 {
210  return false;
211 }
212 
213 //-/////////////////////////////////////////////////////////////////////////////////////////////////
214 // senf::ppi::detail::RouteImplementation2<Source,Target>
215 
216 //-/////////////////////////////////////////////////////////////////////////////////////////////////
217 // protected members
218 
219 template <class Source, class Target>
220 prefix_ senf::ppi::detail::RouteImplementation2<Source,Target>::
221 RouteImplementation2(Source & source, Target & target)
222  : Base(source,target)
223 {}
224 
225 //-/////////////////////////////////////////////////////////////////////////////////////////////////
226 // senf::ppi::detail::RouteImplementation<Source,Target>
227 
228 //-/////////////////////////////////////////////////////////////////////////////////////////////////
229 // protected members
230 
231 template <class Source, class Target>
232 prefix_ senf::ppi::detail::RouteImplementation<Source,Target>::
233 RouteImplementation(Source & source, Target & target)
234  : Base(source,target)
235 {}
236 
237 //-/////////////////////////////////////////////////////////////////////////////////////////////////
238 #undef prefix_
239 
240 
241 // Local Variables:
242 // mode: c++
243 // fill-column: 100
244 // comment-column: 40
245 // c-file-style: "senf"
246 // indent-tabs-mode: nil
247 // ispell-local-dictionary: "american"
248 // compile-command: "scons -u test"
249 // End: