+++ /dev/null
-# -*- 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)
// 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///////////////////////////////////////
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///////////////////////////////////////
#include "Config.ih"
// Custom includes
-#include "../Utils/membind.hh"
+#include "../../Utils/membind.hh"
//#include "Config.mpp"
#define prefix_
#include "Config.ih"
// Custom includes
-#include "../Utils/membind.hh"
+#include "../../Utils/membind.hh"
#define prefix_ inline
///////////////////////////////cci.p///////////////////////////////////////
#include <boost/utility.hpp>
#include <boost/intrusive_ptr.hpp>
#include "Executor.hh"
-#include "../Utils/intrusive_refcount.hh"
+#include "../../Utils/intrusive_refcount.hh"
///////////////////////////////ih.p////////////////////////////////////////
#include "ProgramOptions.hh"
#include <boost/filesystem/operations.hpp>
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
#include "ParsedCommand.hh"
#include <boost/filesystem/operations.hpp>
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
#include "Config.hh"
#include "ConfigFile.hh"
#include "ProgramOptions.hh"
+#include "Sysdir.hh"
///////////////////////////////hh.e////////////////////////////////////////
//#include "Console.cci"
#include <boost/utility.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/bind.hpp>
-#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_
// Custom includes
#include <boost/utility.hpp>
#include "Parse.hh"
-#include "../Utils/Logger/SenfLog.hh"
+#include "../../Utils/Logger/SenfLog.hh"
#include "Node.hh"
//#include "Executor.mpp"
#include <vector>
#include "Executor.hh"
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
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" );
}
{
// 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 <boost/test/test_tools.hpp>
+#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"
\f
// Local Variables:
// 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 <boost/utility.hpp>
+#include <boost/scoped_ptr.hpp>
-//#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 Owner=void> 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
\f
#include "Node.ih"
// Custom includes
-#include "../Utils/senfassert.hh"
+#include "../../Utils/senfassert.hh"
#define prefix_ inline
///////////////////////////////cci.p///////////////////////////////////////
#include <boost/range/iterator_range.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/type_traits/remove_reference.hpp>
-#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"
#include "Node.hh"
#include <boost/iterator/transform_iterator.hpp>
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
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<std::string const &>()),
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)
// Custom includes
#include "Node.hh"
#include <boost/intrusive_ptr.hpp>
-#include "../Utils/intrusive_refcount.hh"
+#include "../../Utils/intrusive_refcount.hh"
//#include "OverloadedCommand.mpp"
///////////////////////////////hh.p////////////////////////////////////////
#include <sstream>
#include "OverloadedCommand.hh"
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
#include <boost/iterator/transform_iterator.hpp>
#include <boost/spirit/iterator/file_iterator.hpp>
#include <boost/spirit/iterator/position_iterator.hpp>
-#include "../Utils/Exception.hh"
-#include "../Utils/senfassert.hh"
+#include "../../Utils/Exception.hh"
+#include "../../Utils/senfassert.hh"
//#include "Parse.mpp"
#define prefix_
// (disabled) #include "Parse.ih"
// Custom includes
-#include "../Utils/senfassert.hh"
+#include "../../Utils/senfassert.hh"
#define prefix_ inline
///////////////////////////////cci.p///////////////////////////////////////
#include <boost/range/iterator_range.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/function.hpp>
-#include "../Utils/safe_bool.hh"
-#include "../Utils/Exception.hh"
+#include "../../Utils/safe_bool.hh"
+#include "../../Utils/Exception.hh"
//#include "Parse.mpp"
///////////////////////////////hh.p////////////////////////////////////////
#include <boost/spirit/utility/grammar_def.hpp>
#include <boost/spirit/dynamic.hpp>
#include <boost/spirit/phoenix.hpp>
-#include "../Utils/Phoenix.hh"
+#include "../../Utils/Phoenix.hh"
///////////////////////////////ih.p////////////////////////////////////////
#include <sstream>
#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 <boost/test/test_tools.hpp>
#define prefix_
// senf::console::ParsedCommandOverload<FunctionTraits,n>
#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()
#include "ParsedCommand.ih"
// Custom includes
-#include "../Utils/membind.hh"
+#include "../../Utils/membind.hh"
#include <boost/format.hpp>
-#include "../Utils/parameter.hh"
+#include "../../Utils/parameter.hh"
#define prefix_ inline
///////////////////////////////cti.p///////////////////////////////////////
// senf::console::ParsedCommandOverload<FunctionTraits,n>
#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()
};
# 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()
#include <boost/utility.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/parameter/parameters.hpp>
-#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"
#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()
# 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()
#include "Parse.hh"
#include "ScopedDirectory.hh"
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
#include "ScopedDirectory.hh"
#include "ParsedCommand.hh"
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
#include <readline/history.h>
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/replace.hpp>
-#include "../Utils/membind.hh"
+#include "../../Utils/membind.hh"
//#include "Readline.mpp"
#define prefix_
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)
{
// Custom includes
#include <boost/scoped_ptr.hpp>
#include "Server.hh"
-#include "../Utils/Exception.hh"
-#include "../Scheduler/Scheduler.hh"
+#include "../../Utils/Exception.hh"
+#include "../Scheduler.hh"
//#include "Readline.mpp"
///////////////////////////////hh.p////////////////////////////////////////
--- /dev/null
+# -*- python -*-
+
+Import('env')
+import SENFSCons
+
+###########################################################################
+
+env.Command(env.File('test'), '../test', [])
+
+SENFSCons.Doxygen(env)
#include <boost/utility.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include "Node.hh"
+#include "LazyDirectory.hh" // For ScopedDirectory template default arg
//#include "ScopedDirectory.mpp"
///////////////////////////////hh.p////////////////////////////////////////
\ingroup node_tree
*/
- template <class Owner=void>
+ template <class Owner>
class ScopedDirectory : public ScopedDirectoryBase
{
public:
///\name Structors and default members
///@{
- ScopedDirectory(Owner * owner);
+ explicit ScopedDirectory(Owner * owner);
///@}
///////////////////////////////////////////////////////////////////////////
#include "ScopedDirectory.hh"
#include <boost/iterator/transform_iterator.hpp>
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/bind.hpp>
-#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"
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)
{}
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)
{}
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),
#include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
-#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"
// Custom includes
#include "Server.hh"
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
// 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 <class Command>
-prefix_ Command &
-senf::console::OverloadedCommandNode::add(boost::intrusive_ptr<Command> 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_
\f
// $Id$
//
-// Copyright (C) 2006
+// Copyright (C) 2008
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
// 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 <boost/test/test_tools.hpp>
+#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
\f
// 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:
// 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
namespace console {
namespace detail {
-#ifndef DOXYGEN
-
- class NodeTraverser
+ class SysdirManager
+ : public singleton<SysdirManager>
{
public:
- NodeTraverser(DirectoryNode & root, DirectoryNode & dir, bool autocomplete);
+ using singleton<SysdirManager>::instance;
+ using singleton<SysdirManager>::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<SysdirManager>;
+ };
}}}
#include "Traits.ih"
// Custom includes
-#include "../Utils/senfassert.hh"
+#include "../../Utils/senfassert.hh"
//#include "Traits.mpp"
#define prefix_
// Custom includes
#include <sstream>
#include <boost/lexical_cast.hpp>
-#include "../Utils/TypeInfo.hh"
+#include "../../Utils/TypeInfo.hh"
#define prefix_ inline
///////////////////////////////cti.p///////////////////////////////////////
// Custom includes
#include <iostream>
#include <boost/intrusive_ptr.hpp>
-#include "../Utils/intrusive_refcount.hh"
+#include "../../Utils/intrusive_refcount.hh"
#include "Parse.hh"
#include "Node.hh"
#include <boost/preprocessor/facilities/empty.hpp>
#include <boost/bimap.hpp>
#include <boost/assign/list_inserter.hpp>
-#include "../Utils/singleton.hh"
+#include "../../Utils/singleton.hh"
///////////////////////////////ih.p////////////////////////////////////////
#include "Parse.hh"
#include "ScopedDirectory.hh"
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
#include "Parse.hh"
#include "ScopedDirectory.hh"
-#include "../Utils/auto_unit_test.hh"
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#define prefix_
// 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 <boost/format.hpp>
+#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<unsigned long>(&(*i))
+ % (i->enabled() ? "enabled" : "disabled")
+ % i->runCount()
+ % i->info();
}
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
-//#include "Traits.mpp"
+//#include "EventManager.mpp"
\f
// Local Variables:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// 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_
+
+\f
+// 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:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// 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 <string>
+#include <boost/iterator/filter_iterator.hpp>
+#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<EventListTag> EventListBase;
+ typedef boost::intrusive::ilist<EventListBase::value_traits<Event>, 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<EventManager>
+ {
+ struct IteratorFilter {
+ bool operator()(Event const & e);
+ };
+
+ public:
+ using singleton<EventManager>::instance;
+ using singleton<EventManager>::alive;
+
+ typedef boost::filter_iterator<IteratorFilter, EventList::const_iterator> iterator;
+
+ void add(Event & event);
+ void remove(Event & event);
+
+ iterator begin() const;
+ iterator end() const;
+
+ protected:
+
+ private:
+ EventManager();
+
+ EventList events_;
+
+ friend class singleton<EventManager>;
+
+#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
+
+\f
+// 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:
// 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 <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
-//#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<senf::scheduler::detail::Event*>(&fdEvent) );
+ ++i;
+ BOOST_REQUIRE( i != em.end() );
+ BOOST_CHECK( &(*i) == static_cast<senf::scheduler::detail::Event*>(&timer) );
+ ++i;
+ BOOST_REQUIRE( i != em.end() );
+ BOOST_CHECK( &(*i) == static_cast<senf::scheduler::detail::Event*>(&signal) );
+ ++i;
+ BOOST_CHECK( i == em.end() );
}
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
-//#include "ConfigFile.mpp"
\f
// Local Variables:
: public senf::scheduler::detail::FIFORunner::TaskInfo
{
NullTask() : senf::scheduler::detail::FIFORunner::TaskInfo ("<null>") {}
- void run() {};
+ virtual void v_run() {};
+ virtual char const * v_type() const { return 0; }
+ virtual std::string v_info() const { return ""; }
};
}
TaskInfo & task (*next_);
if (task.runnable_) {
task.runnable_ = false;
- runningName_ = task.name_;
+ runningName_ = task.name();
# ifdef SENF_DEBUG
runningBacktrace_ = task.backtrace_;
# endif
///////////////////////////////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()
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);
#include "../boost/intrusive/ilist.hpp"
#include "../boost/intrusive/ilist_hook.hpp"
#include "../Utils/singleton.hh"
+#include "EventManager.hh"
//#include "FIFORunner.mpp"
///////////////////////////////hh.p////////////////////////////////////////
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<FIFORunner>::instance;
using singleton<FIFORunner>::alive;
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:
#include "FdEvent.ih"
// Custom includes
+#include <sstream>
#include "../Utils/senfassert.hh"
//#include "FdEvent.mpp"
}
}
-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"
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_;
###########################################################################
-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")
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"
cb_ = cb;
}
-prefix_ void senf::scheduler::SignalEvent::run()
-{
- cb_(siginfo_);
-}
-
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
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_;
#include "TimerEvent.ih"
// Custom includes
+#include <sstream>
//#include "TimerEvent.mpp"
#define prefix_
///////////////////////////////////////////////////////////////////////////
// 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"
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_;
library = 'Socket',
sources = sources + subob,
testSources = testSources,
- LIBS = [ 'Scheduler', 'Utils' ])
+ LIBS = [ 'Utils' ])
SENFSCons.Doxygen(env, extra_sources = [
env.Dia2Png('SocketLibrary-classes.dia'),
: 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))
{
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)
{}
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)
{}
SENFSCons.Lib( env,
library = 'Utils_Daemon',
sources = sources,
- LIBS = [ 'Scheduler', 'Utils' ] )
+ LIBS = [ 'Scheduler', 'Socket', 'Utils' ] )
SENFSCons.Doxygen(env)
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#include "Console/Console.hh"
+#include "Scheduler/Console/Console.hh"
\f
// Local Variables: