Scheduler/Console: Fix adding variables to ScopedDirectory instances
g0dil [Fri, 14 Nov 2008 10:03:27 +0000 (10:03 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@960 270642c3-0616-0410-b53a-bc976706d245

Scheduler/Console/Variables.cti
Scheduler/Console/Variables.hh
Scheduler/Console/Variables.test.cc

index 0e9367f..ef846d5 100644 (file)
@@ -195,6 +195,15 @@ senf::console::senf_console_add_node(DirectoryNode & node, std::string const & n
     return detail::VariableNodeCreator<Variable>::add(node, name, var.get());
 }
 
+template <class Variable, class Owner>
+prefix_ senf::console::VariableAttributor<Variable> senf::console::
+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 *)
+{
+    return detail::VariableNodeCreator<Variable>::add(node, name, var);
+}
+
 #endif
 
 ///////////////////////////////cti.e///////////////////////////////////////
index 1afc654..74db97c 100644 (file)
@@ -54,6 +54,11 @@ namespace console {
     senf_console_add_node(DirectoryNode & node, std::string const & name, 
                           boost::reference_wrapper<Variable> var, int);
 
+    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);
+
 #endif
 
     /** \brief Variable command attributes (const)
index 0bcebc7..58348f7 100644 (file)
@@ -93,6 +93,27 @@ BOOST_AUTO_UNIT_TEST(variables)
         .formatter(&testFormatter);
 }
 
+namespace {
+    
+    class Test2
+    {
+    public:
+        senf::console::ScopedDirectory<Test2> dir;
+        
+        Test2() : dir(this), var_(0)
+            { dir.add("var", var_); }
+        
+    private:
+        int var_;
+    };
+  
+}
+
+BOOST_AUTO_UNIT_TEST(memberVariables)
+{
+    Test2 test2ob;
+}
+
 #ifdef COMPILE_CHECK
 
 COMPILE_FAIL(constVariable)