From 0b197501e1cc611606b9c3728613530714539717 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Sun, 20 Oct 2013 12:03:41 +0200 Subject: [PATCH] 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. --- simgear/props/props.hxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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. * -- 2.39.5