From 5b3359d6536f68838a57a7c66f9f3e9b13a5f3b7 Mon Sep 17 00:00:00 2001
From: g0dil <g0dil@wiback.org>
Date: Fri, 14 Nov 2008 10:03:27 +0000
Subject: [PATCH] Scheduler/Console: Fix adding variables to ScopedDirectory
 instances

---
 Scheduler/Console/Variables.cti     |  9 +++++++++
 Scheduler/Console/Variables.hh      |  5 +++++
 Scheduler/Console/Variables.test.cc | 21 +++++++++++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/Scheduler/Console/Variables.cti b/Scheduler/Console/Variables.cti
index 0e9367f7..ef846d5d 100644
--- a/Scheduler/Console/Variables.cti
+++ b/Scheduler/Console/Variables.cti
@@ -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///////////////////////////////////////
diff --git a/Scheduler/Console/Variables.hh b/Scheduler/Console/Variables.hh
index 1afc654c..74db97c7 100644
--- a/Scheduler/Console/Variables.hh
+++ b/Scheduler/Console/Variables.hh
@@ -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)
diff --git a/Scheduler/Console/Variables.test.cc b/Scheduler/Console/Variables.test.cc
index 0bcebc70..58348f78 100644
--- a/Scheduler/Console/Variables.test.cc
+++ b/Scheduler/Console/Variables.test.cc
@@ -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)
-- 
GitLab