From: Torsten Dreyer <torsten@t3r.de>
Date: Wed, 27 May 2015 18:18:22 +0000 (+0200)
Subject: PropertyObject: enable creation of property
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0b1399479a09c25e52f12ed8f37971830aa55d29;p=simgear.git

PropertyObject: enable creation of property

add a create-flag to the node() method of a PropertyObject,
defaulting to false to maintain existing behaviour.
This could be used to add a listener to a non-existing property
without having to write a dummy-value beforehand.

Usage:
myPropertyObject->node() returns the corresponding node or NULL if
does not exist or has not been accessed before.
myPropertyObject->node(true) returns the corresponding node, never NULL.
If the property does not exist, it will gets created.
---

diff --git a/simgear/props/propertyObject.hxx b/simgear/props/propertyObject.hxx
index 9e658659..d97f9d11 100644
--- a/simgear/props/propertyObject.hxx
+++ b/simgear/props/propertyObject.hxx
@@ -144,9 +144,9 @@ public:
 
 #undef SG_DEF_ASSIGN_OP
 
-  SGPropertyNode* node() const
+  SGPropertyNode* node(bool aCreate = false) const
   {
-    return PropertyObjectBase::node(false);
+    return PropertyObjectBase::node(aCreate);
   }
 }; // of template PropertyObject