From: g0dil Date: Mon, 12 Jan 2009 11:37:37 +0000 (+0000) Subject: PPI: Implement ActiveSplitter routing module X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=7ff3c55db7420433cea0bd7f0fe6c82583f78d4f;hp=a726ae0cb14d0ce37e5aab3c4e07121bbbd3b31c;p=senf.git PPI: Implement ActiveSplitter routing module Utils/Console: Ignore trailing '/' on auto-cd Utils/Console: Add support for STL vector/list arguments and return values Utils/Console: Set default server name from executable name senfscons: Don't build SENF automatically in senfutil git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1056 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/Splitters.cc b/PPI/Splitters.cc new file mode 100644 index 0000000..8e3cce3 --- /dev/null +++ b/PPI/Splitters.cc @@ -0,0 +1,68 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 Splitters non-inline non-template implementation */ + +#include "Splitters.hh" +//#include "Splitters.ih" + +// Custom includes + +//#include "Splitters.mpp" +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +prefix_ senf::ppi::connector::ActiveOutput<> & +senf::ppi::module::ActiveSplitter::newOutput() +{ + outputs_.push_back(new connector::ActiveOutput<>()); + connector::ActiveOutput<> & output (outputs_.back()); + + route(input, output); + + return output; +} + +prefix_ void senf::ppi::module::ActiveSplitter::request() +{ + Packet p (input()); + Outputs::iterator i (outputs_.begin()); + Outputs::iterator const i_end (outputs_.end()); + for (; i != i_end; ++i) + (*i)(p); +} + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ +//#include "Splitters.mpp" + + +// 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/PPI/Splitters.cci b/PPI/Splitters.cci new file mode 100644 index 0000000..7d47333 --- /dev/null +++ b/PPI/Splitters.cci @@ -0,0 +1,54 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 Splitters inline non-template implementation */ + +//#include "Splitters.ih" + +// Custom includes + +#define prefix_ inline +///////////////////////////////cci.p/////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// senf::ppi::module::ActiveSplitter + +prefix_ senf::ppi::module::ActiveSplitter::ActiveSplitter() +{ + noroute(input); + input.onRequest(&ActiveSplitter::request); +} + +///////////////////////////////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/PPI/Splitters.cti b/PPI/Splitters.cti new file mode 100644 index 0000000..d96f3ec --- /dev/null +++ b/PPI/Splitters.cti @@ -0,0 +1,63 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 Splitters inline template implementation */ + +//#include "Splitters.ih" + +// Custom includes +#include "Setup.hh" + +#define prefix_ inline +///////////////////////////////cti.p/////////////////////////////////////// + +template +prefix_ senf::ppi::connector::GenericActiveOutput & +senf::ppi::connect(module::ActiveSplitter & source, Target & target) +{ + return source.connect(target); +} + +template +prefix_ senf::ppi::connector::GenericActiveOutput & +senf::ppi::module::ActiveSplitter::connect(Target & target) +{ + connector::GenericActiveOutput & output (newOutput()); + ppi::connect(output, target); + return output; +} + + +///////////////////////////////cti.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/PPI/Splitters.hh b/PPI/Splitters.hh new file mode 100644 index 0000000..670296c --- /dev/null +++ b/PPI/Splitters.hh @@ -0,0 +1,94 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 Splitters public header */ + +#ifndef HH_SENF_PPI_Splitters_ +#define HH_SENF_PPI_Splitters_ 1 + +// Custom includes +#include +#include "predecl.hh" +#include "Connectors.hh" +#include "Module.hh" + +//#include "Splitters.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +namespace senf { +namespace ppi { + +#ifndef DOXYGEN + + template + connector::GenericActiveOutput & connect(module::ActiveSplitter & source, Target & target); + +#endif + +namespace module { + + class ActiveSplitter + : public Module + { + SENF_PPI_MODULE(ActiveSplitter); + public: + connector::PassiveInput<> input; + + ActiveSplitter(); + + private: + connector::ActiveOutput<> & newOutput(); + +#ifndef DOXYGEN + public: +#endif + template + connector::GenericActiveOutput & connect(Target & target); + + private: + void request(); + + typedef boost::ptr_vector > Outputs; + Outputs outputs_; + }; + +}}} + + + +///////////////////////////////hh.e//////////////////////////////////////// +#include "Splitters.cci" +//#include "Splitters.ct" +#include "Splitters.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/PPI/Splitters.test.cc b/PPI/Splitters.test.cc new file mode 100644 index 0000000..9d55191 --- /dev/null +++ b/PPI/Splitters.test.cc @@ -0,0 +1,79 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 Splitters.test unit tests */ + +//#include "Splitters.test.hh" +//#include "Splitters.test.ih" + +// Custom includes +#include "Splitters.hh" +#include "DebugModules.hh" +#include "Setup.hh" +#include "../Packets/Packets.hh" + +#include "../Utils/auto_unit_test.hh" +#include + +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +namespace ppi = senf::ppi; +namespace connector = ppi::connector; +namespace module = ppi::module; +namespace debug = module::debug; + +BOOST_AUTO_UNIT_TEST(activeSplitter) +{ + debug::ActiveSource source; + module::ActiveSplitter splitter; + debug::PassiveSink sink1; + debug::PassiveSink sink2; + + ppi::connect(source, splitter); + ppi::connect(splitter, sink1); + ppi::connect(splitter, sink2); + ppi::init(); + + senf::Packet p (senf::DataPacket::create()); + + source.submit(p); + BOOST_CHECK_EQUAL( sink1.size(), 1u ); + BOOST_CHECK_EQUAL( sink2.size(), 1u ); + BOOST_CHECK( sink1.pop_front() == p ); + BOOST_CHECK( sink2.pop_front() == p ); +} + +///////////////////////////////cc.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/PPI/predecl.hh b/PPI/predecl.hh index ef6e17b..af96ceb 100644 --- a/PPI/predecl.hh +++ b/PPI/predecl.hh @@ -72,6 +72,7 @@ namespace ppi { } class PassiveJoin; class PriorityJoin; + class ActiveSplitter; } namespace connector { diff --git a/Utils/Console/Console.hh b/Utils/Console/Console.hh index c75f995..6f98d86 100644 --- a/Utils/Console/Console.hh +++ b/Utils/Console/Console.hh @@ -40,6 +40,7 @@ #include "ConfigFile.hh" #include "ProgramOptions.hh" #include "Sysdir.hh" +#include "STLSupport.hh" ///////////////////////////////hh.e//////////////////////////////////////// //#include "Console.cci" diff --git a/Utils/Console/Executor.cc b/Utils/Console/Executor.cc index d6218d8..f78a736 100644 --- a/Utils/Console/Executor.cc +++ b/Utils/Console/Executor.cc @@ -257,7 +257,7 @@ senf::console::Executor::traverseNode(ParseCommandInfo::TokensRange const & path return *dir.back().lock(); } DirectoryNode & base (*dir.back().lock()); - if (tok == WordToken(".")) + if (tok == WordToken(".") || tok == NoneToken()) return base; std::string const & name (complete(base, tok.value())); if (policy_) diff --git a/Utils/Console/ParsedCommand.cti b/Utils/Console/ParsedCommand.cti index c0d42a8..065f14f 100644 --- a/Utils/Console/ParsedCommand.cti +++ b/Utils/Console/ParsedCommand.cti @@ -182,7 +182,7 @@ argInfo(ArgumentPack const & args) return next(); -# undef HaveArg +# undef ProcessArg } template diff --git a/Utils/Console/ParsedCommand.hh b/Utils/Console/ParsedCommand.hh index 4d6cc0c..67b8daa 100644 --- a/Utils/Console/ParsedCommand.hh +++ b/Utils/Console/ParsedCommand.hh @@ -492,7 +492,7 @@ namespace console { # define BOOST_PP_ITERATION_PARAMS_1 \ (4, (1, BOOST_PARAMETER_MAX_ARITY, \ - SENF_ABSOLUTE_INCLUDE_PATH(Utils/Console/ParsedCommand.mpp), \ + SENF_ABSOLUTE_INCLUDE_PATH(Utils/Console/ParsedCommand.mpp), \ 5)) # include BOOST_PP_ITERATE() diff --git a/Utils/Console/STLSupport.ct b/Utils/Console/STLSupport.ct new file mode 100644 index 0000000..ca7f599 --- /dev/null +++ b/Utils/Console/STLSupport.ct @@ -0,0 +1,99 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 VectorSupport non-inline template implementation */ + +//#include "VectorSupport.ih" + +// Custom includes + +#define prefix_ +///////////////////////////////ct.p//////////////////////////////////////// + +#ifndef DOXYGEN + +template +prefix_ void senf::console::SequenceArgumentTraits:: +parse(ParseCommandInfo::TokensRange const & tokens, type & out) +{ + out.clear(); + CheckedArgumentIteratorWrapper arg (tokens); + while (arg) { + out.push_back(typename Sequence::value_type()); + senf::console::parse( *(arg++), out.back() ); + } +} + +template +prefix_ std::string senf::console::SequenceArgumentTraits::description() +{ + std::string type (prettyName(typeid(Sequence))); + std::string::size_type e (type.find('<')); + if (e == std::string::npos) e = type.size(); + std::string::size_type b (type.rfind(':', e)); + if (b == std::string::npos) b = 0; else ++b; + return type.substr(b,e-b) + "<" + + ArgumentTraits::description() + ">"; +} + +template +prefix_ std::string senf::console::SequenceArgumentTraits::str(type const & value) +{ + std::stringstream ss; + senf::console::format(value, ss); + return ss.str(); +} + +template +prefix_ void senf::console::SequenceReturnValueTraits::format(type const & value, + std::ostream & os) +{ + os << "("; + typename type::const_iterator i (value.begin()); + typename type::const_iterator const i_end (value.end()); + if (i != i_end) + for (;;) { + senf::console::format(*i, os); + if (++i == i_end) + break; + else + os << " "; + } + os << ")"; +} + +#endif + +///////////////////////////////ct.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/Utils/Console/STLSupport.hh b/Utils/Console/STLSupport.hh new file mode 100644 index 0000000..6879483 --- /dev/null +++ b/Utils/Console/STLSupport.hh @@ -0,0 +1,99 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 STLSupport public header */ + +#ifndef HH_SENF_Utils_Console_STLSupport_ +#define HH_SENF_Utils_Console_STLSupport_ 1 + +// Custom includes +#include +#include +#include "Traits.hh" + +//#include "STLSupport.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +namespace senf { +namespace console { + +#ifndef DOXYGEN + + template + struct SequenceArgumentTraits + { + typedef Sequence type; + + static void parse(ParseCommandInfo::TokensRange const & tokens, type & out); + static std::string description(); + static std::string str(type const & value); + }; + + template + struct SequenceReturnValueTraits + { + typedef Sequence type; + + static void format(type const & value, std::ostream & os); + }; + + template + struct ArgumentTraits< std::vector > + : public SequenceArgumentTraits< std::vector > + {}; + + template + struct ReturnValueTraits< std::vector > + : public SequenceReturnValueTraits< std::vector > + {}; + + template + struct ArgumentTraits< std::list > + : public SequenceArgumentTraits< std::list > + {}; + + template + struct ReturnValueTraits< std::list > + : public SequenceReturnValueTraits< std::list > + {}; + +#endif + +}} + +///////////////////////////////hh.e//////////////////////////////////////// +//#include "STLSupport.cci" +#include "STLSupport.ct" +//#include "STLSupport.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/Utils/Console/STLSupport.test.cc b/Utils/Console/STLSupport.test.cc new file mode 100644 index 0000000..8b3dcf0 --- /dev/null +++ b/Utils/Console/STLSupport.test.cc @@ -0,0 +1,137 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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 STLSupport.test unit tests */ + +//#include "STLSupport.test.hh" +//#include "STLSupport.test.ih" + +// Custom includes +#include +#include "STLSupport.hh" +#include "ParsedCommand.hh" +#include "Executor.hh" +#include "Parse.hh" +#include "ScopedDirectory.hh" + +#include "../../Utils/auto_unit_test.hh" +#include + +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +namespace { + + int vectorTest(std::vector const & data) + { + int sum (0); + for (std::vector::const_iterator i (data.begin()); i != data.end(); ++i) + sum += *i; + return sum; + } + + int listTest(std::list const & data) + { + int sum (0); + for (std::list::const_iterator i (data.begin()); i != data.end(); ++i) + sum += *i; + return sum; + } + +} + +BOOST_AUTO_UNIT_TEST(vectorSupport) +{ + senf::console::Executor executor; + senf::console::CommandParser parser; + senf::console::ScopedDirectory<> dir; + senf::console::root().add("test", dir); + + std::vector defv (boost::assign::list_of(7)(2).to_container(defv)); + dir.add("test", &vectorTest) + .arg("data", "test data", senf::console::kw::default_value = defv); + std::stringstream ss; + + BOOST_CHECK_NO_THROW( + parser.parse("test/test; test/test (); test/test 5; test/test (13); test/test (4 5 8)", + boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); + BOOST_CHECK_EQUAL( ss.str(), "9\n" "0\n" "5\n" "13\n" "17\n" ); + + ss.str(""); + BOOST_CHECK_NO_THROW( + parser.parse("help test/test", + boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); + BOOST_CHECK_EQUAL( + ss.str(), + "Usage:\n" + " test [data:vector]\n" + "\n" + "With:\n" + " data test data\n" + " default: (7 2)\n" ); +} + +BOOST_AUTO_UNIT_TEST(listSupport) +{ + senf::console::Executor executor; + senf::console::CommandParser parser; + senf::console::ScopedDirectory<> dir; + senf::console::root().add("test", dir); + + std::list defv (boost::assign::list_of(7)(2).to_container(defv)); + dir.add("test", &listTest) + .arg("data", "test data", senf::console::kw::default_value = defv); + std::stringstream ss; + + BOOST_CHECK_NO_THROW( + parser.parse("test/test; test/test (); test/test 5; test/test (13); test/test (4 5 8)", + boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); + BOOST_CHECK_EQUAL( ss.str(), "9\n" "0\n" "5\n" "13\n" "17\n" ); + + ss.str(""); + BOOST_CHECK_NO_THROW( + parser.parse("help test/test", + boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); + BOOST_CHECK_EQUAL( + ss.str(), + "Usage:\n" + " test [data:list]\n" + "\n" + "With:\n" + " data test data\n" + " default: (7 2)\n" ); +} + +///////////////////////////////cc.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/Utils/Console/Server.cc b/Utils/Console/Server.cc index b3bf694..cbc8aca 100644 --- a/Utils/Console/Server.cc +++ b/Utils/Console/Server.cc @@ -27,6 +27,7 @@ #include "Server.ih" // Custom includes +#include #include #include #include @@ -93,7 +94,8 @@ prefix_ senf::console::Server::Server(ServerHandle handle) : handle_ (handle), event_ ("senf::console::Server", senf::membind(&Server::newClient, this), handle_, scheduler::FdEvent::EV_READ), - root_ (senf::console::root().thisptr()), mode_ (Automatic) + root_ (senf::console::root().thisptr()), mode_ (Automatic), + name_ (::program_invocation_short_name) {} prefix_ void senf::console::Server::newClient(int event) diff --git a/Utils/Console/Traits.cti b/Utils/Console/Traits.cti index afaa43b..db9163f 100644 --- a/Utils/Console/Traits.cti +++ b/Utils/Console/Traits.cti @@ -66,6 +66,12 @@ prefix_ void senf::console::parse(ParseCommandInfo::TokensRange const & tokens, } template +prefix_ void senf::console::format(Type const & value, std::ostream & os) +{ + ReturnValueTraits::format(value, os); +} + +template prefix_ std::string senf::console::ArgumentTraits::description() { std::string type (prettyName(typeid(Type))); @@ -77,7 +83,7 @@ template prefix_ std::string senf::console::ArgumentTraits::str(Type const & value) { std::stringstream ss; - senf::console::ReturnValueTraits::format(value, ss); + senf::console::format(value, ss); return ss.str(); } diff --git a/Utils/Console/Traits.hh b/Utils/Console/Traits.hh index d479f45..f7fa1e4 100644 --- a/Utils/Console/Traits.hh +++ b/Utils/Console/Traits.hh @@ -133,6 +133,9 @@ namespace console { template void parse(ParseCommandInfo::TokensRange const & tokens, Type & out); + template + void format(Type const & value, std::ostream & os); + #ifndef DOXYGEN // Parse bool: true/false, yes/no, enabled/disabled, 0/1 diff --git a/Utils/Termlib/Editor.hh b/Utils/Termlib/Editor.hh index 8646d4a..a2221b8 100644 --- a/Utils/Termlib/Editor.hh +++ b/Utils/Termlib/Editor.hh @@ -218,13 +218,6 @@ namespace term { /////////////////////////////////////////////////////////////////////////// - void prompt(std::string const & text); ///< Set prompt string - void set(std::string const & text, unsigned pos = 0u); - ///< Set edit buffer contents - /**< The edit buffer contents will be replaced by \a - text. The cursor will be placed at position \a pos - within this text. */ - ///\name Overall edit control ///\{ @@ -234,6 +227,7 @@ namespace term { void clear(); ///< Clear editor buffer void redisplay(); ///< Mark the editor buffer for redisplay void forceRedisplay(); ///< Redisplay the editor buffer \e now + void prompt(std::string const & text); ///< Set prompt string ///\} @@ -251,6 +245,11 @@ namespace term { void deleteChar(unsigned n=1); ///< Delete \a n characters at point void insert(char ch); ///< Insert \a ch at point void insert(std::string const & text); ///< Insert \a text at point + void set(std::string const & text, unsigned pos = 0u); + ///< Set edit buffer contents + /**< The edit buffer contents will be replaced by \a + text. The cursor will be placed at position \a pos + within this text. */ ///\} diff --git a/senfscons/senfutil.py b/senfscons/senfutil.py index 9560dd5..69f18e0 100644 --- a/senfscons/senfutil.py +++ b/senfscons/senfutil.py @@ -62,8 +62,8 @@ def SetupForSENF(env): '${profile and "profile=1" or None}' ], CPPDEFINES = [ '${not(final) and "SENF_DEBUG" or None}' ] ) - env.Default( - env.AlwaysBuild( - env.Command('senf/libsenf.a', [], [ 'scons -C %s $SENF_BUILDOPTS libsenf.a' % os.path.realpath('senf')]))) + #env.Default( + # env.AlwaysBuild( + # env.Command('senf/libsenf.a', [], [ 'scons -C %s $SENF_BUILDOPTS libsenf.a' % os.path.realpath('senf')]))) else: print '\nUsing global SENF\n'