diff --git a/simgear/structure/SGBinding.cxx b/simgear/structure/SGBinding.cxx index 4a0d0326..320e13a1 100644 --- a/simgear/structure/SGBinding.cxx +++ b/simgear/structure/SGBinding.cxx @@ -69,7 +69,9 @@ SGBinding::read(const SGPropertyNode* node, SGPropertyNode* root) } _arg = const_cast(node); + _root = const_cast(root); _setting = 0; + } void @@ -89,7 +91,7 @@ SGBinding::innerFire () const SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding:" << _command_name); } else { try { - if (!(*_command)(_arg)) { + if (!(*_command)(_arg, _root)) { SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command " << _command_name); } diff --git a/simgear/structure/SGBinding.hxx b/simgear/structure/SGBinding.hxx index 6ec2bc68..3574a524 100644 --- a/simgear/structure/SGBinding.hxx +++ b/simgear/structure/SGBinding.hxx @@ -142,6 +142,7 @@ private: mutable SGCommandMgr::Command* _command; mutable SGPropertyNode_ptr _arg; mutable SGPropertyNode_ptr _setting; + mutable SGPropertyNode_ptr _root; }; typedef SGSharedPtr SGBinding_ptr; diff --git a/simgear/structure/commands.cxx b/simgear/structure/commands.cxx index 752f880c..150e16aa 100644 --- a/simgear/structure/commands.cxx +++ b/simgear/structure/commands.cxx @@ -75,7 +75,7 @@ SGCommandMgr::getCommandNames () const } bool -SGCommandMgr::execute (const std::string &name, const SGPropertyNode * arg) const +SGCommandMgr::execute (const std::string &name, const SGPropertyNode * arg, SGPropertyNode *root) const { Command* command = getCommand(name); if (command == 0) @@ -86,7 +86,7 @@ SGCommandMgr::execute (const std::string &name, const SGPropertyNode * arg) cons try { - return (*command)(arg); + return (*command)(arg, root); } catch(sg_exception& e) { diff --git a/simgear/structure/commands.hxx b/simgear/structure/commands.hxx index 7f4185ec..58d8c281 100644 --- a/simgear/structure/commands.hxx +++ b/simgear/structure/commands.hxx @@ -41,11 +41,11 @@ public: { public: virtual ~Command() { } - virtual bool operator()(const SGPropertyNode * arg) = 0; + virtual bool operator()(const SGPropertyNode * arg, SGPropertyNode *root) = 0; }; - typedef bool (*command_t) (const SGPropertyNode * arg); + typedef bool (*command_t) (const SGPropertyNode * arg, SGPropertyNode *root); private: class FunctionCommand : public Command @@ -54,7 +54,7 @@ private: FunctionCommand( command_t fun ) : f_(fun) {} - virtual bool operator()(const SGPropertyNode * arg) { return (*f_)(arg); } + virtual bool operator()(const SGPropertyNode * arg, SGPropertyNode *root) { return (*f_)(arg, root); } private: command_t f_; }; @@ -66,9 +66,9 @@ private: MethodCommand( const ObjPtr& pObj, MemFn pMemFn ) : pObj_(pObj), pMemFn_(pMemFn) {} - virtual bool operator()(const SGPropertyNode * arg) + virtual bool operator()(const SGPropertyNode * arg, SGPropertyNode *root) { - return ((*pObj_).*pMemFn_)(arg); + return ((*pObj_).*pMemFn_)(arg,root); } private: ObjPtr pObj_; @@ -147,7 +147,7 @@ public: * @return true if the command is present and executes successfully, * false otherwise. */ - virtual bool execute (const std::string &name, const SGPropertyNode * arg) const; + virtual bool execute (const std::string &name, const SGPropertyNode * arg, SGPropertyNode *root) const; /** * Remove a command registration