Module.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 
18 #ifndef HH_SENF_PPI_Module_
19 #define HH_SENF_PPI_Module_ 1
20 
21 // Custom includes
22 #include <boost/noncopyable.hpp>
23 #include <boost/ptr_container/ptr_vector.hpp>
26 #include "predecl.hh"
27 #include "ModuleManager.hh"
28 
29 //#include "Module.mpp"
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
31 
32 namespace senf {
33 namespace ppi {
34 
35  namespace detail { class EventBindingBase; }
36 
37 namespace module {
38 
169  class Module
170  : ModuleManager::Initializable, boost::noncopyable
171  {
172  public:
173  virtual ~Module();
174 
175  protected:
176  Module();
177 
178 #ifdef DOXYGEN
180  route(connector::InputConnector & input, connector::OutputConnector & output);
182 
208  route(connector::InputConnector & input, EventDescriptor & output);
210 
224  route(EventDescriptor & input, connector::OutputConnector & output);
226 
237 #else
238 # define route_decl(Source, Target) \
239  Route<Source, Target> & \
240  route(Source & source, Target & target);
241 
250 
251 #undef Route_decl
252 #endif
253 
254  void noroute(connector::Connector & connector);
255 
265 #ifndef DOXYGEN
266  template <class Descriptor, class Target>
267  void registerEvent(Descriptor & descriptor, Target target);
268 #else
269  template <class Target>
270  void registerEvent(EventDescriptor & descriptor, Target target);
272 
289 #endif
290 
291  ClockService::clock_type const & time() const;
292 
295  ClockService::clock_type const & now() const;
296 
297 #ifndef DOXYGEN
298  virtual void macro_SENF_PPI_MODULE_missing() = 0;
299 #endif
300  virtual void v_init();
301 
308  console::DirectoryNode & sysConsoleDir() const;
309 
310 #ifndef DOXYGEN
311  public:
312 #endif
313  void destroy();
314 
315  private:
316  EventManager & eventManager() const;
317  ModuleManager & moduleManager() const;
318 
319  void registerConnector(connector::Connector & connector);
320  void unregisterConnector(connector::Connector & connector);
321  void unregisterEvent(EventDescriptor & event);
322 
323  RouteBase & addRoute(std::unique_ptr<RouteBase> route);
324 
325  typedef std::vector<connector::Connector *> ConnectorRegistry;
326  ConnectorRegistry connectorRegistry_;
327 
328  typedef boost::ptr_vector<RouteBase> RouteInfoBase;
329  RouteInfoBase routes_;
330 
331  console::ScopedDirectory<> sysConsoleDir_;
332 
333  template <class Source, class Target>
334  friend struct detail::RouteHelper;
336  friend class connector::Connector;
338  };
339 
346 # define SENF_PPI_MODULE(name) \
347  public: \
348  ~ name() { destroy(); } \
349  void macro_SENF_PPI_MODULE_missing() override {} \
350  private:
351 
352 }}}
353 
354 //-/////////////////////////////////////////////////////////////////////////////////////////////////
355 #include "Module.cci"
356 #include "Module.ct"
357 //#include "Module.cti"
358 #endif
359 
360 
361 // Local Variables:
362 // mode: c++
363 // fill-column: 100
364 // c-file-style: "senf"
365 // indent-tabs-mode: nil
366 // ispell-local-dictionary: "american"
367 // compile-command: "scons -u test"
368 // comment-column: 40
369 // End:
Internal: Association Event - Module - Handler, base-class.
Definition: EventBinding.hh:33
config::time_type clock_type
Module base-class.
Definition: Module.hh:169
Combination of PassiveConnector and OutputConnector.
Definition: Connectors.hh:513
Combination of ActiveConnector and InputConnector.
Definition: Connectors.hh:538
Input connector base-class.
Definition: Connectors.hh:397
ModuleManager public header.
Output connector base-class.
Definition: Connectors.hh:449
ClockService::clock_type const & now()
Generic event interface base-class.
Definition: Events.hh:60
Combination of ActiveConnector and OutputConnector.
Definition: Connectors.hh:563
Event registry and control.
Definition: EventManager.hh:40
predecl public header
Connector base-class.
Definition: Connectors.hh:156
Route descriptor.
Definition: predecl.hh:36
Routing base class.
Definition: Route.hh:34
Combination of PassiveConnector and InputConnector.
Definition: Connectors.hh:478
Internal: Module management.