#endif
#include "props.hxx"
+#include "vectorPropTemplates.hxx"
#include <algorithm>
#include <boost/functional/hash.hpp>
#include <boost/range.hpp>
-#include <simgear/math/SGMath.hxx>
-
#if PROPS_STANDALONE
#include <iostream>
#else
* Last used attribute
* Update as needed when enum Attribute is changed
*/
-const int SGPropertyNode::LAST_USED_ATTRIBUTE = USERARCHIVE;
+const int SGPropertyNode::LAST_USED_ATTRIBUTE = PRESERVE;
/**
* Default constructor: always creates a root node.
* Copy constructor.
*/
SGPropertyNode::SGPropertyNode (const SGPropertyNode &node)
- : _index(node._index),
+ : SGReferenced(node),
+ _index(node._index),
_name(node._name),
_parent(0), // don't copy the parent
_type(node._type),
bool
SGPropertyNode::alias (SGPropertyNode * target)
{
- if (target == 0 || _type == props::ALIAS || _tied)
- return false;
- clearValue();
- get(target);
- _value.alias = target;
- _type = props::ALIAS;
- return true;
+ if (target && (_type != props::ALIAS) && (!_tied))
+ {
+ clearValue();
+ get(target);
+ _value.alias = target;
+ _type = props::ALIAS;
+ return true;
+ }
+
+#if PROPS_STANDALONE
+#else
+ if (!target)
+ {
+ SG_LOG(SG_GENERAL, SG_ALERT,
+ "Failed to create alias for " << getPath() << ". "
+ "The target property does not exist.");
+ }
+ else
+ if (_type == props::ALIAS)
+ {
+ if (_value.alias == target)
+ return true; // ok, identical alias requested
+ SG_LOG(SG_GENERAL, SG_ALERT,
+ "Failed to create alias at " << target->getPath() << ". "
+ "Source "<< getPath() << " is already aliasing another property.");
+ }
+ else
+ if (_tied)
+ {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Failed to create alias at " << target->getPath() << ". "
+ "Source " << getPath() << " is a tied property.");
+ }
+#endif
+
+ return false;
}
_tied = true;
_value.val = rawValue.clone();
- if (useDefault)
+ if (useDefault) {
+ int save_attributes = getAttributes();
+ setAttribute( WRITE, true );
setStringValue(old_val.c_str());
+ setAttributes( save_attributes );
+ }
return true;
}