Module.cci
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 Module inline non-template implementation */
16 
17 // Custom includes
18 #include "Route.hh"
19 #include "EventManager.hh"
20 #include <boost/lambda/lambda.hpp>
21 #include <boost/lambda/bind.hpp>
22 #include <algorithm>
23 
24 #define prefix_ inline
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 // senf::ppi::module::Module
29 
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
31 // private members
32 
33 prefix_ senf::ppi::EventManager & senf::ppi::module::Module::eventManager()
34  const
35 {
36  return EventManager::instance();
37 }
38 
39 prefix_ senf::ppi::ModuleManager & senf::ppi::module::Module::moduleManager()
40  const
41 {
42  return ModuleManager::instance();
43 }
44 
45 prefix_ void senf::ppi::module::Module::unregisterEvent(EventDescriptor & event)
46 {
47  routes_.erase_if(boost::bind(&RouteBase::hasEvent, _1, boost::cref(event)));
48 }
49 
50 //-/////////////////////////////////////////////////////////////////////////////////////////////////
51 // public members
52 
53 prefix_ senf::ppi::module::Module::~Module()
54 {
55  SENF_ASSERT(connectorRegistry_.empty(),
56  "Internal failure: connectors still registered in Module destructor ??");
57  SENF_ASSERT(routes_.empty(),
58  "internal failure: routes still registered in Module destructor ??");
59 
60  moduleManager().unregisterModule(*this);
61 }
62 
63 prefix_ senf::ClockService::clock_type const & senf::ppi::module::Module::time()
64  const
65 {
66  return eventManager().time();
67 }
68 
69 prefix_ senf::ClockService::clock_type const & senf::ppi::module::Module::now()
70  const
71 {
72  return eventManager().now();
73 }
74 
75 //-/////////////////////////////////////////////////////////////////////////////////////////////////
76 // protected members
77 
78 prefix_ senf::ppi::module::Module::Module()
79 {
80  moduleManager().registerModule(*this);
81 }
82 
83 prefix_ void senf::ppi::module::Module::destroy()
84 {
85  if (EventManager::alive())
86  eventManager().destroyModule(*this);
87 }
88 
89 prefix_ senf::console::DirectoryNode & senf::ppi::module::Module::sysConsoleDir()
90  const
91 {
92  return sysConsoleDir_.node();
93 }
94 
95 //-/////////////////////////////////////////////////////////////////////////////////////////////////
96 #undef prefix_
97 
98 
99 // Local Variables:
100 // mode: c++
101 // fill-column: 100
102 // comment-column: 40
103 // c-file-style: "senf"
104 // indent-tabs-mode: nil
105 // ispell-local-dictionary: "american"
106 // compile-command: "scons -u test"
107 // End: