4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief ModuleManager non-inline non-template implementation */
26 #include "ModuleManager.hh"
27 //#include "ModuleManager.ih"
30 #include <senf/Scheduler/Scheduler.hh>
31 #include <senf/Utils/membind.hh>
33 #include <senf/Utils/Console/Console.hh>
35 //#include "ModuleManager.mpp"
37 ///////////////////////////////cc.p////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////////////
40 // senf::ppi::ModuleManager
42 prefix_ void senf::ppi::ModuleManager::init()
44 while (! initQueue_.empty()) {
45 initQueue_.front()->v_init();
46 initQueue_.pop_front();
48 initRunner_.disable();
53 struct senf::ppi::ModuleManager::RunGuard
55 RunGuard(ModuleManager & m) : manager(m) { manager.running_ = true; }
56 ~RunGuard() { manager.running_ = false; }
57 ModuleManager & manager;
62 prefix_ void senf::ppi::ModuleManager::run()
65 RunGuard guard (*this);
69 ////////////////////////////////////////
72 prefix_ senf::ppi::ModuleManager::ModuleManager()
73 : running_(false), terminate_(false),
74 initRunner_ ("senf::ppi::init", membind(&ModuleManager::init, this),
75 scheduler::EventHook::PRE, false)
77 senf::console::sysdir().add("ppi", consoleDir_);
80 .add("dump", senf::console::factory::Command(
81 senf::membind(&ModuleManager::dumpModules, this))
82 .doc("Dump complete PPI structure\n"
83 "The dump will contain one paragraph for each module. The first line gives module\n"
84 "information, additional lines list all connectors and their peers (if connected).\n"
86 "This information can be processed by 'PPI/drawmodules.py' and 'dot' (from the\n"
87 "graphviz package) to generate a graphic representation of the module structure:\n"
89 " $ echo /sys/ppi/dump | nc -q1 <host> <port> \\\n"
90 " | python PPI/drawmodules.py | dot -Tpng /dev/fd/0 >modules.png\n")
94 prefix_ void senf::ppi::ModuleManager::dumpModules(std::ostream & os)
96 for (ModuleRegistry::const_iterator i (moduleRegistry_.begin()), i_end (moduleRegistry_.end());
98 os << *i << " " << prettyName(typeid(**i)) << "\n";
99 for (module::Module::ConnectorRegistry::iterator j ((*i)->connectorRegistry_.begin()),
100 j_end ((*i)->connectorRegistry_.end()); j != j_end; ++j) {
101 os << " " << *j << " " << prettyName(typeid(**j));
102 if ((**j).connected())
103 os << " " << & (*j)->peer();
110 ///////////////////////////////cc.e////////////////////////////////////////
112 //#include "ModuleManager.mpp"
118 // comment-column: 40
119 // c-file-style: "senf"
120 // indent-tabs-mode: nil
121 // ispell-local-dictionary: "american"
122 // compile-command: "scons -u test"