ModuleManager.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 ModuleManager inline non-template implementation */
16 
17 // Custom includes
18 #include <algorithm>
19 
20 #define prefix_ inline
21 //-/////////////////////////////////////////////////////////////////////////////////////////////////
22 
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 // senf::ppi::ModuleManager
25 
26 prefix_ senf::ppi::ModuleManager & senf::ppi::ModuleManager::instance()
27 {
28  static ModuleManager manager;
29  return manager;
30 }
31 
32 prefix_ bool senf::ppi::ModuleManager::initializableRegistered(Initializable const & i)
33  const
34 {
35  return alive_ ? std::find(initQueue_.begin(), initQueue_.end(), &i) != initQueue_.end() : false;
36 }
37 
38 prefix_ bool senf::ppi::ModuleManager::running()
39  const
40 {
41  return running_;
42 }
43 
44 prefix_ senf::console::DirectoryNode & senf::ppi::ModuleManager::consoleDir()
45  const
46 {
47  return consoleDir_.node();
48 }
49 
50 //-/////////////////////////////////////////////////////////////////////////////////////////////////
51 // senf::ppi::ModuleManager::Initializable
52 
53 prefix_ senf::ppi::ModuleManager::Initializable::Initializable()
54 {
55  enqueueInitializable();
56 }
57 
58 prefix_ senf::ppi::ModuleManager::Initializable::~Initializable()
59 {
60  dequeueInitializable();
61 }
62 
63 prefix_ void senf::ppi::ModuleManager::Initializable::enqueueInitializable()
64 {
65  moduleManager().registerInitializable(*this);
66 }
67 
68 prefix_ void senf::ppi::ModuleManager::Initializable::dequeueInitializable()
69 {
70  moduleManager().unregisterInitializable(*this);
71 }
72 
73 prefix_ bool senf::ppi::ModuleManager::Initializable::initializationScheduled()
74  const
75 {
76  return moduleManager().initializableRegistered(*this);
77 }
78 
79 prefix_ senf::ppi::ModuleManager & senf::ppi::ModuleManager::Initializable::moduleManager()
80  const
81 {
82  return ModuleManager::instance();
83 }
84 
85 //-/////////////////////////////////////////////////////////////////////////////////////////////////
86 #undef prefix_
87 
88 
89 // Local Variables:
90 // mode: c++
91 // fill-column: 100
92 // comment-column: 40
93 // c-file-style: "senf"
94 // indent-tabs-mode: nil
95 // ispell-local-dictionary: "american"
96 // compile-command: "scons -u test"
97 // End: