From: g0dil Date: Sat, 4 Oct 2008 21:41:36 +0000 (+0000) Subject: Console: Move into Scheduler as subdirectory X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=2da517bbcdb2af10d2322fc762ca27774b53b435;p=senf.git Console: Move into Scheduler as subdirectory Scheduler/Console: Add 'sys' directory Scheduler: Implement EventManager and 'sys/scheduler/events' command git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@926 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Console/SConscript b/Console/SConscript deleted file mode 100644 index fb3fe30..0000000 --- a/Console/SConscript +++ /dev/null @@ -1,21 +0,0 @@ -# -*- python -*- - -Import('env') -import SENFSCons - -########################################################################### - -sources = SENFSCons.GlobSources( exclude = [ 'testServer.cc' ] ) -SENFSCons.StandardTargets(env) - -SENFSCons.Lib(env, - library = 'Console', - sources = sources, - LIBS = [ 'Socket', 'Scheduler', 'Utils' ]) - -SENFSCons.Binary(env, 'testServer', - sources = [ 'testServer.cc' ], - no_includes = True, - LIBS = [ 'Console', 'Socket', 'Scheduler', 'Utils' ]) - -SENFSCons.Doxygen(env) diff --git a/PPI/IdleEvent.cci b/PPI/IdleEvent.cci index 898c14b..7c43754 100644 --- a/PPI/IdleEvent.cci +++ b/PPI/IdleEvent.cci @@ -32,7 +32,7 @@ // senf::ppi::IdleEvent prefix_ senf::ppi::IdleEvent::IdleEvent() - : timer_ ("PPI idle event", boost::bind(&IdleEvent::cb,this)) + : timer_ ("senf::ppi::IdleEvent", boost::bind(&IdleEvent::cb,this)) {} ///////////////////////////////cci.e/////////////////////////////////////// diff --git a/PPI/IntervalTimer.cci b/PPI/IntervalTimer.cci index 35c7ce2..afa7ba3 100644 --- a/PPI/IntervalTimer.cci +++ b/PPI/IntervalTimer.cci @@ -34,7 +34,7 @@ prefix_ senf::ppi::IntervalTimer::IntervalTimer(ClockService::clock_type interval, unsigned eventsPerInterval) : interval_ (interval), eventsPerInterval_ (eventsPerInterval), - timer_("PPI interval timer", boost::bind(&IntervalTimer::cb,this)) + timer_("senf::ppi::IntervalTimer", boost::bind(&IntervalTimer::cb,this)) {} ///////////////////////////////cci.e/////////////////////////////////////// diff --git a/Console/Config.cc b/Scheduler/Console/Config.cc similarity index 99% rename from Console/Config.cc rename to Scheduler/Console/Config.cc index 1895d16..77d712a 100644 --- a/Console/Config.cc +++ b/Scheduler/Console/Config.cc @@ -27,7 +27,7 @@ #include "Config.ih" // Custom includes -#include "../Utils/membind.hh" +#include "../../Utils/membind.hh" //#include "Config.mpp" #define prefix_ diff --git a/Console/Config.cci b/Scheduler/Console/Config.cci similarity index 99% rename from Console/Config.cci rename to Scheduler/Console/Config.cci index 1f41ebf..46cb12f 100644 --- a/Console/Config.cci +++ b/Scheduler/Console/Config.cci @@ -26,7 +26,7 @@ #include "Config.ih" // Custom includes -#include "../Utils/membind.hh" +#include "../../Utils/membind.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// diff --git a/Console/Config.cti b/Scheduler/Console/Config.cti similarity index 100% rename from Console/Config.cti rename to Scheduler/Console/Config.cti diff --git a/Console/Config.hh b/Scheduler/Console/Config.hh similarity index 100% rename from Console/Config.hh rename to Scheduler/Console/Config.hh diff --git a/Console/Config.ih b/Scheduler/Console/Config.ih similarity index 99% rename from Console/Config.ih rename to Scheduler/Console/Config.ih index 7ee336b..208abb2 100644 --- a/Console/Config.ih +++ b/Scheduler/Console/Config.ih @@ -30,7 +30,7 @@ #include #include #include "Executor.hh" -#include "../Utils/intrusive_refcount.hh" +#include "../../Utils/intrusive_refcount.hh" ///////////////////////////////ih.p//////////////////////////////////////// diff --git a/Console/Config.test.cc b/Scheduler/Console/Config.test.cc similarity index 98% rename from Console/Config.test.cc rename to Scheduler/Console/Config.test.cc index 58d5c1b..8d55c84 100644 --- a/Console/Config.test.cc +++ b/Scheduler/Console/Config.test.cc @@ -34,7 +34,7 @@ #include "ProgramOptions.hh" #include -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/ConfigFile.cc b/Scheduler/Console/ConfigFile.cc similarity index 100% copy from Console/ConfigFile.cc copy to Scheduler/Console/ConfigFile.cc diff --git a/Console/ConfigFile.cci b/Scheduler/Console/ConfigFile.cci similarity index 100% rename from Console/ConfigFile.cci rename to Scheduler/Console/ConfigFile.cci diff --git a/Console/ConfigFile.hh b/Scheduler/Console/ConfigFile.hh similarity index 100% rename from Console/ConfigFile.hh rename to Scheduler/Console/ConfigFile.hh diff --git a/Console/ConfigFile.ih b/Scheduler/Console/ConfigFile.ih similarity index 100% rename from Console/ConfigFile.ih rename to Scheduler/Console/ConfigFile.ih diff --git a/Console/ConfigFile.test.cc b/Scheduler/Console/ConfigFile.test.cc similarity index 99% rename from Console/ConfigFile.test.cc rename to Scheduler/Console/ConfigFile.test.cc index b8e68b9..b1976c2 100644 --- a/Console/ConfigFile.test.cc +++ b/Scheduler/Console/ConfigFile.test.cc @@ -33,7 +33,7 @@ #include "ParsedCommand.hh" #include -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/Console.hh b/Scheduler/Console/Console.hh similarity index 98% copy from Console/Console.hh copy to Scheduler/Console/Console.hh index d459701..276e4fa 100644 --- a/Console/Console.hh +++ b/Scheduler/Console/Console.hh @@ -38,6 +38,7 @@ #include "Config.hh" #include "ConfigFile.hh" #include "ProgramOptions.hh" +#include "Sysdir.hh" ///////////////////////////////hh.e//////////////////////////////////////// //#include "Console.cci" diff --git a/Console/Doxyfile b/Scheduler/Console/Doxyfile similarity index 100% rename from Console/Doxyfile rename to Scheduler/Console/Doxyfile diff --git a/Console/Example.dox b/Scheduler/Console/Example.dox similarity index 100% rename from Console/Example.dox rename to Scheduler/Console/Example.dox diff --git a/Console/Executor.cc b/Scheduler/Console/Executor.cc similarity index 98% rename from Console/Executor.cc rename to Scheduler/Console/Executor.cc index 5000104..80d632f 100644 --- a/Console/Executor.cc +++ b/Scheduler/Console/Executor.cc @@ -30,9 +30,9 @@ #include #include #include -#include "../Utils/senfassert.hh" -#include "../Utils/Range.hh" -#include "../Utils/String.hh" +#include "../../Utils/senfassert.hh" +#include "../../Utils/Range.hh" +#include "../../Utils/String.hh" //#include "Executor.mpp" #define prefix_ diff --git a/Console/Executor.cci b/Scheduler/Console/Executor.cci similarity index 100% rename from Console/Executor.cci rename to Scheduler/Console/Executor.cci diff --git a/Console/Executor.hh b/Scheduler/Console/Executor.hh similarity index 99% rename from Console/Executor.hh rename to Scheduler/Console/Executor.hh index 02cff18..1f27f48 100644 --- a/Console/Executor.hh +++ b/Scheduler/Console/Executor.hh @@ -29,7 +29,7 @@ // Custom includes #include #include "Parse.hh" -#include "../Utils/Logger/SenfLog.hh" +#include "../../Utils/Logger/SenfLog.hh" #include "Node.hh" //#include "Executor.mpp" diff --git a/Console/Executor.test.cc b/Scheduler/Console/Executor.test.cc similarity index 98% rename from Console/Executor.test.cc rename to Scheduler/Console/Executor.test.cc index 1266ae0..a2b98ab 100644 --- a/Console/Executor.test.cc +++ b/Scheduler/Console/Executor.test.cc @@ -31,7 +31,7 @@ #include #include "Executor.hh" -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ @@ -99,7 +99,7 @@ BOOST_AUTO_UNIT_TEST(executor) parser.parse("ls", &setCommand); executor(os, commands.back()); BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLS ); - BOOST_CHECK_EQUAL( os.str(), "dir1/\ndir2/\n" ); + BOOST_CHECK_EQUAL( os.str(), "dir1/\ndir2/\nsys/\n" ); } { diff --git a/Console/Server.test.cc b/Scheduler/Console/LazyDirectory.cc similarity index 74% copy from Console/Server.test.cc copy to Scheduler/Console/LazyDirectory.cc index 7c54f39..02f2e5d 100644 --- a/Console/Server.test.cc +++ b/Scheduler/Console/LazyDirectory.cc @@ -21,25 +21,33 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Server.test unit tests */ + \brief LazyDirectory non-inline non-template implementation */ -//#include "Server.test.hh" -//#include "Server.test.ih" +#include "LazyDirectory.hh" +//#include "LazyDirectory.ih" // Custom includes -#include "Server.hh" - -#include "../Utils/auto_unit_test.hh" -#include +#include "Console.hh" +//#include "LazyDirectory.mpp" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -BOOST_AUTO_UNIT_TEST(server) +prefix_ senf::console::LazyDirectory::LazyDirectory() + : p_( new ScopedDirectory<>() ) +{} + +prefix_ senf::console::LazyDirectory::~LazyDirectory() {} +prefix_ senf::console::ScopedDirectory<> & senf::console::LazyDirectory::operator()() +{ + return *p_; +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ +//#include "LazyDirectory.mpp" // Local Variables: diff --git a/Console/Console.hh b/Scheduler/Console/LazyDirectory.hh similarity index 68% rename from Console/Console.hh rename to Scheduler/Console/LazyDirectory.hh index d459701..041bc42 100644 --- a/Console/Console.hh +++ b/Scheduler/Console/LazyDirectory.hh @@ -21,28 +21,42 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Console public header */ + \brief LazyDirectory public header */ -#ifndef HH_Console_ -#define HH_Console_ 1 +#ifndef HH_LazyDirectory_ +#define HH_LazyDirectory_ 1 // Custom includes +#include +#include -//#include "Console.mpp" +//#include "LazyDirectory.mpp" ///////////////////////////////hh.p//////////////////////////////////////// -#include "Server.hh" -#include "ParsedCommand.hh" -#include "ScopedDirectory.hh" -#include "OverloadedCommand.hh" -#include "Config.hh" -#include "ConfigFile.hh" -#include "ProgramOptions.hh" +namespace senf { +namespace console { + + template class ScopedDirectory; + + class LazyDirectory + : boost::noncopyable + { + public: + LazyDirectory(); + ~LazyDirectory(); + + ScopedDirectory<> & operator()(); + + private: + boost::scoped_ptr< ScopedDirectory<> > p_; + }; + +}} ///////////////////////////////hh.e//////////////////////////////////////// -//#include "Console.cci" -//#include "Console.ct" -//#include "Console.cti" +//#include "LazyDirectory.cci" +//#include "LazyDirectory.ct" +//#include "LazyDirectory.cti" #endif diff --git a/Console/Mainpage.dox b/Scheduler/Console/Mainpage.dox similarity index 100% rename from Console/Mainpage.dox rename to Scheduler/Console/Mainpage.dox diff --git a/Console/Node.cc b/Scheduler/Console/Node.cc similarity index 100% rename from Console/Node.cc rename to Scheduler/Console/Node.cc diff --git a/Console/Node.cci b/Scheduler/Console/Node.cci similarity index 99% rename from Console/Node.cci rename to Scheduler/Console/Node.cci index 1fe834d..dabaec9 100644 --- a/Console/Node.cci +++ b/Scheduler/Console/Node.cci @@ -26,7 +26,7 @@ #include "Node.ih" // Custom includes -#include "../Utils/senfassert.hh" +#include "../../Utils/senfassert.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// diff --git a/Console/Node.cti b/Scheduler/Console/Node.cti similarity index 100% rename from Console/Node.cti rename to Scheduler/Console/Node.cti diff --git a/Console/Node.hh b/Scheduler/Console/Node.hh similarity index 99% rename from Console/Node.hh rename to Scheduler/Console/Node.hh index e284998..05a4e92 100644 --- a/Console/Node.hh +++ b/Scheduler/Console/Node.hh @@ -206,10 +206,10 @@ #include #include #include -#include "../Utils/Exception.hh" -#include "../Utils/mpl.hh" -#include "../Utils/Logger/SenfLog.hh" -#include "../Utils/type_traits.hh" +#include "../../Utils/Exception.hh" +#include "../../Utils/mpl.hh" +#include "../../Utils/Logger/SenfLog.hh" +#include "../../Utils/type_traits.hh" #include "Parse.hh" //#include "Node.mpp" diff --git a/Console/Node.ih b/Scheduler/Console/Node.ih similarity index 100% copy from Console/Node.ih copy to Scheduler/Console/Node.ih diff --git a/Console/Node.test.cc b/Scheduler/Console/Node.test.cc similarity index 98% rename from Console/Node.test.cc rename to Scheduler/Console/Node.test.cc index cab82e3..cc786dc 100644 --- a/Console/Node.test.cc +++ b/Scheduler/Console/Node.test.cc @@ -31,7 +31,7 @@ #include "Node.hh" #include -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ @@ -89,7 +89,7 @@ BOOST_AUTO_UNIT_TEST(directoryNode) BOOST_CHECK( &senf::console::root().get("dir1") == p.get() ); senf::console::root().mkdir("dir2").mkdir("dir3"); - char const * const children[] = { "dir1", "dir2", "fn" }; + char const * const children[] = { "dir1", "dir2", "fn", "sys" }; BOOST_CHECK_EQUAL_COLLECTIONS( boost::make_transform_iterator(senf::console::root().children().begin(), select1st()), @@ -116,7 +116,7 @@ BOOST_AUTO_UNIT_TEST(directoryNode) senf::console::root().remove("dir2"); senf::console::root().remove("fn"); - BOOST_CHECK_EQUAL( senf::console::root().children().size(), 0u ); + BOOST_CHECK_EQUAL( senf::console::root().children().size(), 1u ); } BOOST_AUTO_UNIT_TEST(linkNode) diff --git a/Console/OverloadedCommand.cc b/Scheduler/Console/OverloadedCommand.cc similarity index 100% rename from Console/OverloadedCommand.cc rename to Scheduler/Console/OverloadedCommand.cc diff --git a/Console/OverloadedCommand.cci b/Scheduler/Console/OverloadedCommand.cci similarity index 100% rename from Console/OverloadedCommand.cci rename to Scheduler/Console/OverloadedCommand.cci diff --git a/Console/OverloadedCommand.cti b/Scheduler/Console/OverloadedCommand.cti similarity index 100% copy from Console/OverloadedCommand.cti copy to Scheduler/Console/OverloadedCommand.cti diff --git a/Console/OverloadedCommand.hh b/Scheduler/Console/OverloadedCommand.hh similarity index 99% rename from Console/OverloadedCommand.hh rename to Scheduler/Console/OverloadedCommand.hh index db94afe..c39ff51 100644 --- a/Console/OverloadedCommand.hh +++ b/Scheduler/Console/OverloadedCommand.hh @@ -29,7 +29,7 @@ // Custom includes #include "Node.hh" #include -#include "../Utils/intrusive_refcount.hh" +#include "../../Utils/intrusive_refcount.hh" //#include "OverloadedCommand.mpp" ///////////////////////////////hh.p//////////////////////////////////////// diff --git a/Console/OverloadedCommand.test.cc b/Scheduler/Console/OverloadedCommand.test.cc similarity index 98% rename from Console/OverloadedCommand.test.cc rename to Scheduler/Console/OverloadedCommand.test.cc index ad68f57..67d22de 100644 --- a/Console/OverloadedCommand.test.cc +++ b/Scheduler/Console/OverloadedCommand.test.cc @@ -30,7 +30,7 @@ #include #include "OverloadedCommand.hh" -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/Parse.cc b/Scheduler/Console/Parse.cc similarity index 99% rename from Console/Parse.cc rename to Scheduler/Console/Parse.cc index 83ff10c..48cd0a5 100644 --- a/Console/Parse.cc +++ b/Scheduler/Console/Parse.cc @@ -31,8 +31,8 @@ #include #include #include -#include "../Utils/Exception.hh" -#include "../Utils/senfassert.hh" +#include "../../Utils/Exception.hh" +#include "../../Utils/senfassert.hh" //#include "Parse.mpp" #define prefix_ diff --git a/Console/Parse.cci b/Scheduler/Console/Parse.cci similarity index 99% rename from Console/Parse.cci rename to Scheduler/Console/Parse.cci index b5a71be..563cd6f 100644 --- a/Console/Parse.cci +++ b/Scheduler/Console/Parse.cci @@ -27,7 +27,7 @@ // (disabled) #include "Parse.ih" // Custom includes -#include "../Utils/senfassert.hh" +#include "../../Utils/senfassert.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// diff --git a/Console/Parse.hh b/Scheduler/Console/Parse.hh similarity index 99% rename from Console/Parse.hh rename to Scheduler/Console/Parse.hh index 1c11053..59b0a3b 100644 --- a/Console/Parse.hh +++ b/Scheduler/Console/Parse.hh @@ -196,8 +196,8 @@ #include #include #include -#include "../Utils/safe_bool.hh" -#include "../Utils/Exception.hh" +#include "../../Utils/safe_bool.hh" +#include "../../Utils/Exception.hh" //#include "Parse.mpp" ///////////////////////////////hh.p//////////////////////////////////////// diff --git a/Console/Parse.ih b/Scheduler/Console/Parse.ih similarity index 99% rename from Console/Parse.ih rename to Scheduler/Console/Parse.ih index 70791d4..7816764 100644 --- a/Console/Parse.ih +++ b/Scheduler/Console/Parse.ih @@ -32,7 +32,7 @@ #include #include #include -#include "../Utils/Phoenix.hh" +#include "../../Utils/Phoenix.hh" ///////////////////////////////ih.p//////////////////////////////////////// diff --git a/Console/Parse.test.cc b/Scheduler/Console/Parse.test.cc similarity index 99% rename from Console/Parse.test.cc rename to Scheduler/Console/Parse.test.cc index 3981972..472b9a3 100644 --- a/Console/Parse.test.cc +++ b/Scheduler/Console/Parse.test.cc @@ -33,9 +33,9 @@ #include #include "Parse.hh" #include "Parse.ih" -#include "../Utils/String.hh" +#include "../../Utils/String.hh" -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/ParsedCommand.cc b/Scheduler/Console/ParsedCommand.cc similarity index 100% rename from Console/ParsedCommand.cc rename to Scheduler/Console/ParsedCommand.cc diff --git a/Console/ParsedCommand.cci b/Scheduler/Console/ParsedCommand.cci similarity index 100% rename from Console/ParsedCommand.cci rename to Scheduler/Console/ParsedCommand.cci diff --git a/Console/ParsedCommand.ct b/Scheduler/Console/ParsedCommand.ct similarity index 97% rename from Console/ParsedCommand.ct rename to Scheduler/Console/ParsedCommand.ct index f0469de..b3acb01 100644 --- a/Console/ParsedCommand.ct +++ b/Scheduler/Console/ParsedCommand.ct @@ -34,7 +34,7 @@ // senf::console::ParsedCommandOverload #define BOOST_PP_ITERATION_PARAMS_1 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \ - SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \ + SENF_ABSOLUTE_INCLUDE_PATH(Scheduler/Console/ParsedCommand.mpp), \ 3)) #include BOOST_PP_ITERATE() diff --git a/Console/ParsedCommand.cti b/Scheduler/Console/ParsedCommand.cti similarity index 98% rename from Console/ParsedCommand.cti rename to Scheduler/Console/ParsedCommand.cti index b6d140f..a3f2618 100644 --- a/Console/ParsedCommand.cti +++ b/Scheduler/Console/ParsedCommand.cti @@ -26,9 +26,9 @@ #include "ParsedCommand.ih" // Custom includes -#include "../Utils/membind.hh" +#include "../../Utils/membind.hh" #include -#include "../Utils/parameter.hh" +#include "../../Utils/parameter.hh" #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// @@ -69,7 +69,7 @@ prefix_ void senf::console::ParsedCommandOverloadBase::addParameter() // senf::console::ParsedCommandOverload #define BOOST_PP_ITERATION_PARAMS_1 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \ - SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \ + SENF_ABSOLUTE_INCLUDE_PATH(Scheduler/Console/ParsedCommand.mpp), \ 2)) #include BOOST_PP_ITERATE() @@ -343,7 +343,7 @@ namespace detail { }; # define BOOST_PP_ITERATION_PARAMS_1 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \ - SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \ + SENF_ABSOLUTE_INCLUDE_PATH(Scheduler/Console/ParsedCommand.mpp), \ 4)) # include BOOST_PP_ITERATE() diff --git a/Console/ParsedCommand.hh b/Scheduler/Console/ParsedCommand.hh similarity index 99% rename from Console/ParsedCommand.hh rename to Scheduler/Console/ParsedCommand.hh index db85451..107ed65 100644 --- a/Console/ParsedCommand.hh +++ b/Scheduler/Console/ParsedCommand.hh @@ -37,10 +37,10 @@ #include #include #include -#include "../config.hh" +#include "../../config.hh" #include "OverloadedCommand.hh" #include "Traits.hh" -#include "../Utils/type_traits.hh" +#include "../../Utils/type_traits.hh" #include "ParsedCommand.ih" #include "ParsedCommand.mpp" @@ -183,7 +183,7 @@ namespace console { #ifndef DOXYGEN # define BOOST_PP_ITERATION_PARAMS_1 (4, (0, SENF_CONSOLE_MAX_COMMAND_ARITY, \ - SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \ + SENF_ABSOLUTE_INCLUDE_PATH(Scheduler/Console/ParsedCommand.mpp), \ 1)) # include BOOST_PP_ITERATE() @@ -492,7 +492,7 @@ namespace console { # define BOOST_PP_ITERATION_PARAMS_1 \ (4, (1, BOOST_PARAMETER_MAX_ARITY, \ - SENF_ABSOLUTE_INCLUDE_PATH(Console/ParsedCommand.mpp), \ + SENF_ABSOLUTE_INCLUDE_PATH(Scheduler/Console/ParsedCommand.mpp), \ 5)) # include BOOST_PP_ITERATE() diff --git a/Console/ParsedCommand.ih b/Scheduler/Console/ParsedCommand.ih similarity index 100% rename from Console/ParsedCommand.ih rename to Scheduler/Console/ParsedCommand.ih diff --git a/Console/ParsedCommand.mpp b/Scheduler/Console/ParsedCommand.mpp similarity index 100% rename from Console/ParsedCommand.mpp rename to Scheduler/Console/ParsedCommand.mpp diff --git a/Console/ParsedCommand.test.cc b/Scheduler/Console/ParsedCommand.test.cc similarity index 99% rename from Console/ParsedCommand.test.cc rename to Scheduler/Console/ParsedCommand.test.cc index 223a3e3..0ad7fc6 100644 --- a/Console/ParsedCommand.test.cc +++ b/Scheduler/Console/ParsedCommand.test.cc @@ -34,7 +34,7 @@ #include "Parse.hh" #include "ScopedDirectory.hh" -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/ProgramOptions.cc b/Scheduler/Console/ProgramOptions.cc similarity index 100% rename from Console/ProgramOptions.cc rename to Scheduler/Console/ProgramOptions.cc diff --git a/Console/ProgramOptions.cci b/Scheduler/Console/ProgramOptions.cci similarity index 100% rename from Console/ProgramOptions.cci rename to Scheduler/Console/ProgramOptions.cci diff --git a/Console/ProgramOptions.cti b/Scheduler/Console/ProgramOptions.cti similarity index 100% rename from Console/ProgramOptions.cti rename to Scheduler/Console/ProgramOptions.cti diff --git a/Console/ProgramOptions.hh b/Scheduler/Console/ProgramOptions.hh similarity index 100% rename from Console/ProgramOptions.hh rename to Scheduler/Console/ProgramOptions.hh diff --git a/Console/ProgramOptions.ih b/Scheduler/Console/ProgramOptions.ih similarity index 100% rename from Console/ProgramOptions.ih rename to Scheduler/Console/ProgramOptions.ih diff --git a/Console/ProgramOptions.test.cc b/Scheduler/Console/ProgramOptions.test.cc similarity index 99% rename from Console/ProgramOptions.test.cc rename to Scheduler/Console/ProgramOptions.test.cc index f630141..cf1e12f 100644 --- a/Console/ProgramOptions.test.cc +++ b/Scheduler/Console/ProgramOptions.test.cc @@ -31,7 +31,7 @@ #include "ScopedDirectory.hh" #include "ParsedCommand.hh" -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/Readline.cc b/Scheduler/Console/Readline.cc similarity index 98% rename from Console/Readline.cc rename to Scheduler/Console/Readline.cc index 188bc77..87efd87 100644 --- a/Console/Readline.cc +++ b/Scheduler/Console/Readline.cc @@ -32,7 +32,7 @@ #include #include #include -#include "../Utils/membind.hh" +#include "../../Utils/membind.hh" //#include "Readline.mpp" #define prefix_ @@ -116,7 +116,7 @@ namespace { prefix_ senf::console::detail::ReadlineClientReader::ReadlineClientReader(Client & client) : ClientReader(client), ch_ (-1), skipChars_ (0), - readevent_ ( "ReadlineClientReader", senf::membind(&ReadlineClientReader::charEvent, this), + readevent_ ( "senf::console::detail::ReadlineClientReader", senf::membind(&ReadlineClientReader::charEvent, this), client.handle(), scheduler::FdEvent::EV_READ, false ), terminate_ (false) { diff --git a/Console/Readline.cci b/Scheduler/Console/Readline.cci similarity index 100% rename from Console/Readline.cci rename to Scheduler/Console/Readline.cci diff --git a/Console/Readline.hh b/Scheduler/Console/Readline.hh similarity index 98% rename from Console/Readline.hh rename to Scheduler/Console/Readline.hh index 69ae87d..3daf490 100644 --- a/Console/Readline.hh +++ b/Scheduler/Console/Readline.hh @@ -29,8 +29,8 @@ // Custom includes #include #include "Server.hh" -#include "../Utils/Exception.hh" -#include "../Scheduler/Scheduler.hh" +#include "../../Utils/Exception.hh" +#include "../Scheduler.hh" //#include "Readline.mpp" ///////////////////////////////hh.p//////////////////////////////////////// diff --git a/Scheduler/Console/SConscript b/Scheduler/Console/SConscript new file mode 100644 index 0000000..20e0cab --- /dev/null +++ b/Scheduler/Console/SConscript @@ -0,0 +1,10 @@ +# -*- python -*- + +Import('env') +import SENFSCons + +########################################################################### + +env.Command(env.File('test'), '../test', []) + +SENFSCons.Doxygen(env) diff --git a/Console/ScopedDirectory.cci b/Scheduler/Console/ScopedDirectory.cci similarity index 100% rename from Console/ScopedDirectory.cci rename to Scheduler/Console/ScopedDirectory.cci diff --git a/Console/ScopedDirectory.cti b/Scheduler/Console/ScopedDirectory.cti similarity index 100% rename from Console/ScopedDirectory.cti rename to Scheduler/Console/ScopedDirectory.cti diff --git a/Console/ScopedDirectory.hh b/Scheduler/Console/ScopedDirectory.hh similarity index 98% rename from Console/ScopedDirectory.hh rename to Scheduler/Console/ScopedDirectory.hh index 04a33ec..c0f3bb9 100644 --- a/Console/ScopedDirectory.hh +++ b/Scheduler/Console/ScopedDirectory.hh @@ -30,6 +30,7 @@ #include #include #include "Node.hh" +#include "LazyDirectory.hh" // For ScopedDirectory template default arg //#include "ScopedDirectory.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -131,7 +132,7 @@ namespace console { \ingroup node_tree */ - template + template class ScopedDirectory : public ScopedDirectoryBase { public: @@ -144,7 +145,7 @@ namespace console { ///\name Structors and default members ///@{ - ScopedDirectory(Owner * owner); + explicit ScopedDirectory(Owner * owner); ///@} /////////////////////////////////////////////////////////////////////////// diff --git a/Console/ScopedDirectory.test.cc b/Scheduler/Console/ScopedDirectory.test.cc similarity index 99% rename from Console/ScopedDirectory.test.cc rename to Scheduler/Console/ScopedDirectory.test.cc index 45f70cd..60b665e 100644 --- a/Console/ScopedDirectory.test.cc +++ b/Scheduler/Console/ScopedDirectory.test.cc @@ -31,7 +31,7 @@ #include "ScopedDirectory.hh" #include -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/Server.cc b/Scheduler/Console/Server.cc similarity index 96% rename from Console/Server.cc rename to Scheduler/Console/Server.cc index e69bca1..ef885ba 100644 --- a/Console/Server.cc +++ b/Scheduler/Console/Server.cc @@ -32,9 +32,9 @@ #include #include #include -#include "../Utils/senfassert.hh" -#include "../Utils/membind.hh" -#include "../Utils/Logger/SenfLog.hh" +#include "../../Utils/senfassert.hh" +#include "../../Utils/membind.hh" +#include "../../Utils/Logger/SenfLog.hh" #include "Readline.hh" //#include "Server.mpp" @@ -92,7 +92,7 @@ prefix_ senf::console::Server & senf::console::Server::start(ServerHandle handle prefix_ senf::console::Server::Server(ServerHandle handle) : handle_ (handle), - event_ ("console::Server", senf::membind(&Server::newClient, this), + event_ ("senf::console::Server", senf::membind(&Server::newClient, this), handle_, scheduler::FdEvent::EV_READ), root_ (senf::console::root().thisptr()), mode_ (Automatic) {} @@ -179,7 +179,7 @@ prefix_ void senf::console::detail::DumbClientReader::v_translate(std::string & prefix_ senf::console::detail::NoninteractiveClientReader::NoninteractiveClientReader(Client & client) : ClientReader (client), - readevent_ ("NoninteractiveClientReader", + readevent_ ("senf::console::detail::NoninteractiveClientReader", senf::membind(&NoninteractiveClientReader::newData, this), handle(), senf::scheduler::FdEvent::EV_READ) {} @@ -217,9 +217,10 @@ senf::console::detail::NoninteractiveClientReader::newData(int event) prefix_ senf::console::Client::Client(Server & server, ClientHandle handle) : out_t(boost::ref(*this)), senf::log::IOStreamTarget(out_t::member), server_ (server), handle_ (handle), - readevent_ ("senf::console::Client", boost::bind(&Client::setNoninteractive,this), + readevent_ ("senf::console::Client::interactive_check", + boost::bind(&Client::setNoninteractive,this), handle, scheduler::FdEvent::EV_READ, false), - timer_ ("senf::console::Client interactive timeout", + timer_ ("senf::console::Client::interactive_timer", boost::bind(&Client::setInteractive, this), scheduler::eventTime() + ClockService::milliseconds(INTERACTIVE_TIMEOUT), false), diff --git a/Console/Server.cci b/Scheduler/Console/Server.cci similarity index 100% rename from Console/Server.cci rename to Scheduler/Console/Server.cci diff --git a/Console/Server.hh b/Scheduler/Console/Server.hh similarity index 96% rename from Console/Server.hh rename to Scheduler/Console/Server.hh index 1974a74..ac86ca2 100644 --- a/Console/Server.hh +++ b/Scheduler/Console/Server.hh @@ -31,15 +31,15 @@ #include #include #include -#include "../Utils/intrusive_refcount.hh" -#include "../Socket/Protocols/INet/TCPSocketHandle.hh" -#include "../Socket/ServerSocketHandle.hh" -#include "../Scheduler/Scheduler.hh" -#include "../Scheduler/ReadHelper.hh" +#include "../../Utils/intrusive_refcount.hh" +#include "../../Socket/Protocols/INet/TCPSocketHandle.hh" +#include "../../Socket/ServerSocketHandle.hh" +#include "../Scheduler.hh" +#include "../ReadHelper.hh" #include "Parse.hh" #include "Executor.hh" -#include "../Socket/Protocols/INet/INetAddressing.hh" -#include "../Utils/Logger.hh" +#include "../../Socket/Protocols/INet/INetAddressing.hh" +#include "../../Utils/Logger.hh" //#include "Server.mpp" #include "Server.ih" diff --git a/Console/Server.ih b/Scheduler/Console/Server.ih similarity index 100% rename from Console/Server.ih rename to Scheduler/Console/Server.ih diff --git a/Console/Server.test.cc b/Scheduler/Console/Server.test.cc similarity index 97% rename from Console/Server.test.cc rename to Scheduler/Console/Server.test.cc index 7c54f39..84599f0 100644 --- a/Console/Server.test.cc +++ b/Scheduler/Console/Server.test.cc @@ -29,7 +29,7 @@ // Custom includes #include "Server.hh" -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/OverloadedCommand.cti b/Scheduler/Console/Sysdir.cci similarity index 67% rename from Console/OverloadedCommand.cti rename to Scheduler/Console/Sysdir.cci index b5e7a75..9b97ea9 100644 --- a/Console/OverloadedCommand.cti +++ b/Scheduler/Console/Sysdir.cci @@ -21,28 +21,33 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief OverloadedCommand inline template implementation */ + \brief Sysdir inline non-template implementation */ -//#include "OverloadedCommand.ih" +#include "Sysdir.ih" // Custom includes +#include "ScopedDirectory.hh" #define prefix_ inline -///////////////////////////////cti.p/////////////////////////////////////// +///////////////////////////////cci.p/////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// -// senf::console::OverloadedCommandNode +prefix_ senf::console::ScopedDirectory<> & senf::console::sysdir() +{ + return detail::SysdirManager::instance().sysdir(); +} + +prefix_ senf::console::ScopedDirectory<> & +senf::console::detail::SysdirManager::sysdir() +{ + return sysdir_; +} -template -prefix_ Command & -senf::console::OverloadedCommandNode::add(boost::intrusive_ptr overload) +prefix_ senf::console::detail::SysdirManager::SysdirManager() { - overloads_.push_back(overload); - overload->node_ = this; - return *overload; + senf::console::root().add("sys", sysdir_); } -///////////////////////////////cti.e/////////////////////////////////////// +///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ diff --git a/Console/main.test.cc b/Scheduler/Console/Sysdir.hh similarity index 72% rename from Console/main.test.cc rename to Scheduler/Console/Sysdir.hh index b6d1686..06fb086 100644 --- a/Console/main.test.cc +++ b/Scheduler/Console/Sysdir.hh @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2006 +// Copyright (C) 2008 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund @@ -20,30 +20,38 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline non-template functions +/** \file + \brief Sysdir public header */ -//#include "test.hh" -//#include "test.ih" +#ifndef HH_Sysdir_ +#define HH_Sysdir_ 1 // Custom includes -#define BOOST_AUTO_TEST_MAIN -#include "../Utils/auto_unit_test.hh" -#include +#include "Node.hh" -#define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// +//#include "Sysdir.mpp" +///////////////////////////////hh.p//////////////////////////////////////// +namespace senf { +namespace console { -///////////////////////////////cc.e//////////////////////////////////////// -#undef prefix_ + ScopedDirectory<> & sysdir(); + +}} + +///////////////////////////////hh.e//////////////////////////////////////// +#include "Sysdir.cci" +//#include "Sysdir.ct" +//#include "Sysdir.cti" +#endif // Local Variables: // mode: c++ // fill-column: 100 +// comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" -// comment-column: 40 // End: diff --git a/Console/Node.ih b/Scheduler/Console/Sysdir.ih similarity index 77% rename from Console/Node.ih rename to Scheduler/Console/Sysdir.ih index 1a02bdd..56ab1fc 100644 --- a/Console/Node.ih +++ b/Scheduler/Console/Sysdir.ih @@ -21,10 +21,10 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Node internal header */ + \brief Sysdir internal header */ -#ifndef IH_Node_ -#define IH_Node_ 1 +#ifndef IH_Sysdir_ +#define IH_Sysdir_ 1 // Custom includes @@ -34,26 +34,22 @@ namespace senf { namespace console { namespace detail { -#ifndef DOXYGEN - - class NodeTraverser + class SysdirManager + : public singleton { public: - NodeTraverser(DirectoryNode & root, DirectoryNode & dir, bool autocomplete); + using singleton::instance; + using singleton::alive; - void operator()(std::string const & name); + ScopedDirectory<> & sysdir(); - GenericNode & node(); - private: - DirectoryNode & root_; - DirectoryNode::ptr dir_; - bool autocomplete_; - std::string elt_; - bool init_; - }; + SysdirManager(); -#endif + ScopedDirectory<> sysdir_; + + friend class singleton; + }; }}} diff --git a/Console/Traits.cc b/Scheduler/Console/Traits.cc similarity index 98% copy from Console/Traits.cc copy to Scheduler/Console/Traits.cc index 81acbe7..1f082eb 100644 --- a/Console/Traits.cc +++ b/Scheduler/Console/Traits.cc @@ -27,7 +27,7 @@ #include "Traits.ih" // Custom includes -#include "../Utils/senfassert.hh" +#include "../../Utils/senfassert.hh" //#include "Traits.mpp" #define prefix_ diff --git a/Console/Traits.cci b/Scheduler/Console/Traits.cci similarity index 100% rename from Console/Traits.cci rename to Scheduler/Console/Traits.cci diff --git a/Console/Traits.ct b/Scheduler/Console/Traits.ct similarity index 100% rename from Console/Traits.ct rename to Scheduler/Console/Traits.ct diff --git a/Console/Traits.cti b/Scheduler/Console/Traits.cti similarity index 98% rename from Console/Traits.cti rename to Scheduler/Console/Traits.cti index 4ffa5a7..afaa43b 100644 --- a/Console/Traits.cti +++ b/Scheduler/Console/Traits.cti @@ -28,7 +28,7 @@ // Custom includes #include #include -#include "../Utils/TypeInfo.hh" +#include "../../Utils/TypeInfo.hh" #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// diff --git a/Console/Traits.hh b/Scheduler/Console/Traits.hh similarity index 99% rename from Console/Traits.hh rename to Scheduler/Console/Traits.hh index b647dd4..900b2b1 100644 --- a/Console/Traits.hh +++ b/Scheduler/Console/Traits.hh @@ -29,7 +29,7 @@ // Custom includes #include #include -#include "../Utils/intrusive_refcount.hh" +#include "../../Utils/intrusive_refcount.hh" #include "Parse.hh" #include "Node.hh" diff --git a/Console/Traits.ih b/Scheduler/Console/Traits.ih similarity index 99% rename from Console/Traits.ih rename to Scheduler/Console/Traits.ih index 2e46835..7d97e70 100644 --- a/Console/Traits.ih +++ b/Scheduler/Console/Traits.ih @@ -33,7 +33,7 @@ #include #include #include -#include "../Utils/singleton.hh" +#include "../../Utils/singleton.hh" ///////////////////////////////ih.p//////////////////////////////////////// diff --git a/Console/Traits.test.cc b/Scheduler/Console/Traits.test.cc similarity index 99% rename from Console/Traits.test.cc rename to Scheduler/Console/Traits.test.cc index bc122ea..b8d366b 100644 --- a/Console/Traits.test.cc +++ b/Scheduler/Console/Traits.test.cc @@ -33,7 +33,7 @@ #include "Parse.hh" #include "ScopedDirectory.hh" -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/Variables.cti b/Scheduler/Console/Variables.cti similarity index 100% rename from Console/Variables.cti rename to Scheduler/Console/Variables.cti diff --git a/Console/Variables.hh b/Scheduler/Console/Variables.hh similarity index 100% rename from Console/Variables.hh rename to Scheduler/Console/Variables.hh diff --git a/Console/Variables.ih b/Scheduler/Console/Variables.ih similarity index 100% rename from Console/Variables.ih rename to Scheduler/Console/Variables.ih diff --git a/Console/Variables.test.cc b/Scheduler/Console/Variables.test.cc similarity index 98% rename from Console/Variables.test.cc rename to Scheduler/Console/Variables.test.cc index 502474d..0bcebc7 100644 --- a/Console/Variables.test.cc +++ b/Scheduler/Console/Variables.test.cc @@ -34,7 +34,7 @@ #include "Parse.hh" #include "ScopedDirectory.hh" -#include "../Utils/auto_unit_test.hh" +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ diff --git a/Console/testServer.cc b/Scheduler/Console/testServer.cc similarity index 100% rename from Console/testServer.cc rename to Scheduler/Console/testServer.cc diff --git a/Console/Traits.cc b/Scheduler/EventManager.cc similarity index 52% rename from Console/Traits.cc rename to Scheduler/EventManager.cc index 81acbe7..0743cb6 100644 --- a/Console/Traits.cc +++ b/Scheduler/EventManager.cc @@ -21,40 +21,54 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief Traits non-inline non-template implementation */ + \brief EventManager non-inline non-template implementation */ -#include "Traits.hh" -#include "Traits.ih" +//#include "EventManager.hh" +//#include "EventManager.ih" // Custom includes -#include "../Utils/senfassert.hh" +#include +#include "../Utils/membind.hh" +#include "Console/Console.hh" +#include "FIFORunner.hh" -//#include "Traits.mpp" +//#include "EventManager.mpp" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ long senf::console::detail::parseEnum(EnumTable const & table, - ParseCommandInfo::TokensRange const & tokens) +prefix_ senf::scheduler::detail::EventManager::EventManager() { - if (tokens.size() != 1) - throw SyntaxErrorException("parameter syntax error"); - - EnumTable::left_map::const_iterator i (table.left.find(tokens.begin()[0].value())); - if (i == table.left.end()) - throw SyntaxErrorException("parameter syntax error: invalid enum value"); - return i->second; +#ifndef SENF_DISABLE_CONSOLE + consoleDir_().add("events", senf::membind(&EventManager::consoleEvents, this)); + senf::console::sysdir().add("scheduler", consoleDir_()); +#endif } -prefix_ std::string senf::console::detail::formatEnum(EnumTable const & table, long value) +prefix_ void senf::scheduler::detail::EventManager::consoleEvents(std::ostream & os) { - EnumTable::right_map::const_iterator i (table.right.find(value)); - SENF_ASSERT( i != table.right.end() ); - return i->second; + iterator i (begin()); + iterator const i_end (end()); + // On an 80 column display, this wraps nicely directly before the RUN column + os << boost::format("%-6s %-52s %-10s %-8s %7s %s\n") + % "TYPE" + % "NAME" + % "ADDRESS" + % "ACTIVE?" + % "RUN" + % "INFO"; + for (; i != i_end; ++i) + os << boost::format("%-6.6s %-52.52s 0x%08x %-8.8s %7d %s\n") + % i->type() + % i->name() + % reinterpret_cast(&(*i)) + % (i->enabled() ? "enabled" : "disabled") + % i->runCount() + % i->info(); } ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ -//#include "Traits.mpp" +//#include "EventManager.mpp" // Local Variables: diff --git a/Scheduler/EventManager.cci b/Scheduler/EventManager.cci new file mode 100644 index 0000000..010e8f2 --- /dev/null +++ b/Scheduler/EventManager.cci @@ -0,0 +1,128 @@ +// $Id$ +// +// Copyright (C) 2008 +// 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 +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief EventManager inline non-template implementation */ + +//#include "EventManager.ih" + +// Custom includes + +#define prefix_ inline +///////////////////////////////cci.p/////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// senf::scheduler::detail::Event + +prefix_ senf::scheduler::detail::Event::Event(std::string const & name) + : name_ (name), runCount_ (0u) +{ + EventManager::instance().add(*this); +} + +prefix_ senf::scheduler::detail::Event::~Event() +{ + EventManager::instance().remove(*this); +} + +prefix_ void senf::scheduler::detail::EventManager::add(Event & event) +{ + events_.push_back(event); +} + +prefix_ void senf::scheduler::detail::EventManager::remove(Event & event) +{ + events_.erase(EventList::current(event)); +} + +prefix_ std::string const & senf::scheduler::detail::Event::name() + const +{ + return name_; +} + +prefix_ bool senf::scheduler::detail::Event::enabled() + const +{ + return v_enabled(); +} + +prefix_ unsigned senf::scheduler::detail::Event::runCount() + const +{ + return runCount_; +} + +prefix_ char const * senf::scheduler::detail::Event::type() + const +{ + return v_type(); +} + +prefix_ std::string senf::scheduler::detail::Event::info() + const +{ + return v_info(); +} + +prefix_ void senf::scheduler::detail::Event::countRun() +{ + ++ runCount_; +} + +/////////////////////////////////////////////////////////////////////////// +// senf::scheduler::detail::EventManager + +prefix_ bool senf::scheduler::detail::EventManager::IteratorFilter::operator()(Event const & e) +{ + return e.type() != 0; +} + +prefix_ senf::scheduler::detail::EventManager::iterator +senf::scheduler::detail::EventManager::begin() + const +{ + // We need to filter out elements with e.type() == 0 ... the NullTask temporarily added + // by the FIFORunner is such an element and must be skipped. + return boost::make_filter_iterator(IteratorFilter(), events_.begin(), events_.end()); +} + +prefix_ senf::scheduler::detail::EventManager::iterator +senf::scheduler::detail::EventManager::end() + const +{ + return boost::make_filter_iterator(IteratorFilter(), events_.end(), events_.end()); +} + +///////////////////////////////cci.e/////////////////////////////////////// +#undef prefix_ + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/Scheduler/EventManager.hh b/Scheduler/EventManager.hh new file mode 100644 index 0000000..56a32ae --- /dev/null +++ b/Scheduler/EventManager.hh @@ -0,0 +1,140 @@ +// $Id$ +// +// Copyright (C) 2008 +// 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 +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief EventManager public header */ + +#ifndef HH_SchedulerEventManager_ +#define HH_SchedulerEventManager_ 1 + +// Custom includes +#include +#include +#include "../boost/intrusive/ilist.hpp" +#include "../boost/intrusive/ilist_hook.hpp" +#include "../Utils/singleton.hh" +#include "Console/LazyDirectory.hh" + +//#include "EventManager.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +namespace senf { +namespace scheduler { +namespace detail { + + class Event; + struct EventListTag; + typedef boost::intrusive::ilist_base_hook EventListBase; + typedef boost::intrusive::ilist, false> EventList; + + /** \brief + */ + class Event + : public EventListBase + { + public: + /////////////////////////////////////////////////////////////////////////// + // Types + + /////////////////////////////////////////////////////////////////////////// + ///\name Structors and default members + ///@{ + + explicit Event(std::string const & name); + virtual ~Event(); + + ///@} + /////////////////////////////////////////////////////////////////////////// + + std::string const & name() const; + bool enabled() const; + unsigned runCount() const; + char const * type() const; + std::string info() const; + + protected: + void countRun(); + + private: + virtual bool v_enabled() const = 0; + virtual char const * v_type() const = 0; + virtual std::string v_info() const = 0; + + std::string name_; + unsigned runCount_; + }; + + /** \brief + */ + class EventManager + : public singleton + { + struct IteratorFilter { + bool operator()(Event const & e); + }; + + public: + using singleton::instance; + using singleton::alive; + + typedef boost::filter_iterator iterator; + + void add(Event & event); + void remove(Event & event); + + iterator begin() const; + iterator end() const; + + protected: + + private: + EventManager(); + + EventList events_; + + friend class singleton; + +#ifndef SENF_DISABLE_CONSOLE + void consoleEvents(std::ostream & os); + + console::LazyDirectory consoleDir_; +#endif + }; + +}}} + +///////////////////////////////hh.e//////////////////////////////////////// +#include "EventManager.cci" +//#include "EventManager.ct" +//#include "EventManager.cti" +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/Console/ConfigFile.cc b/Scheduler/EventManager.test.cc similarity index 55% rename from Console/ConfigFile.cc rename to Scheduler/EventManager.test.cc index 45e0eee..806c89c 100644 --- a/Console/ConfigFile.cc +++ b/Scheduler/EventManager.test.cc @@ -21,38 +21,46 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief ConfigFile non-inline non-template implementation */ + \brief EventManager.test unit tests */ -#include "ConfigFile.hh" -#include "ConfigFile.ih" +//#include "EventManager.test.hh" +//#include "EventManager.test.ih" // Custom includes +#include "EventManager.hh" +#include "FdEvent.hh" +#include "TimerEvent.hh" +#include "SignalEvent.hh" + +#include +#include -//#include "ConfigFile.mpp" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////// -// senf::console::detail::ConfigFileSource - -prefix_ void senf::console::detail::ConfigFileSource::v_parse(RestrictedExecutor & executor) +BOOST_AUTO_UNIT_TEST(eventManager) { - parser_.parseFile(filename_, boost::bind( boost::ref(executor), - boost::ref(std::cerr), - _1 )); -} + senf::scheduler::FdEvent fdEvent ("fdEvent", 0); + senf::scheduler::TimerEvent timer ("timer", 0); + senf::scheduler::SignalEvent signal (SIGUSR2, 0, false); -/////////////////////////////////////////////////////////////////////////// + senf::scheduler::detail::EventManager & em (senf::scheduler::detail::EventManager::instance()); -prefix_ void senf::console::parseFile(std::string const & filename, DirectoryNode & root) -{ - ConfigFile cfg (filename, root); - cfg.parse(); + senf::scheduler::detail::EventManager::iterator i (em.begin()); + BOOST_REQUIRE( i != em.end() ); + BOOST_CHECK( &(*i) == static_cast(&fdEvent) ); + ++i; + BOOST_REQUIRE( i != em.end() ); + BOOST_CHECK( &(*i) == static_cast(&timer) ); + ++i; + BOOST_REQUIRE( i != em.end() ); + BOOST_CHECK( &(*i) == static_cast(&signal) ); + ++i; + BOOST_CHECK( i == em.end() ); } ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ -//#include "ConfigFile.mpp" // Local Variables: diff --git a/Scheduler/FIFORunner.cc b/Scheduler/FIFORunner.cc index 2b54eb6..8510c04 100644 --- a/Scheduler/FIFORunner.cc +++ b/Scheduler/FIFORunner.cc @@ -102,7 +102,9 @@ namespace { : public senf::scheduler::detail::FIFORunner::TaskInfo { NullTask() : senf::scheduler::detail::FIFORunner::TaskInfo ("") {} - void run() {}; + virtual void v_run() {}; + virtual char const * v_type() const { return 0; } + virtual std::string v_info() const { return ""; } }; } @@ -133,7 +135,7 @@ prefix_ void senf::scheduler::detail::FIFORunner::run() TaskInfo & task (*next_); if (task.runnable_) { task.runnable_ = false; - runningName_ = task.name_; + runningName_ = task.name(); # ifdef SENF_DEBUG runningBacktrace_ = task.backtrace_; # endif diff --git a/Scheduler/FIFORunner.cci b/Scheduler/FIFORunner.cci index 536865c..fb08059 100644 --- a/Scheduler/FIFORunner.cci +++ b/Scheduler/FIFORunner.cci @@ -35,7 +35,7 @@ ///////////////////////////////cci.p/////////////////////////////////////// prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::TaskInfo(std::string const & name) - : runnable_ (false), name_ (name) + : Event(name), runnable_ (false) {} prefix_ senf::scheduler::detail::FIFORunner::TaskInfo::~TaskInfo() @@ -46,6 +46,18 @@ prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::setRunnable() runnable_ = true; } +prefix_ void senf::scheduler::detail::FIFORunner::TaskInfo::run() +{ + v_run(); + countRun(); +} + +prefix_ bool senf::scheduler::detail::FIFORunner::TaskInfo::v_enabled() + const +{ + return TaskListBase::linked(); +} + prefix_ void senf::scheduler::detail::FIFORunner::enqueue(TaskInfo * task) { tasks_.push_back(*task); diff --git a/Scheduler/FIFORunner.hh b/Scheduler/FIFORunner.hh index a6db0a5..49d62fa 100644 --- a/Scheduler/FIFORunner.hh +++ b/Scheduler/FIFORunner.hh @@ -32,6 +32,7 @@ #include "../boost/intrusive/ilist.hpp" #include "../boost/intrusive/ilist_hook.hpp" #include "../Utils/singleton.hh" +#include "EventManager.hh" //#include "FIFORunner.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -56,26 +57,30 @@ namespace detail { public: class TaskInfo - : public TaskListBase + : public Event, + public TaskListBase { public: explicit TaskInfo(std::string const & name); virtual ~TaskInfo(); + void run(); + protected: void setRunnable(); private: - virtual void run() = 0; + virtual void v_run() = 0; + virtual bool v_enabled() const; bool runnable_; - std::string name_; # ifdef SENF_DEBUG std::string backtrace_; # endif friend class FIFORunner; }; + using singleton::instance; using singleton::alive; @@ -87,11 +92,7 @@ namespace detail { void taskTimeout(unsigned ms); unsigned taskTimeout() const; - unsigned hangCount() const; ///< Number of task expirations - /**< The FIFORunner manages a watchdog which checks, that a - single task does not run continuously for a longer time - or block. If a task runs for more than 1s, a warning is - printed and the hangCount is increased. */ + unsigned hangCount() const; protected: diff --git a/Scheduler/FdEvent.cc b/Scheduler/FdEvent.cc index f6a6396..e3500ca 100644 --- a/Scheduler/FdEvent.cc +++ b/Scheduler/FdEvent.cc @@ -27,6 +27,7 @@ #include "FdEvent.ih" // Custom includes +#include #include "../Utils/senfassert.hh" //#include "FdEvent.mpp" @@ -168,11 +169,34 @@ prefix_ void senf::scheduler::FdEvent::signal(int events) } } -prefix_ void senf::scheduler::FdEvent::run() +prefix_ void senf::scheduler::FdEvent::v_run() { cb_(signaledEvents_); } +prefix_ char const * senf::scheduler::FdEvent::v_type() + const +{ + return "fd"; +} + +prefix_ std::string senf::scheduler::FdEvent::v_info() + const +{ + std::stringstream ss; + + ss << "fd " << fd_; + if (! pollable_) + ss << " (NOT pollable)"; + if (events_ & EV_READ) + ss << " READ"; + if (events_ & EV_PRIO) + ss << " PRIO"; + if (events_ & EV_WRITE) + ss << " WRITE"; + return ss.str(); +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "FdEvent.mpp" diff --git a/Scheduler/FdEvent.hh b/Scheduler/FdEvent.hh index d574351..ff3642d 100644 --- a/Scheduler/FdEvent.hh +++ b/Scheduler/FdEvent.hh @@ -157,7 +157,9 @@ namespace scheduler { private: virtual void signal(int events); - virtual void run(); + virtual void v_run(); + virtual char const * v_type() const; + virtual std::string v_info() const; Callback cb_; int fd_; diff --git a/Scheduler/SConscript b/Scheduler/SConscript index 3b58ec6..f9804fc 100644 --- a/Scheduler/SConscript +++ b/Scheduler/SConscript @@ -5,10 +5,19 @@ import SENFSCons ########################################################################### -sources = SENFSCons.GlobSources() +sources = SENFSCons.GlobSources(subdirs=[ 'Console' ], exclude=[ 'Console/testServer.cc' ]) SENFSCons.StandardTargets(env) + SENFSCons.Lib(env, library = 'Scheduler', sources = sources, - LIBS = [ 'Utils' ]) + LIBS = [ 'Socket', 'Utils' ]) + +SENFSCons.Binary(env, 'Console/testServer', + sources = [ 'Console/testServer.cc' ], + no_includes = True, + LIBS = [ 'Scheduler', 'Socket', 'Utils' ]) + SENFSCons.Doxygen(env) + +SConscript("Console/SConscript") diff --git a/Scheduler/SignalEvent.cc b/Scheduler/SignalEvent.cc index 32c5461..d66d506 100644 --- a/Scheduler/SignalEvent.cc +++ b/Scheduler/SignalEvent.cc @@ -119,6 +119,23 @@ prefix_ void senf::scheduler::detail::SignalDispatcher::sigHandler(int signal, : write(instance().sigPipe_[1], siginfo, sizeof(*siginfo)); } +prefix_ void senf::scheduler::SignalEvent::v_run() +{ + cb_(siginfo_); +} + +prefix_ char const * senf::scheduler::SignalEvent::v_type() + const +{ + return "signal"; +} + +prefix_ std::string senf::scheduler::SignalEvent::v_info() + const +{ + return ""; +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "SignalEvent.mpp" diff --git a/Scheduler/SignalEvent.cci b/Scheduler/SignalEvent.cci index 71b224c..b11e5f1 100644 --- a/Scheduler/SignalEvent.cci +++ b/Scheduler/SignalEvent.cci @@ -93,11 +93,6 @@ prefix_ void senf::scheduler::SignalEvent::action(Callback const & cb) cb_ = cb; } -prefix_ void senf::scheduler::SignalEvent::run() -{ - cb_(siginfo_); -} - ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ diff --git a/Scheduler/SignalEvent.hh b/Scheduler/SignalEvent.hh index bd6540d..cb78b15 100644 --- a/Scheduler/SignalEvent.hh +++ b/Scheduler/SignalEvent.hh @@ -95,7 +95,9 @@ namespace scheduler { void action(Callback const & cb); ///< Change signal event callback private: - virtual void run(); + virtual void v_run(); + virtual char const * v_type() const; + virtual std::string v_info() const; int signal_; Callback cb_; diff --git a/Scheduler/TimerEvent.cc b/Scheduler/TimerEvent.cc index 6e75a3d..572b3c1 100644 --- a/Scheduler/TimerEvent.cc +++ b/Scheduler/TimerEvent.cc @@ -27,6 +27,7 @@ #include "TimerEvent.ih" // Custom includes +#include //#include "TimerEvent.mpp" #define prefix_ @@ -163,12 +164,28 @@ prefix_ void senf::scheduler::detail::TimerDispatcher::reschedule() /////////////////////////////////////////////////////////////////////////// // senf::scheduler::detail::TimerDispatcher::TimerEvent -prefix_ void senf::scheduler::TimerEvent::run() +prefix_ void senf::scheduler::TimerEvent::v_run() { disable(); cb_(); } +prefix_ char const * senf::scheduler::TimerEvent::v_type() + const +{ + return "timer"; +} + +prefix_ std::string senf::scheduler::TimerEvent::v_info() + const +{ + std::stringstream ss; + ss.imbue( std::locale(ss.getloc(), + new boost::posix_time::time_facet("%Y-%m-%d %H:%M:%S.%f-0000")) ); + ss << "expire " << ClockService::abstime(timeout_); + return ss.str(); +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "TimerEvent.mpp" diff --git a/Scheduler/TimerEvent.hh b/Scheduler/TimerEvent.hh index b228890..4c06dfc 100644 --- a/Scheduler/TimerEvent.hh +++ b/Scheduler/TimerEvent.hh @@ -116,7 +116,9 @@ namespace scheduler { enable callback automatically. */ private: - virtual void run(); + virtual void v_run(); + virtual char const * v_type() const; + virtual std::string v_info() const; Callback cb_; ClockService::clock_type timeout_; diff --git a/Socket/SConscript b/Socket/SConscript index 67b1bdc..3177782 100644 --- a/Socket/SConscript +++ b/Socket/SConscript @@ -21,7 +21,7 @@ SENFSCons.Lib(env, library = 'Socket', sources = sources + subob, testSources = testSources, - LIBS = [ 'Scheduler', 'Utils' ]) + LIBS = [ 'Utils' ]) SENFSCons.Doxygen(env, extra_sources = [ env.Dia2Png('SocketLibrary-classes.dia'), diff --git a/Utils/Daemon/Daemon.cc b/Utils/Daemon/Daemon.cc index d6b8d91..2326897 100644 --- a/Utils/Daemon/Daemon.cc +++ b/Utils/Daemon/Daemon.cc @@ -572,7 +572,7 @@ prefix_ senf::detail::DaemonWatcher::DaemonWatcher(int pid, int coutpipe, int ce : childPid_(pid), coutpipe_(coutpipe), cerrpipe_(cerrpipe), stdout_(stdout), stderr_(stderr), sigChld_(false), cldSignal_ (SIGCHLD, senf::membind(&DaemonWatcher::sigChld, this)), - timer_ ("DaemanWatcher watchdog", senf::membind(&DaemonWatcher::childOk, this)), + timer_ ("senf::detail::DaemonWatcher::childOk", senf::membind(&DaemonWatcher::childOk, this)), coutForwarder_(coutpipe_, boost::bind(&DaemonWatcher::pipeClosed, this, 1)), cerrForwarder_(cerrpipe_, boost::bind(&DaemonWatcher::pipeClosed, this, 2)) { @@ -640,7 +640,7 @@ prefix_ void senf::detail::DaemonWatcher::childOk() prefix_ senf::detail::DaemonWatcher::Forwarder::Forwarder(int src, Callback cb) : src_(src), cb_(cb), - readevent_("DaemanWatcher::Forwarder", senf::membind(&Forwarder::readData, this), + readevent_("senf::detail::DaemonWatcher::Forwarder::readevent", senf::membind(&Forwarder::readData, this), src_, scheduler::FdEvent::EV_READ) {} diff --git a/Utils/Daemon/Daemon.cci b/Utils/Daemon/Daemon.cci index 36e0f2f..50c8c6c 100644 --- a/Utils/Daemon/Daemon.cci +++ b/Utils/Daemon/Daemon.cci @@ -33,7 +33,7 @@ prefix_ senf::detail::DaemonWatcher::Forwarder::Target::Target(Forwarder & fwd, int fd_) : fd (fd_), offset (0), - writeevent ("DaemonWatcher::Forwarder::Target", + writeevent ("senf::detail::DaemonWatcher::Forwarder::Target::writeevent", boost::bind(&Forwarder::writeData, &fwd, _1, this), fd, scheduler::FdEvent::EV_WRITE, false) {} diff --git a/Utils/Daemon/SConscript b/Utils/Daemon/SConscript index d7d4586..db6cfbe 100644 --- a/Utils/Daemon/SConscript +++ b/Utils/Daemon/SConscript @@ -12,6 +12,6 @@ sources = SENFSCons.GlobSources() SENFSCons.Lib( env, library = 'Utils_Daemon', sources = sources, - LIBS = [ 'Scheduler', 'Utils' ] ) + LIBS = [ 'Scheduler', 'Socket', 'Utils' ] ) SENFSCons.Doxygen(env) diff --git a/include/senf/Console.hh b/include/senf/Console.hh index 2b11670..38936b1 100644 --- a/include/senf/Console.hh +++ b/include/senf/Console.hh @@ -20,7 +20,7 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#include "Console/Console.hh" +#include "Scheduler/Console/Console.hh" // Local Variables: