From: g0dil Date: Mon, 1 Feb 2010 17:49:39 +0000 (+0000) Subject: Utils/Console: Convert BoundCommand to additional Command overload X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=21be434729b552e31b856b2f42fc978062d0dd55;p=senf.git Utils/Console: Convert BoundCommand to additional Command overload git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1559 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Socket/Protocols/DVB/DVBProtocolWrapper.cc b/senf/Socket/Protocols/DVB/DVBProtocolWrapper.cc index 42dd6b5..733c94d 100644 --- a/senf/Socket/Protocols/DVB/DVBProtocolWrapper.cc +++ b/senf/Socket/Protocols/DVB/DVBProtocolWrapper.cc @@ -36,18 +36,18 @@ prefix_ senf::DVBSectionProtocolWrapper::DVBSectionProtocolWrapper(senf::DVBDemu namespace kw = senf::console::kw; namespace fty = senf::console::factory; - dir.add("buffersize", fty::BoundCommand(this, &DVBSectionProtocolWrapper::setBufferSize) + dir.add("buffersize", fty::Command(this, &DVBSectionProtocolWrapper::setBufferSize) .doc("Set the size of the circular buffer used for filtered data.") .arg("size", "in byte") ); - dir.add("start", fty::BoundCommand(this,&DVBSectionProtocolWrapper::startFiltering) + dir.add("start", fty::Command(this,&DVBSectionProtocolWrapper::startFiltering) .doc("Starts filtering") ); - dir.add("stop", fty::BoundCommand(this, &DVBSectionProtocolWrapper::setBufferSize) + dir.add("stop", fty::Command(this, &DVBSectionProtocolWrapper::setBufferSize) .doc("Stops filtering") ); dir.add("filter", - fty::BoundCommand, unsigned, @@ -72,7 +72,7 @@ prefix_ senf::DVBSectionProtocolWrapper::DVBSectionProtocolWrapper(senf::DVBDemu kw::default_doc = "0x00") .doc("Sets parameters for section filter.") ); - dir.add("stop", fty::BoundCommand(this, &DVBSectionProtocolWrapper::setBufferSize) + dir.add("stop", fty::Command(this, &DVBSectionProtocolWrapper::setBufferSize) .doc("Stops filtering") ); } @@ -84,7 +84,7 @@ prefix_ senf::DVBPESProtocolWrapper::DVBPESProtocolWrapper(senf::DVBDemuxPESHand namespace fty = senf::console::factory; dir.add("filter", - fty::BoundCommand shortdoc_; }; -namespace factory { - - SimpleOverloadAttributor Command(SimpleCommandOverload::Function fn); - -}}} +}} ///////////////////////////////hh.e//////////////////////////////////////// #include "OverloadedCommand.cci" diff --git a/senf/Utils/Console/ParsedCommand.cti b/senf/Utils/Console/ParsedCommand.cti index 43a2cff..b7c7cfc 100644 --- a/senf/Utils/Console/ParsedCommand.cti +++ b/senf/Utils/Console/ParsedCommand.cti @@ -361,9 +361,50 @@ namespace detail { }}} +/////////////////////////////////////////////////////////////////////////// + +template +prefix_ senf::console::SimpleOverloadAttributor +senf::console::factory:: +Command(boost::function fn, + typename boost::enable_if_c::is_simple>::type *) +{ + return SimpleOverloadAttributor(fn); +} + +template +prefix_ senf::console::SimpleOverloadAttributor +senf::console::factory:: +Command(Function fn, + typename boost::enable_if_c::is_simple>::type *) +{ + return SimpleOverloadAttributor(fn); +} + +template +prefix_ senf::console::SimpleOverloadAttributor +senf::console::factory:: +Command(Owner * owner, Member memfn, + typename boost::enable_if >::type *, + typename boost::enable_if_c::is_simple>::type *) +{ + return SimpleOverloadAttributor(senf::membind(memfn,owner)); +} + +template +prefix_ senf::console::SimpleOverloadAttributor +senf::console::factory:: +Command(Owner const * owner, Member memfn, + typename boost::enable_if >::type *, + typename boost::enable_if_c::is_simple>::type *) +{ + return SimpleOverloadAttributor(senf::membind(memfn,owner)); +} + template prefix_ typename senf::console::detail::ParsedCommandTraits::Attributor -senf::console::factory::Command(boost::function fn) +senf::console::factory:: +Command(boost::function fn) { return detail::addOverloadedCommandNode(fn); } @@ -372,14 +413,16 @@ template prefix_ typename senf::console::detail::ParsedCommandTraits::Attributor senf::console::factory:: Command(Function fn, - typename boost::enable_if_c::is_callable>::type *) + typename boost::enable_if_c::is_callable>::type *, + typename boost::disable_if >::type *) { return detail::addOverloadedCommandNode(fn); } template prefix_ typename senf::console::detail::ParsedCommandTraits::Attributor -senf::console::factory::Command(boost::function fn) +senf::console::factory:: +Command(boost::function fn) { return detail::addOverloadedCommandNode(fn); } @@ -388,35 +431,44 @@ template prefix_ typename senf::console::detail::ParsedCommandTraits::Attributor senf::console::factory:: Command(Function fn, - typename boost::enable_if_c::is_callable>::type *) + typename boost::enable_if_c::is_callable>::type *, + typename boost::disable_if >::type *) { return detail::addOverloadedCommandNode(fn); } template prefix_ typename senf::console::detail::ParsedCommandTraits::Attributor -senf::console::factory::BoundCommand(Owner * owner, Member memfn) +senf::console::factory:: +Command(Owner * owner, Member memfn, + typename boost::enable_if >::type *) { return detail::addOverloadedCommandNode(senf::membind(memfn,owner)); } template prefix_ typename senf::console::detail::ParsedCommandTraits::Attributor -senf::console::factory::BoundCommand(Owner const * owner, Member memfn) +senf::console::factory:: +Command(Owner const * owner, Member memfn, + typename boost::enable_if >::type *) { return detail::addOverloadedCommandNode(senf::membind(memfn,owner)); } template prefix_ typename senf::console::detail::ParsedCommandTraits::Attributor -senf::console::factory::BoundCommand(Owner * owner, Member memfn) +senf::console::factory:: +Command(Owner * owner, Member memfn, + typename boost::enable_if >::type *) { return detail::addOverloadedCommandNode(senf::membind(memfn,owner)); } template prefix_ typename senf::console::detail::ParsedCommandTraits::Attributor -senf::console::factory::BoundCommand(Owner const * owner, Member memfn) +senf::console::factory:: +Command(Owner const * owner, Member memfn, + typename boost::enable_if >::type *) { return detail::addOverloadedCommandNode(senf::membind(memfn,owner)); } diff --git a/senf/Utils/Console/ParsedCommand.hh b/senf/Utils/Console/ParsedCommand.hh index ce9cad5..0e96d8f 100644 --- a/senf/Utils/Console/ParsedCommand.hh +++ b/senf/Utils/Console/ParsedCommand.hh @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include #include @@ -572,6 +572,28 @@ namespace console { namespace factory { + template + SimpleOverloadAttributor + Command(boost::function fn, + typename boost::enable_if_c::is_simple>::type * = 0); + + template + SimpleOverloadAttributor + Command(Function fn, + typename boost::enable_if_c::is_simple>::type * = 0); + + template + SimpleOverloadAttributor + Command(Owner * owner, Member memfn, + typename boost::enable_if >::type * = 0, + typename boost::enable_if_c::is_simple>::type * = 0); + + template + SimpleOverloadAttributor + Command(Owner const * owner, Member memfn, + typename boost::enable_if >::type * = 0, + typename boost::enable_if_c::is_simple>::type * = 0); + template typename senf::console::detail::ParsedCommandTraits::Attributor Command(boost::function fn); @@ -579,8 +601,9 @@ namespace factory { template typename senf::console::detail::ParsedCommandTraits::Attributor Command(Function fn, - typename boost::enable_if_c::is_callable>::type * = 0); - + typename boost::enable_if_c::is_callable>::type * = 0, + typename boost::disable_if >::type * = 0); + template typename senf::console::detail::ParsedCommandTraits::Attributor Command(boost::function fn); @@ -588,23 +611,28 @@ namespace factory { template typename senf::console::detail::ParsedCommandTraits::Attributor Command(Function fn, - typename boost::enable_if_c::is_callable>::type * = 0); + typename boost::enable_if_c::is_callable>::type * = 0, + typename boost::disable_if >::type * = 0); template typename senf::console::detail::ParsedCommandTraits::Attributor - BoundCommand(Owner * owner, Member memfn); + Command(Owner * owner, Member memfn, + typename boost::enable_if >::type * = 0); template typename senf::console::detail::ParsedCommandTraits::Attributor - BoundCommand(Owner const * owner, Member memfn); - + Command(Owner const * owner, Member memfn, + typename boost::enable_if >::type * = 0); + template typename senf::console::detail::ParsedCommandTraits::Attributor - BoundCommand(Owner * owner, Member memfn); + Command(Owner * owner, Member memfn, + typename boost::enable_if >::type * = 0); template typename senf::console::detail::ParsedCommandTraits::Attributor - BoundCommand(Owner const * owner, Member memfn); + Command(Owner const * owner, Member memfn, + typename boost::enable_if >::type * = 0); }}} diff --git a/senf/Utils/Console/ParsedCommand.ih b/senf/Utils/Console/ParsedCommand.ih index 5ee1a84..3fbb1b5 100644 --- a/senf/Utils/Console/ParsedCommand.ih +++ b/senf/Utils/Console/ParsedCommand.ih @@ -116,6 +116,7 @@ namespace detail { { static const bool is_callable = false; static const bool is_member = false; + static const bool is_simple = false; }; template @@ -138,6 +139,7 @@ namespace detail { static const bool is_callable = true; static const bool is_member = boost::is_member_pointer::value; + static const bool is_simple = false; typedef typename senf::member_class::type class_type; @@ -148,7 +150,9 @@ namespace detail { // Disable auto-parsing for ParseCommandInfo arg -> register manually parsed command template struct ParsedCommandTraits_i - {}; + { + static const bool is_simple = true; + }; template struct ParsedCommandTraits diff --git a/senf/Utils/Console/ScopedDirectory.test.cc b/senf/Utils/Console/ScopedDirectory.test.cc index 92e30aa..0197408 100644 --- a/senf/Utils/Console/ScopedDirectory.test.cc +++ b/senf/Utils/Console/ScopedDirectory.test.cc @@ -43,7 +43,7 @@ namespace { senf::console::ScopedDirectory dir; TestObject() : dir(this) { - dir.add("member", senf::console::factory::Command(senf::membind(&Self::member,this))); + dir.add("member", senf::console::factory::Command(this, &Self::member)); } void member(std::ostream & os, senf::console::ParseCommandInfo const &) { diff --git a/senf/Utils/Logger/FileTarget.cc b/senf/Utils/Logger/FileTarget.cc index efa898f..e4bf38f 100644 --- a/senf/Utils/Logger/FileTarget.cc +++ b/senf/Utils/Logger/FileTarget.cc @@ -58,11 +58,11 @@ prefix_ senf::log::FileTarget::FileTarget(std::string const & filename, SENF_THROW_SYSTEM_EXCEPTION("logfile open") << ": " << filename; consoleDir() .add( "reopen", - fty::BoundCommand(this, SENF_MEMFNP(void, FileTarget, reopen, ())) + fty::Command(this, SENF_MEMFNP(void, FileTarget, reopen, ())) .doc("Reopen logfile") ); consoleDir() .add("reopen", - fty::BoundCommand(this, SENF_MEMFNP(void, FileTarget, reopen, (std::string const &))) + fty::Command(this, SENF_MEMFNP(void, FileTarget, reopen, (std::string const &))) .arg("filename","new filename") .overloadDoc("Reopen logfile under new name") ); consoleDir() diff --git a/senf/Utils/Logger/LogFormat.cc b/senf/Utils/Logger/LogFormat.cc index 4fc05f8..55304a9 100644 --- a/senf/Utils/Logger/LogFormat.cc +++ b/senf/Utils/Logger/LogFormat.cc @@ -54,24 +54,24 @@ prefix_ senf::log::detail::LogFormat::LogFormat(console::ScopedDirectory<> & dir timeFormat("%Y-%m-%d %H:%M:%S.%f-0000"); - dir.add("showTime", fty::BoundCommand(this, &LogFormat::showTime) + dir.add("showTime", fty::Command(this, &LogFormat::showTime) .arg("flag","whether to display the time in log messages", kw::default_value = true) .doc("Set time display in log messages. If time display is enabled, see the 'timeFormat'\n" "command to set the time format.") ); - dir.add("showStream", fty::BoundCommand(this, &LogFormat::showStream) + dir.add("showStream", fty::Command(this, &LogFormat::showStream) .arg("flag","whether to display the stream in log messages", kw::default_value = true) .doc("Set strean display in log messages.") ); - dir.add("showLevel", fty::BoundCommand(this, &LogFormat::showLevel) + dir.add("showLevel", fty::Command(this, &LogFormat::showLevel) .arg("flag","whether to display the log level in log messages", kw::default_value = true) .doc("Set log level display in log messages.") ); - dir.add("showArea", fty::BoundCommand(this, &LogFormat::showArea) + dir.add("showArea", fty::Command(this, &LogFormat::showArea) .arg("flag","whether to display the area in log messages", kw::default_value = true) .doc("Set area display in log messages.") ); - dir.add("timeFormat", fty::BoundCommand(this, &LogFormat::timeFormat) + dir.add("timeFormat", fty::Command(this, &LogFormat::timeFormat) .arg("format","time format") .doc("Set time format. The time format is specified using a format string. This format\n" "string follows the strftime format.\n" @@ -79,11 +79,11 @@ prefix_ senf::log::detail::LogFormat::LogFormat(console::ScopedDirectory<> & dir "As additional option, the format string may be set to the empty string. In this\n" "case the time will be displayed as 'second.nanosecond' value. IN this case, the\n" "time is displayed relative to the first message after changing the format.") ); - dir.add("tag", fty::BoundCommand(this, &LogFormat::tag) + dir.add("tag", fty::Command(this, &LogFormat::tag) .arg("tag","log message tag prefix") .doc("Every log message is optionally prefixed with a tag value. This value defaults to\n" "the executable name and pid.") ); - dir.add("format", fty::BoundCommand(this, &LogFormat::consoleFormat) + dir.add("format", fty::Command(this, &LogFormat::consoleFormat) .doc("Show the current log message format.") ); } diff --git a/senf/Utils/Logger/SyslogUDPTarget.cc b/senf/Utils/Logger/SyslogUDPTarget.cc index 88b44ba..b5a04e5 100644 --- a/senf/Utils/Logger/SyslogUDPTarget.cc +++ b/senf/Utils/Logger/SyslogUDPTarget.cc @@ -43,10 +43,10 @@ prefix_ void senf::log::SyslogUDPTarget::init() consoleDir().remove("format"); consoleDir() - .add("format", fty::BoundCommand(this, &SyslogUDPTarget::consoleFormat) + .add("format", fty::Command(this, &SyslogUDPTarget::consoleFormat) .doc("Show the current log message format.") ); consoleDir() - .add("syslog", fty::BoundCommand(this, SENF_MEMFNP(void, SyslogUDPTarget, syslog, (bool))) + .add("syslog", fty::Command(this, SENF_MEMFNP(void, SyslogUDPTarget, syslog, (bool))) .arg("flag","new syslog format state", kw::default_value=true) .doc("Change the syslog format flag. By default, syslog formating is enabled. In this\n" diff --git a/senf/Utils/Logger/Target.cc b/senf/Utils/Logger/Target.cc index a693279..1069656 100644 --- a/senf/Utils/Logger/Target.cc +++ b/senf/Utils/Logger/Target.cc @@ -60,7 +60,7 @@ prefix_ senf::log::Target::Target(std::string const & name) detail::TargetRegistry::instance().registerTarget(this, name); consoleDir_() - .add("list", fty::BoundCommand(this, &Target::consoleList) + .add("list", fty::Command(this, &Target::consoleList) .doc("Show routing table\n" "\n" "Columns:\n" @@ -72,7 +72,7 @@ prefix_ senf::log::Target::Target(std::string const & name) " verbose, notice, message, important, critical, fatal\n" " ACTION action to take: accept or reject") ); consoleDir_() - .add("route", fty::BoundCommand(this, &Target::consoleRoute) + .add("route", fty::Command(this, &Target::consoleRoute) .arg("index", "index at which to insert new rule") .arg("parameters", "log parameters. The log parameters select the log stream, log area\n" " and log level. You may specify any combination of these parameterse\n" @@ -108,11 +108,11 @@ prefix_ senf::log::Target::Target(std::string const & name) .arg("action", kw::default_value=ACCEPT) ); consoleDir_() .add("unroute", - fty::BoundCommand(this, static_cast(&Target::unroute)) + fty::Command(this, static_cast(&Target::unroute)) .arg("index", "index of routing entry to remove") .overloadDoc("Remove routing entry with the given index") ); consoleDir_() - .add("unroute", fty::BoundCommand(this, &Target::consoleUnroute) + .add("unroute", fty::Command(this, &Target::consoleUnroute) .arg("parameters", "log parameters. The log parameters select the log stream, log area\n" " and log level. You may specify any combination of these parameterse\n" " in any order. Use the '/sys/log/stream' and '/sys/log/areas' commands\n" @@ -122,7 +122,7 @@ prefix_ senf::log::Target::Target(std::string const & name) kw::default_value=ACCEPT) .overloadDoc("Remove the routing entry matching the specified arguments.") ); consoleDir_() - .add("flush", fty::BoundCommand(this, &Target::flush) + .add("flush", fty::Command(this, &Target::flush) .doc("Remove all routing entries clearing the routing table. This will disable all\n" "logging output on this target.") ); } @@ -402,13 +402,13 @@ prefix_ senf::log::detail::TargetRegistry::TargetRegistry() console::sysdir().add("log", consoleDir_()); consoleDir_() - .add("areas", fty::BoundCommand(this, &TargetRegistry::consoleAreas) + .add("areas", fty::Command(this, &TargetRegistry::consoleAreas) .doc("List all areas") ); consoleDir_() - .add("streams", fty::BoundCommand(this, &TargetRegistry::consoleStreams) + .add("streams", fty::Command(this, &TargetRegistry::consoleStreams) .doc("List all streams") ); consoleDir_() - .add("message", fty::BoundCommand(this, &TargetRegistry::consoleWrite) + .add("message", fty::Command(this, &TargetRegistry::consoleWrite) .arg("parameters", "log parameters. The log parameters select the log stream, log area\n" " and log level. You may specify any combination of these parameterse\n" " in any order. Use the '/sys/log/stream' and '/sys/log/areas' commands\n" @@ -424,7 +424,7 @@ prefix_ senf::log::detail::TargetRegistry::TargetRegistry() " message (FATAL) \"Program on fire\";\n" " message (VERBOSE senf::log::Debug) \"Debug message\";") ); consoleDir_() - .add("self", fty::BoundCommand(this, &TargetRegistry::consoleSelf) + .add("self", fty::Command(this, &TargetRegistry::consoleSelf) .doc("Get the log directory of the current network client. Example usage:\n" "\n" "Just get the log config directory\n" diff --git a/senf/Utils/Statistics.cc b/senf/Utils/Statistics.cc index 2efca87..3dd6d89 100644 --- a/senf/Utils/Statistics.cc +++ b/senf/Utils/Statistics.cc @@ -155,7 +155,7 @@ prefix_ senf::Statistics::Statistics() #ifndef SENF_DISABLE_CONSOLE namespace fty = senf::console::factory; - dir.add("list", fty::BoundCommand(this,&Statistics::consoleList) + dir.add("list", fty::Command(this,&Statistics::consoleList) .doc("List statistics collection intervals and current values.\n" "\n" "Columns:\n" @@ -166,7 +166,7 @@ prefix_ senf::Statistics::Statistics() " AVG Last entered average value.\n" " DEV Standard deviation of average value over the collector rank.\n" " MAX Last entered maximum value.") ); - dir.add("collect", fty::BoundCommand(this, &Statistics::consoleCollect) + dir.add("collect", fty::Command(this, &Statistics::consoleCollect) .doc("Add statistics collection groups. The argument gives a sequence of collector\n" "ranks each building on the preceding collector:\n" "\n" @@ -181,7 +181,7 @@ prefix_ senf::Statistics::Statistics() "You may call collect multiple times. Any missing collection ranks will be\n" "added.") .arg("ranks","chain of collector ranks") ); - dir.add("output", fty::BoundCommand(this, &Statistics::consoleOutput) + dir.add("output", fty::Command(this, &Statistics::consoleOutput) .doc("Generate statistics output. This statement will add an additional output\n" "generator. This generator will be attached to the collector specified by\n" "the {rank} parameter. This parameter is a chain of successive rank values\n" diff --git a/senf/Utils/Statistics.cci b/senf/Utils/Statistics.cci index 6fd93a5..27c953d 100644 --- a/senf/Utils/Statistics.cci +++ b/senf/Utils/Statistics.cci @@ -67,7 +67,7 @@ prefix_ void senf::StatisticsBase::OutputEntry::initDir() { namespace fty = senf::console::factory; - dir.add("list", fty::BoundCommand(this,&OutputEntry::consoleList) + dir.add("list", fty::Command(this,&OutputEntry::consoleList) .doc("List all known connected targets. This list might not be complete.") ); }