#ifndef __TIEDPROPERTYLIST_HXX
#define __TIEDPROPERTYLIST_HXX
#include <simgear/props/props.hxx>
-using simgear::PropertyList;
+#include <assert.h>
namespace simgear {
* This helper class keeps track of tied properties and unties
* each tied property when this class gets destructed.
*/
-class TiedPropertyList : PropertyList {
+class TiedPropertyList : simgear::PropertyList {
public:
TiedPropertyList() {}
TiedPropertyList( SGPropertyNode_ptr root ) : _root(root) {}
+ virtual ~TiedPropertyList()
+ {
+ _root = 0;
+ if (size()>0)
+ {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Detected properties with dangling ties. Use 'Untie' before removing a TiedPropertyList.");
+ // running debug mode: go, fix it!
+ assert(size() == 0);
+ }
+ }
void setRoot( SGPropertyNode_ptr root ) { _root = root; }
SGPropertyNode_ptr getRoot() const { return _root; }
template<typename T> SGPropertyNode_ptr Tie( SGPropertyNode_ptr node, const SGRawValue<T> &rawValue, bool useDefault = true ) {
bool success = node->tie( rawValue, useDefault );
if( success ) {
- SG_LOG( SG_ALL, SG_INFO, "Tied " << node->getPath() );
+ SG_LOG( SG_ALL, SG_DEBUG, "Tied " << node->getPath() );
push_back( node );
} else {
#if PROPS_STANDALONE
void Untie() {
while( size() > 0 ) {
- SG_LOG( SG_ALL, SG_INFO, "untie of " << back()->getPath() );
+ SG_LOG( SG_ALL, SG_DEBUG, "untie of " << back()->getPath() );
back()->untie();
pop_back();
}
}
+
+ void setAttribute (SGPropertyNode::Attribute attr, bool state)
+ {
+ for (std::vector<SGPropertyNode_ptr>::iterator it=begin() ; it < end(); it++ )
+ (*it)->setAttribute(attr, state);
+ }
private:
SGPropertyNode_ptr _root;
};