From: g0dil Date: Fri, 14 Nov 2008 15:02:55 +0000 (+0000) Subject: Scheduler/Console: Fix overload resolution order when adding parsed commands X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=8488a803a9e1dfa293af161eb271503990d6fdd3;p=senf.git Scheduler/Console: Fix overload resolution order when adding parsed commands git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@962 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Scheduler/Console/ParsedCommand.cti b/Scheduler/Console/ParsedCommand.cti index a3f2618..eeedd3a 100644 --- a/Scheduler/Console/ParsedCommand.cti +++ b/Scheduler/Console/ParsedCommand.cti @@ -373,7 +373,8 @@ namespace detail { template typename senf::console::detail::ParsedCommandTraits::Attributor senf::console::senf_console_add_node(DirectoryNode & node, std::string const & name, - Function fn, int) + Function fn, int, + typename boost::enable_if_c::is_callable>::type *) { return senf::console::detail::addOverloadedCommandNode(node, name, fn); } diff --git a/Scheduler/Console/ParsedCommand.hh b/Scheduler/Console/ParsedCommand.hh index 107ed65..6604dd3 100644 --- a/Scheduler/Console/ParsedCommand.hh +++ b/Scheduler/Console/ParsedCommand.hh @@ -565,7 +565,9 @@ namespace console { template typename detail::ParsedCommandTraits::Attributor - senf_console_add_node(DirectoryNode & node, std::string const & name, Function fn, int); + senf_console_add_node(DirectoryNode & node, std::string const & name, Function fn, int, + typename boost::enable_if_c< + detail::ParsedCommandTraits::is_callable>::type * = 0); template typename detail::ParsedCommandTraits::Attributor diff --git a/Scheduler/Console/ParsedCommand.ih b/Scheduler/Console/ParsedCommand.ih index 330ea7c..c339445 100644 --- a/Scheduler/Console/ParsedCommand.ih +++ b/Scheduler/Console/ParsedCommand.ih @@ -112,7 +112,10 @@ namespace detail { template ::value> struct ParsedCommandTraits_i - {}; + { + static const bool is_callable = false; + static const bool is_member = false; + }; template struct ParsedCommandTraits_i @@ -132,6 +135,7 @@ namespace detail { typedef typename senf::remove_cvref::type result_type; + static const bool is_callable = true; static const bool is_member = boost::is_member_pointer::value; typedef typename senf::member_class::type class_type; diff --git a/Scheduler/Console/ScopedDirectory.cti b/Scheduler/Console/ScopedDirectory.cti index 40c7e25..6fedea2 100644 --- a/Scheduler/Console/ScopedDirectory.cti +++ b/Scheduler/Console/ScopedDirectory.cti @@ -75,7 +75,7 @@ senf::console::ScopedDirectory::add(std::string const & name, Object & ob template prefix_ senf::console::SimpleCommandNode & senf::console:: senf_console_add_node(DirectoryNode & node, Owner & , std::string const & name, - Function const & fn, ...) + SimpleCommandNode::Function fn, int) { return node.add(name,fn); } diff --git a/Scheduler/Console/ScopedDirectory.hh b/Scheduler/Console/ScopedDirectory.hh index c0f3bb9..f82375a 100644 --- a/Scheduler/Console/ScopedDirectory.hh +++ b/Scheduler/Console/ScopedDirectory.hh @@ -189,7 +189,8 @@ namespace console { template SimpleCommandNode & senf_console_add_node( - DirectoryNode & node, Owner & owner, std::string const & name, Function const & fn, ...); + DirectoryNode & node, Owner & owner, std::string const & name, + SimpleCommandNode::Function fn, int); template SimpleCommandNode & senf_console_add_node( diff --git a/Scheduler/Console/Variables.cti b/Scheduler/Console/Variables.cti index ef846d5..f6839be 100644 --- a/Scheduler/Console/Variables.cti +++ b/Scheduler/Console/Variables.cti @@ -182,7 +182,8 @@ senf::console::detail::VariableNodeCreator::add(DirectoryNode & template prefix_ senf::console::VariableAttributor senf::console:: senf_console_add_node(DirectoryNode & node, std::string const & name, Variable & var, int, - typename boost::disable_if< boost::is_convertible >::type *) + typename boost::disable_if< boost::is_convertible >::type *, + typename boost::disable_if_c::is_callable>::type *) { return detail::VariableNodeCreator::add(node, name, var); } @@ -197,13 +198,23 @@ senf::console::senf_console_add_node(DirectoryNode & node, std::string const & n template prefix_ senf::console::VariableAttributor senf::console:: -senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name, +senf_console_add_node(DirectoryNode & node, Owner &, std::string const & name, Variable & var, int, - typename boost::disable_if< boost::is_convertible >::type *) + typename boost::disable_if< boost::is_convertible >::type *, + typename boost::disable_if_c::is_callable>::type *) { return detail::VariableNodeCreator::add(node, name, var); } +template +prefix_ typename senf::console::detail::VariableNodeCreator::result_type +senf::console::senf_console_add_node(DirectoryNode & node, Owner &, + std::string const & name, + boost::reference_wrapper var, int) +{ + return detail::VariableNodeCreator::add(node, name, var.get()); +} + #endif ///////////////////////////////cti.e/////////////////////////////////////// diff --git a/Scheduler/Console/Variables.hh b/Scheduler/Console/Variables.hh index 74db97c..d8a9468 100644 --- a/Scheduler/Console/Variables.hh +++ b/Scheduler/Console/Variables.hh @@ -47,7 +47,8 @@ namespace console { template VariableAttributor senf_console_add_node( DirectoryNode & node, std::string const & name, Variable & var, int, - typename boost::disable_if< boost::is_convertible >::type * = 0); + typename boost::disable_if< boost::is_convertible >::type * = 0, + typename boost::disable_if_c::is_callable>::type * = 0); template typename detail::VariableNodeCreator::result_type @@ -57,7 +58,13 @@ namespace console { template VariableAttributor senf_console_add_node( DirectoryNode & node, Owner & owner, std::string const & name, Variable & var, int, - typename boost::disable_if< boost::is_convertible >::type * = 0); + typename boost::disable_if< boost::is_convertible >::type * = 0, + typename boost::disable_if_c::is_callable>::type * = 0); + + template + typename detail::VariableNodeCreator::result_type + senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name, + boost::reference_wrapper var, int); #endif diff --git a/Scheduler/Console/Variables.test.cc b/Scheduler/Console/Variables.test.cc index 58348f7..9bc58cd 100644 --- a/Scheduler/Console/Variables.test.cc +++ b/Scheduler/Console/Variables.test.cc @@ -29,10 +29,7 @@ // Custom includes #include #include -#include "Variables.hh" -#include "Executor.hh" -#include "Parse.hh" -#include "ScopedDirectory.hh" +#include "Console.hh" #include "../../Utils/auto_unit_test.hh" #include diff --git a/Utils/type_traits.hh b/Utils/type_traits.hh index 34451b4..1e9667b 100644 --- a/Utils/type_traits.hh +++ b/Utils/type_traits.hh @@ -131,6 +131,11 @@ namespace senf typedef T type; }; + template < class C, class T > struct remove_member_pointer + { + typedef T type; + }; + #endif /** \brief Get class of a member pointer @@ -163,6 +168,11 @@ namespace senf typedef C type; }; + template < class C, class T > struct member_class + { + typedef C type; + }; + #endif /** \brief Remove any type of pointer from type