DebugModules.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_DebugModules_
18 #define HH_SENF_PPI_DebugModules_ 1
19 
20 // Custom includes
21 #include <deque>
22 #include <senf/Utils/safe_bool.hh>
25 #include "MonitorModule.hh"
26 #include "ActiveFeeder.hh"
27 
28 //#include "DebugModules.mpp"
29 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30 
31 namespace senf {
32 namespace ppi {
33 namespace module {
34 namespace debug {
35 
68  : public Module,
69  public safe_bool<ActiveSource>
70  {
72 
73  public:
75 
76  ActiveSource();
77 
78  void submit(Packet const & packet);
79 
81  bool boolean_test() const;
82  };
83 
91  : public Module
92  {
94 
95  typedef std::deque<Packet> Queue;
96 
97  public:
98  typedef Queue::size_type size_type;
99 
101 
102  PassiveSource();
103 
104  void throttle();
105  void unthrottle();
106 
107  void submit(Packet const & packet);
108 
109  bool empty();
110  size_type size();
111 
112  private:
113  void request();
114  virtual void v_init() override;
115 
116  Queue packets_;
117  };
118 
129  : public Module,
130  public safe_bool<ActiveSink>
131  {
133 
134  public:
136 
137  ActiveSink();
138 
139  Packet request();
140 
142  bool boolean_test() const;
143  };
144 
151  : public Module
152  {
154 
155  typedef std::deque<Packet> Queue;
156 
157  public:
158  typedef Queue::size_type size_type;
159  typedef Queue::const_iterator iterator;
160 
162 
163  PassiveSink();
164 
165  void throttle();
166  void unthrottle();
167 
168  bool empty();
169  size_type size();
170  iterator begin();
171  iterator end();
172 
173  Packet front();
174  Packet pop_front();
175 
176  void clear();
177 
178  private:
179  void request();
180 
181  Queue packets_;
182  };
183 
199  {
200  private:
201  PassiveSource source;
202  ActiveFeeder feeder;
203 
204  public:
206 
208 
210 
211  void submit(Packet packet);
212  bool empty();
213  size_type size();
214  };
215 
231  {
232  private:
233  PassiveSink sink;
234  ActiveFeeder feeder;
235 
236  public:
239 
241 
243 
244  bool empty();
245  size_type size();
246  iterator begin();
247  iterator end();
248 
249  Packet front();
250  Packet pop_front();
251 
252  void clear();
253  };
254 
260  template < class Stream = log::Debug,
261  class Area = log::DefaultArea,
262  class Level = log::VERBOSE >
263  class Logger
264  : public MonitorModule<>
265  {
267  public:
268  Logger();
269  explicit Logger(std::string label);
270 
271  private:
272  virtual void v_handlePacket(Packet const & packet);
273 
274  std::string label_;
275  };
276 
277 }}}}
278 
279 //-/////////////////////////////////////////////////////////////////////////////////////////////////
280 #include "DebugModules.cci"
281 //#include "DebugModules.ct"
282 #include "DebugModules.cti"
283 #endif
284 
285 
286 // Local Variables:
287 // mode: c++
288 // fill-column: 100
289 // comment-column: 40
290 // c-file-style: "senf"
291 // indent-tabs-mode: nil
292 // ispell-local-dictionary: "american"
293 // compile-command: "scons -u test"
294 // End:
Connector actively sending packets.
Definition: Connectors.hh:677
Module base-class.
Definition: Module.hh:169
Debug packet sink with active input.
bool empty()
Debug packet source with active output.
Definition: DebugModules.hh:67
Debug packet source with passive output.
Definition: DebugModules.hh:90
Connector actively reading packets.
Definition: Connectors.hh:632
Base class providing simple monitor module support.
ActiveFeeder public header.
Debug packet sink with passive input.
Active, queue-based packet source.
bool boolean_test() const
true if output is not throttled
MonitorModule public header.
#define SENF_PPI_MODULE(name)
Define PPI Module.
Definition: Module.hh:346
Connector passively providing packets.
Definition: Connectors.hh:697
Log received packets.
void submit(Packet const &packet)
Submit packet.
Connector passively receiving packets.
Definition: Connectors.hh:655
::phoenix::function< detail::clear > const clear
virtual void v_init()
Called after module setup.
Definition: Module.cc:120
Adapter to connect passive connectors.
Definition: ActiveFeeder.hh:43
Active, queue-based packet sink.