X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FModuleManager.cc;h=77f190c17eb299c5ec13346a9fd56fb2102a9ceb;hb=d5a72d0b3f6fee56dba6de1c54cafb448ebe3457;hp=e713c74962e18aa4ba68188120304a5ef4176f44;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/PPI/ModuleManager.cc b/PPI/ModuleManager.cc index e713c74..77f190c 100644 --- a/PPI/ModuleManager.cc +++ b/PPI/ModuleManager.cc @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -28,7 +28,9 @@ // Custom includes #include "../Scheduler/Scheduler.hh" +#include "../Utils/membind.hh" #include "Module.hh" +#include "../Utils/Console/Console.hh" //#include "ModuleManager.mpp" #define prefix_ @@ -39,10 +41,11 @@ prefix_ void senf::ppi::ModuleManager::init() { - ModuleRegistry::const_iterator i (moduleRegistry_.begin()); - ModuleRegistry::const_iterator const i_end (moduleRegistry_.end()); - for (; i != i_end; ++i) - (*i)->init(); + while (! initQueue_.empty()) { + initQueue_.front()->v_init(); + initQueue_.pop_front(); + } + initRunner_.disable(); } #ifndef DOXYGEN @@ -60,15 +63,47 @@ prefix_ void senf::ppi::ModuleManager::run() { init(); RunGuard guard (*this); - Scheduler::instance().process(); + scheduler::process(); } //////////////////////////////////////// // private members prefix_ senf::ppi::ModuleManager::ModuleManager() - : running_(false), terminate_(false) -{} + : running_(false), terminate_(false), + initRunner_ ("senf::ppi::init", membind(&ModuleManager::init, this), + scheduler::EventHook::PRE, false) +{ + senf::console::sysdir().add("ppi", consoleDir_); + + consoleDir_ + .add("dump", senf::membind(&ModuleManager::dumpModules, this)) + .doc("Dump complete PPI structure\n" + "The dump will contain one paragraph for each module. The first line gives module\n" + "information, additional lines list all connectors and their peers (if connected).\n" + "\n" + "This information can be processed by 'PPI/drawmodules.py' and 'dot' (from the\n" + "graphviz package) to generate a graphic representation of the module structure:\n" + "\n" + " $ echo /sys/ppi/dump | nc -q1 \\\n" + " | python PPI/drawmodules.py | dot -Tpng /dev/fd/0 >modules.png\n"); +} + +prefix_ void senf::ppi::ModuleManager::dumpModules(std::ostream & os) +{ + for (ModuleRegistry::const_iterator i (moduleRegistry_.begin()), i_end (moduleRegistry_.end()); + i != i_end; ++i) { + os << *i << " " << prettyName(typeid(**i)) << "\n"; + for (module::Module::ConnectorRegistry::iterator j ((*i)->connectorRegistry_.begin()), + j_end ((*i)->connectorRegistry_.end()); j != j_end; ++j) { + os << " " << *j << " " << prettyName(typeid(**j)); + if ((**j).connected()) + os << " " << & (*j)->peer(); + os << "\n"; + } + os << "\n"; + } +} ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_