Route.hh
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 
17 #ifndef HH_SENF_PPI_Route_
18 #define HH_SENF_PPI_Route_ 1
19 
20 // Custom includes
21 #include "predecl.hh"
22 
23 //#include "Route.mpp"
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 namespace ppi {
28 
34  class RouteBase
35  {
36  public:
37  virtual ~RouteBase();
38 
39  bool hasConnector(connector::Connector const & conn) const;
41  bool hasEvent(EventDescriptor const & event) const;
43 
44  protected:
45  RouteBase();
46 
47 #ifdef DOXYGEN
48  Source & source() const;
49 
52  Target & target() const;
53 
56 #endif
57 
58  private:
59  virtual bool v_hasConnector(connector::Connector const & conn) const = 0;
60  virtual bool v_hasEvent(EventDescriptor const & event) const = 0;
61  };
62 
70  : public RouteBase
71  {
72  public:
73  bool autoThrottling() const;
74  void autoThrottling(bool state);
75 
89  bool throttled() const;
90 
94  protected:
96 
97  // Called to register this route with the connectors forwarding information base
98  template <class T> void registerRoute(T & ob);
99  template <class T> void unregisterRoute(T & ob);
100 
101  template <class T> void notifyThrottle(T & ob);
102  template <class T> void notifyUnthrottle(T & ob);
103 
104  private:
105  // called to forward a throttling notification along the route
106  void notifyThrottle();
107  void notifyUnthrottle();
108 
109  // Implemented in the derived classes to forward throttling notifications
110  virtual void v_notifyThrottle() = 0;
111  virtual void v_notifyUnthrottle() = 0;
112  virtual bool v_throttled() const = 0;
113 
114  bool autoThrottling_;
115 
117  };
118 
119 }}
120 
121 // We need detail::RouteImplementation here ...
122 #include "Route.ih"
123 
124 namespace senf {
125 namespace ppi {
126 
142  template <class Source, class Target>
143  class Route
144  : public detail::RouteImplementation<Source,Target>
145  {
146  private:
147  typedef detail::RouteImplementation<Source,Target> Base;
148  typedef detail::RouteImplementation<Source,Target> Implementation;
149 
150  Route(Source & source, Target & target);
151 
152  friend class module::Module;
153  };
154 
155 }}
156 
157 //-/////////////////////////////////////////////////////////////////////////////////////////////////
158 #include "Route.cci"
159 #include "Route.ct"
160 #include "Route.cti"
161 #endif
162 
163 
164 // Local Variables:
165 // mode: c++
166 // fill-column: 100
167 // c-file-style: "senf"
168 // indent-tabs-mode: nil
169 // ispell-local-dictionary: "american"
170 // compile-command: "scons -u test"
171 // comment-column: 40
172 // End:
Module base-class.
Definition: Module.hh:169
Active connector base-class.
Definition: Connectors.hh:309
Generic event interface base-class.
Definition: Events.hh:60
Source & source() const
Routing source.
predecl public header
Target & target() const
Routing target.
Connector base-class.
Definition: Connectors.hh:156
Route descriptor.
Definition: predecl.hh:36
Forwarding route base class.
Definition: Route.hh:69
Routing base class.
Definition: Route.hh:34
bool hasEvent(EventDescriptor const &event) const
true, if route has event event
bool hasConnector(connector::Connector const &conn) const
true, if route has connector conn