X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGBinding.hxx;h=15757faeeeb357c214c0dd3c5d0a06abe74d5a46;hb=f41b18f0649a50e179ba41383f4061e1878c4d4c;hp=25e1601efc4e970bace30afa993b9ebc0fdcd289;hpb=8106956be236a35652d4421bae78e6f3a4c81543;p=simgear.git diff --git a/simgear/structure/SGBinding.hxx b/simgear/structure/SGBinding.hxx index 25e1601e..15757fae 100644 --- a/simgear/structure/SGBinding.hxx +++ b/simgear/structure/SGBinding.hxx @@ -38,6 +38,12 @@ public: */ SGBinding (); + /** + * Convenience constructor. + * + * @param node The binding will be built from this node. + */ + SGBinding(const std::string& commandName); /** * Convenience constructor. @@ -52,6 +58,14 @@ public: */ virtual ~SGBinding (); + + /** + * clear internal state of the binding back to empty. This is useful + * if you don't want the 'remove on delete' behaviour of the + * destructor. + */ + void clear(); + /** * Get the command name. @@ -67,7 +81,7 @@ public: * @return The command associated with this binding, or 0 if none * is present. */ - SGCommandMgr::command_t getCommand () const { return _command; } + SGCommandMgr::Command* getCommand () const { return _command; } /** @@ -108,18 +122,49 @@ public: */ void fire (double setting) const; - + /** + * Fire a binding with a number of additional parameters + * + * The children of params will be merged with the fixed arguments. + */ + void fire (SGPropertyNode* params) const; + private: + void innerFire() const; // just to be safe. SGBinding (const SGBinding &binding); std::string _command_name; - mutable SGCommandMgr::command_t _command; + mutable SGCommandMgr::Command* _command; mutable SGPropertyNode_ptr _arg; mutable SGPropertyNode_ptr _setting; }; -typedef std::vector > SGBindingList; +typedef SGSharedPtr SGBinding_ptr; + +typedef std::vector SGBindingList; typedef std::map SGBindingMap; +/** + * fire every binding in a list, in sequence + + */ +void fireBindingList(const SGBindingList& aBindings, SGPropertyNode* params = NULL); + +/** + * fire every binding in a list with a setting value + + */ +void fireBindingListWithOffset(const SGBindingList& aBindings, double offset, double max); + +/** + * read multiple bindings from property-list format + */ +SGBindingList readBindingList(const simgear::PropertyList& aNodes, SGPropertyNode* aRoot); + +/** + * call clear() on every binding in a list + */ +void clearBindingList(const SGBindingList& aBindings); + #endif