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
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
15 \brief Route inline template implementation */
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::ppi::Route<Source,Target>
27 template <class Source, class Target>
28 prefix_ senf::ppi::Route<Source,Target>::Route(Source & source, Target & target)
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33 // senf::ppi::ForwardingRoute
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 prefix_ void senf::ppi::ForwardingRoute::registerRoute(T & ob)
41 ob.registerRoute(*this);
45 prefix_ void senf::ppi::ForwardingRoute::unregisterRoute(T & ob)
47 ob.unregisterRoute(*this);
51 prefix_ void senf::ppi::ForwardingRoute::notifyThrottle(T & ob)
57 prefix_ void senf::ppi::ForwardingRoute::notifyUnthrottle(T & ob)
59 ob.notifyUnthrottle();
62 //-/////////////////////////////////////////////////////////////////////////////////////////////////
63 // senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>
65 template <class Source, class Target, class Base>
66 prefix_ Source & senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::source()
72 template <class Source, class Target, class Base>
73 prefix_ Target & senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::target()
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
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)
88 //-/////////////////////////////////////////////////////////////////////////////////////////////////
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)
96 return isSame(conn, source()) || isSame(conn, target());
99 template <class Source, class Target, class Base>
100 prefix_ bool senf::ppi::detail::BaseRouteImplementation<Source,Target,Base>::
101 v_hasEvent(EventDescriptor const & event)
104 return isSame(event, source()) || isSame(event, target());
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)
112 return &conn == &other;
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)
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)
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)
136 return &event == &other;
139 //-/////////////////////////////////////////////////////////////////////////////////////////////////
140 // senf::ppi::detail::ForwardingRouteImplementation<Source,Target>
142 //-/////////////////////////////////////////////////////////////////////////////////////////////////
145 template <class Source, class Target>
147 senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
148 ForwardingRouteImplementation(Source & source, Target & target)
149 : Base(source,target)
151 Base::registerRoute(source);
152 Base::registerRoute(target);
155 template <class Source, class Target>
157 senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
158 ~ForwardingRouteImplementation()
160 Base::unregisterRoute(this->source());
161 Base::unregisterRoute(this->target());
164 //-/////////////////////////////////////////////////////////////////////////////////////////////////
167 template <class Source, class Target>
169 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
170 notifyThrottle(T & ob, boost::mpl::bool_<true> const &)
172 ForwardingRoute::notifyThrottle(ob);
175 template <class Source, class Target>
177 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
178 notifyThrottle(T & ob, boost::mpl::bool_<false> const &)
181 template <class Source, class Target>
183 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
184 notifyUnthrottle(T & ob, boost::mpl::bool_<true> const &)
186 ForwardingRoute::notifyUnthrottle(ob);
189 template <class Source, class Target>
191 prefix_ void senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
192 notifyUnthrottle(T & ob, boost::mpl::bool_<false> const &)
195 template <class Source, class Target>
197 prefix_ bool senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
198 throttled(T & ob, boost::mpl::bool_<true> const &)
201 return ob.throttled();
204 template <class Source, class Target>
206 prefix_ bool senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
207 throttled(T & ob, boost::mpl::bool_<false> const &)
213 //-/////////////////////////////////////////////////////////////////////////////////////////////////
214 // senf::ppi::detail::RouteImplementation2<Source,Target>
216 //-/////////////////////////////////////////////////////////////////////////////////////////////////
219 template <class Source, class Target>
220 prefix_ senf::ppi::detail::RouteImplementation2<Source,Target>::
221 RouteImplementation2(Source & source, Target & target)
222 : Base(source,target)
225 //-/////////////////////////////////////////////////////////////////////////////////////////////////
226 // senf::ppi::detail::RouteImplementation<Source,Target>
228 //-/////////////////////////////////////////////////////////////////////////////////////////////////
231 template <class Source, class Target>
232 prefix_ senf::ppi::detail::RouteImplementation<Source,Target>::
233 RouteImplementation(Source & source, Target & target)
234 : Base(source,target)
237 //-/////////////////////////////////////////////////////////////////////////////////////////////////
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"