PPI: output throttle state on ppi-dump
[senf.git] / senf / PPI / ModuleManager.cc
index 77f190c..82aef9d 100644 (file)
 //#include "ModuleManager.ih"
 
 // Custom includes
-#include "../Scheduler/Scheduler.hh"
-#include "../Utils/membind.hh"
+#include <senf/Scheduler/Scheduler.hh>
+#include <senf/Utils/membind.hh>
 #include "Module.hh"
-#include "../Utils/Console/Console.hh"
+#include <senf/Utils/Console/ParsedCommand.hh>
+#include <senf/Utils/Console/Sysdir.hh>
 
 //#include "ModuleManager.mpp"
 #define prefix_
@@ -70,26 +71,29 @@ prefix_ void senf::ppi::ModuleManager::run()
 // 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 <host> <port> \\\n"
-             "          | python PPI/drawmodules.py | dot -Tpng /dev/fd/0 >modules.png\n");
+        .add("dump", senf::console::factory::Command(
+                 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 'tools/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 <host> <port> \\\n"
+                  "          | python tools/drawmodules.py | dot -Tpng /dev/fd/0 >modules.png\n")
+            );
 }
 
 prefix_ void senf::ppi::ModuleManager::dumpModules(std::ostream & os)
+    const
 {
     for (ModuleRegistry::const_iterator i (moduleRegistry_.begin()), i_end (moduleRegistry_.end());
          i != i_end; ++i) {
@@ -97,8 +101,12 @@ prefix_ void senf::ppi::ModuleManager::dumpModules(std::ostream & os)
         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())
+            if ((**j).connected()) {
                 os << " " << & (*j)->peer();
+                connector::PassiveConnector * pc (dynamic_cast<connector::PassiveConnector *>(*j));
+                if (pc && pc->throttled())
+                    os << " throttled";
+            }
             os << "\n";
         }
         os << "\n";