From: Thomas Geymayer Date: Sun, 20 Oct 2013 10:03:41 +0000 (+0200) Subject: Add SGPropertyNode::setValueReadOnly. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0b197501e1cc611606b9c3728613530714539717;p=simgear.git Add SGPropertyNode::setValueReadOnly. Helper to set value of relative node and mark read only. Use eg. for exposing configuration and build values to the property tree. --- diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index 5103e8c0..c78d2102 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -1241,6 +1241,23 @@ public: return setValue(&val[0]); } + /** + * Set relative node to given value and afterwards make read only. + * + * @param relative_path Path to node + * @param value Value to set + * + * @return whether value could be set + */ + template + bool setValueReadOnly(const std::string& relative_path, const T& value) + { + SGPropertyNode* node = getNode(relative_path, true); + bool ret = node->setValue(value); + node->setAttributes(READ); + return ret; + } + /** * Interpolate current value to target value within given time. *