4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief ModuleManager non-inline non-template implementation */
31 #include "ModuleManager.hh"
32 //#include "ModuleManager.ih"
35 #include <senf/Utils/membind.hh>
36 #include <senf/Utils/Console/ParsedCommand.hh>
37 #include <senf/Utils/Console/Sysdir.hh>
40 //#include "ModuleManager.mpp"
42 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 // senf::ppi::ModuleManager
47 prefix_ void senf::ppi::ModuleManager::init()
49 while (! initQueue_.empty()) {
50 initQueue_.front()->v_init();
51 initQueue_.pop_front();
53 initRunner_.disable();
58 struct senf::ppi::ModuleManager::RunGuard
60 RunGuard(ModuleManager & m) : manager(m) { manager.running_ = true; }
61 ~RunGuard() { manager.running_ = false; }
62 ModuleManager & manager;
67 prefix_ void senf::ppi::ModuleManager::run()
70 RunGuard guard (*this);
74 //-/////////////////////////////////////////////////////////////////////////////////////////////////
77 prefix_ senf::ppi::ModuleManager::ModuleManager()
78 : running_(false), terminate_(false),
79 initRunner_ ("senf::ppi::init", membind(&ModuleManager::init, this),
80 scheduler::EventHook::PRE, false)
82 console::sysdir().add("ppi", consoleDir_);
85 .add("dump", console::factory::Command(
86 senf::membind(&ModuleManager::dumpModules, this))
87 .doc("Dump complete PPI structure\n"
88 "The dump will contain one paragraph for each module. The first line gives module\n"
89 "information, additional lines list all connectors and their peers (if connected).\n"
91 "This information can be processed by 'tools/drawmodules.py' and 'dot' (from the\n"
92 "graphviz package) to generate a graphic representation of the module structure:\n"
94 " $ echo /sys/ppi/dump | nc -q1 <host> <port> \\\n"
95 " | python tools/drawmodules.py | dot -Tpng /dev/fd/0 >modules.png\n")
99 prefix_ void senf::ppi::ModuleManager::dumpModules(std::ostream & os)
102 for (ModuleRegistry::const_iterator i (moduleRegistry_.begin()), i_end (moduleRegistry_.end());
104 os << *i << " " << prettyName(typeid(**i)) << "\n";
105 for (module::Module::ConnectorRegistry::iterator j ((*i)->connectorRegistry_.begin()),
106 j_end ((*i)->connectorRegistry_.end()); j != j_end; ++j) {
107 os << " " << *j << " " << prettyName(typeid(**j));
108 if ((**j).connected()) {
109 os << " " << & (*j)->peer();
110 connector::PassiveConnector * pc (dynamic_cast<connector::PassiveConnector *>(*j));
111 if (pc && pc->throttled())
120 //-/////////////////////////////////////////////////////////////////////////////////////////////////
122 //#include "ModuleManager.mpp"
128 // comment-column: 40
129 // c-file-style: "senf"
130 // indent-tabs-mode: nil
131 // ispell-local-dictionary: "american"
132 // compile-command: "scons -u test"