Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

EventManager.cc

Go to the documentation of this file.
00001 // $Id: EventManager.cc 1771 2011-03-08 14:43:47Z tho $
00002 //
00003 // Copyright (C) 2008
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 //#include "EventManager.hh"
00027 //#include "EventManager.ih"
00028 
00029 // Custom includes
00030 #include <boost/format.hpp>
00031 #include <senf/Utils/membind.hh>
00032 #include <senf/Utils/Console/ScopedDirectory.hh>
00033 #include <senf/Utils/Console/ParsedCommand.hh>
00034 #include "ConsoleDir.hh"
00035 #include "FIFORunner.hh"
00036 
00037 //#include "EventManager.mpp"
00038 #define prefix_
00039 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00040 
00041 prefix_ senf::scheduler::detail::EventManager::EventManager()
00042 {
00043 #ifndef SENF_DISABLE_CONSOLE
00044     consoleDir().add("events", console::factory::Command(
00045             membind(&EventManager::listEvents, this))
00046         .doc("List all scheduler events sorted by priority\n"
00047              "\n"
00048              "Columns:\n"
00049              "    TP      event type:\n"
00050              "              fd  file descriptor\n"
00051              "              tm  timer\n"
00052              "              si  UNIX signal\n"
00053              "              ee  event hook\n"
00054              "    NAME    descriptive event name\n"
00055              "    ADDRESS address of event class instance\n"
00056              "    RUNCNT  number of times, the event was called\n"
00057              "    S       state:\n"
00058              "              R  runnable\n"
00059              "              W  waiting\n"
00060              "              -  event disabled\n"
00061              "    INFO    further event specific information")
00062         );
00063 #endif
00064 }
00065 
00066 prefix_ void senf::scheduler::detail::EventManager::listEvents(std::ostream & os)
00067 {
00068     // On an 80 column display, this wraps nicely directly before the INFO column
00069     boost::format fmt  ("%s %-55.55s 0x%08x %8d %s %s\n");
00070     os << boost::format("%s %-55.55s %-10s %8s %s %s\n")
00071         % "TP" % "NAME" % "ADDRESS" % "RUNCNT" % "S" % "INFO";
00072     {
00073         FIFORunner::iterator i (FIFORunner::instance().begin());
00074         FIFORunner::iterator const i_end (FIFORunner::instance().end());
00075         for (; i != i_end; ++i)
00076             os << fmt
00077                 % i->type()
00078                 % i->name()
00079                 % reinterpret_cast<unsigned long>(&(*i))
00080                 % i->runCount()
00081                 % (i->runnable() ? "R" : "W")
00082                 % i->info();
00083     }
00084     {
00085         iterator i (begin());
00086         iterator const i_end (end());
00087         for (; i != i_end; ++i)
00088             if (! i->enabled())
00089                 os << fmt
00090                     % i->type()
00091                     % i->name()
00092                     % reinterpret_cast<unsigned long>(&(*i))
00093                     % i->runCount()
00094                     % "-"
00095                     % i->info();
00096     }
00097 }
00098 
00099 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00100 #undef prefix_
00101 //#include "EventManager.mpp"
00102 
00103 
00104 // Local Variables:
00105 // mode: c++
00106 // fill-column: 100
00107 // comment-column: 40
00108 // c-file-style: "senf"
00109 // indent-tabs-mode: nil
00110 // ispell-local-dictionary: "american"
00111 // compile-command: "scons -u test"
00112 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research