#include "props.hxx"
#include "condition.hxx"
-#include <simgear/math/SGMath.hxx>
#include <simgear/structure/SGExpression.hxx>
using std::istream;
using std::ostream;
-\f
+using std::string;
+
/**
* Condition for a single property.
*
const char * propname );
virtual ~SGPropertyCondition ();
virtual bool test () const { return _node->getBoolValue(); }
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+ { props.insert(_node.get()); }
private:
SGConstPropertyNode_ptr _node;
};
SGNotCondition (SGCondition * condition);
virtual ~SGNotCondition ();
virtual bool test () const;
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const;
private:
SGSharedPtr<SGCondition> _condition;
};
virtual bool test () const;
// transfer pointer ownership
virtual void addCondition (SGCondition * condition);
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const;
private:
std::vector<SGSharedPtr<SGCondition> > _conditions;
};
virtual bool test () const;
// transfer pointer ownership
virtual void addCondition (SGCondition * condition);
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const;
private:
std::vector<SGSharedPtr<SGCondition> > _conditions;
};
void setRightDExpression(SGExpressiond* dexp);
void setPrecisionDExpression(SGExpressiond* dexp);
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const;
private:
Type _type;
bool _reverse;
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGPropertyCondition.
////////////////////////////////////////////////////////////////////////
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGNotCondition.
////////////////////////////////////////////////////////////////////////
return !(_condition->test());
}
+void
+SGNotCondition::collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+{
+ _condition->collectDependentProperties(props);
+}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGAndCondition.
////////////////////////////////////////////////////////////////////////
bool
SGAndCondition::test () const
{
- int nConditions = _conditions.size();
- for (int i = 0; i < nConditions; i++) {
+ for( size_t i = 0; i < _conditions.size(); i++ )
+ {
if (!_conditions[i]->test())
return false;
}
_conditions.push_back(condition);
}
+void
+SGAndCondition::collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+{
+ for( size_t i = 0; i < _conditions.size(); i++ )
+ _conditions[i]->collectDependentProperties(props);
+}
+
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGOrCondition.
////////////////////////////////////////////////////////////////////////
bool
SGOrCondition::test () const
{
- int nConditions = _conditions.size();
- for (int i = 0; i < nConditions; i++) {
+ for( size_t i = 0; i < _conditions.size(); i++ )
+ {
if (_conditions[i]->test())
return true;
}
_conditions.push_back(condition);
}
+void
+SGOrCondition::collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+{
+ for( size_t i = 0; i < _conditions.size(); i++ )
+ _conditions[i]->collectDependentProperties(props);
+}
+
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGComparisonCondition.
////////////////////////////////////////////////////////////////////////
}
case props::INT:
return doComp<int>(left->getIntValue(), right->getIntValue(),
- precision ? abs(precision->getIntValue()/2) : 0 );
+ precision ? std::abs(precision->getIntValue()/2) : 0 );
case props::LONG:
return doComp<long>(left->getLongValue(), right->getLongValue(),
- precision ? abs(precision->getLongValue()/2L) : 0L );
+ precision ? std::abs(precision->getLongValue()/2L) : 0L );
case props::FLOAT:
return doComp<float>(left->getFloatValue(), right->getFloatValue(),
- precision ? fabs(precision->getFloatValue()/2.0f) : 0.0f );
+ precision ? std::fabs(precision->getFloatValue()/2.0f) : 0.0f );
case props::DOUBLE:
return doComp<double>(left->getDoubleValue(), right->getDoubleValue(),
- precision ? fabs(precision->getDoubleValue()/2.0) : 0.0 );
+ precision ? std::fabs(precision->getDoubleValue()/2.0) : 0.0 );
case props::STRING:
case props::NONE:
{
_precision_property = new SGPropertyNode();
_precision_dexp = dexp;
-}\f
+}
+
+void
+SGComparisonCondition::collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+{
+ if (_left_dexp)
+ _left_dexp->collectDependentProperties(props);
+ else
+ props.insert(_left_property);
+
+ if (_right_dexp)
+ _right_dexp->collectDependentProperties(props);
+ else
+ props.insert(_right_property);
+
+ if (_precision_dexp)
+ _precision_dexp->collectDependentProperties(props);
+ else if (_precision_property)
+ props.insert(_precision_property);
+
+}
+
////////////////////////////////////////////////////////////////////////
// Read a condition and use it if necessary.
////////////////////////////////////////////////////////////////////////
}
-\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGConditional.
////////////////////////////////////////////////////////////////////////
}
-\f
// The top-level is always an implicit 'and' group
SGCondition *
sgReadCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )