diff --git a/Scheduler/Console/ParsedCommand.cti b/Scheduler/Console/ParsedCommand.cti index a3f2618c154866bedb11eedd982db3448f407859..eeedd3a303f0d7fcad3a163a51ef962ce0558679 100644 --- a/Scheduler/Console/ParsedCommand.cti +++ b/Scheduler/Console/ParsedCommand.cti @@ -373,7 +373,8 @@ namespace detail { template <class Function> typename senf::console::detail::ParsedCommandTraits<Function>::Attributor senf::console::senf_console_add_node(DirectoryNode & node, std::string const & name, - Function fn, int) + Function fn, int, + typename boost::enable_if_c<detail::ParsedCommandTraits<Function>::is_callable>::type *) { return senf::console::detail::addOverloadedCommandNode<Function>(node, name, fn); } diff --git a/Scheduler/Console/ParsedCommand.hh b/Scheduler/Console/ParsedCommand.hh index 107ed65a0de9c5cae66de7e1eccf9323efedd1a1..6604dd34875277024ef9b873655ae40d2fb65813 100644 --- a/Scheduler/Console/ParsedCommand.hh +++ b/Scheduler/Console/ParsedCommand.hh @@ -565,7 +565,9 @@ namespace console { template <class Function> typename detail::ParsedCommandTraits<Function>::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<Function>::is_callable>::type * = 0); template <class Signature> typename detail::ParsedCommandTraits<Signature>::Attributor diff --git a/Scheduler/Console/ParsedCommand.ih b/Scheduler/Console/ParsedCommand.ih index 330ea7c42857717bc830673656afe309eb395138..c339445209f920d6cc51da7e1bfaf11bfd1bf257 100644 --- a/Scheduler/Console/ParsedCommand.ih +++ b/Scheduler/Console/ParsedCommand.ih @@ -112,7 +112,10 @@ namespace detail { template <class FnunctionP, class Function, bool isFN=boost::is_function<Function>::value> struct ParsedCommandTraits_i - {}; + { + static const bool is_callable = false; + static const bool is_member = false; + }; template <class FunctionP, class Function> struct ParsedCommandTraits_i<FunctionP, Function, true> @@ -132,6 +135,7 @@ namespace detail { typedef typename senf::remove_cvref<typename base_traits::result_type>::type result_type; + static const bool is_callable = true; static const bool is_member = boost::is_member_pointer<base_type>::value; typedef typename senf::member_class<base_type>::type class_type; diff --git a/Scheduler/Console/ScopedDirectory.cti b/Scheduler/Console/ScopedDirectory.cti index 40c7e2558ff2bfd49cba48897f638e6b6cde9594..6fedea2d3f6aa6519ca837db4a65460bf3bb9b6e 100644 --- a/Scheduler/Console/ScopedDirectory.cti +++ b/Scheduler/Console/ScopedDirectory.cti @@ -75,7 +75,7 @@ senf::console::ScopedDirectory<Owner>::add(std::string const & name, Object & ob template <class Owner, class Function> 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 c0f3bb9f4272146a1267e43af7b0bf1dbb7f5e06..f82375affb4a5cfcf6fc20c127c237d0e06a6640 100644 --- a/Scheduler/Console/ScopedDirectory.hh +++ b/Scheduler/Console/ScopedDirectory.hh @@ -189,7 +189,8 @@ namespace console { template <class Owner, class Function> 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 <class Owner> SimpleCommandNode & senf_console_add_node( diff --git a/Scheduler/Console/Variables.cti b/Scheduler/Console/Variables.cti index ef846d5defc67fa737cabb4da2cc74316de31042..f6839be1fe688fc89248b78f936dc4a53a38ab89 100644 --- a/Scheduler/Console/Variables.cti +++ b/Scheduler/Console/Variables.cti @@ -182,7 +182,8 @@ senf::console::detail::VariableNodeCreator<Variable, true>::add(DirectoryNode & template <class Variable> prefix_ senf::console::VariableAttributor<Variable> senf::console:: senf_console_add_node(DirectoryNode & node, std::string const & name, Variable & var, int, - typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type *) + typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type *, + typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type *) { return detail::VariableNodeCreator<Variable>::add(node, name, var); } @@ -197,13 +198,23 @@ senf::console::senf_console_add_node(DirectoryNode & node, std::string const & n template <class Variable, class Owner> prefix_ senf::console::VariableAttributor<Variable> 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<Variable*, ScopedDirectoryBase*> >::type *) + typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type *, + typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type *) { return detail::VariableNodeCreator<Variable>::add(node, name, var); } +template <class Variable, class Owner> +prefix_ typename senf::console::detail::VariableNodeCreator<Variable>::result_type +senf::console::senf_console_add_node(DirectoryNode & node, Owner &, + std::string const & name, + boost::reference_wrapper<Variable> var, int) +{ + return detail::VariableNodeCreator<Variable>::add(node, name, var.get()); +} + #endif ///////////////////////////////cti.e/////////////////////////////////////// diff --git a/Scheduler/Console/Variables.hh b/Scheduler/Console/Variables.hh index 74db97c78bc133a7c28bd1e0231baf2a3344c5b2..d8a9468019d83344b0bf1d455a4d6bc85766d342 100644 --- a/Scheduler/Console/Variables.hh +++ b/Scheduler/Console/Variables.hh @@ -47,7 +47,8 @@ namespace console { template <class Variable> VariableAttributor<Variable> senf_console_add_node( DirectoryNode & node, std::string const & name, Variable & var, int, - typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type * = 0); + typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type * = 0, + typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type * = 0); template <class Variable> typename detail::VariableNodeCreator<Variable>::result_type @@ -57,7 +58,13 @@ namespace console { template <class Variable, class Owner> VariableAttributor<Variable> senf_console_add_node( DirectoryNode & node, Owner & owner, std::string const & name, Variable & var, int, - typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type * = 0); + typename boost::disable_if< boost::is_convertible<Variable*, ScopedDirectoryBase*> >::type * = 0, + typename boost::disable_if_c<detail::ParsedCommandTraits<Variable>::is_callable>::type * = 0); + + template <class Variable, class Owner> + typename detail::VariableNodeCreator<Variable>::result_type + senf_console_add_node(DirectoryNode & node, Owner & owner, std::string const & name, + boost::reference_wrapper<Variable> var, int); #endif diff --git a/Scheduler/Console/Variables.test.cc b/Scheduler/Console/Variables.test.cc index 58348f784e1afdefe208f4efc930bebd52c72b9f..9bc58cda8638985c71bfe2821c3d4c9d86a13227 100644 --- a/Scheduler/Console/Variables.test.cc +++ b/Scheduler/Console/Variables.test.cc @@ -29,10 +29,7 @@ // Custom includes #include <iostream> #include <sstream> -#include "Variables.hh" -#include "Executor.hh" -#include "Parse.hh" -#include "ScopedDirectory.hh" +#include "Console.hh" #include "../../Utils/auto_unit_test.hh" #include <boost/test/test_tools.hpp> diff --git a/Utils/type_traits.hh b/Utils/type_traits.hh index 34451b4c15b2358ac3ef8ee1146d225f3645bab9..1e9667b40a9bc77b4d96501b9376ba8d127e6979 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 <T (C::* const) > + { + 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 <T (C::* const) > + { + typedef C type; + }; + #endif /** \brief Remove any type of pointer from type