#include <string>
#include <vector>
#include <functional>
+#include <set>
+#include <string>
#include <simgear/props/condition.hxx>
#include <simgear/props/props.hxx>
{
return simgear::expression::TypeTraits<T>::typeTag;
}
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+ { }
};
/// Constant value expression
_expression = _expression->simplify();
return SGExpression<T>::simplify();
}
-
+
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+ { _expression->collectDependentProperties(props); }
protected:
SGUnaryExpression(SGExpression<T>* expression = 0)
{ setOperand(expression); }
return SGExpression<T>::simplify();
}
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+ {
+ _expressions[0]->collectDependentProperties(props);
+ _expressions[1]->collectDependentProperties(props);
+ }
+
protected:
SGBinaryExpression(SGExpression<T>* expr0, SGExpression<T>* expr1)
{ setOperand(0, expr0); setOperand(1, expr1); }
return SGExpression<T>::simplify();
}
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+ {
+ for (size_t i = 0; i < _expressions.size(); ++i)
+ _expressions[i]->collectDependentProperties(props);
+ }
protected:
SGNaryExpression()
{ }
{ _prop = prop; }
virtual void eval(T& value, const simgear::expression::Binding*) const
{ doEval(value); }
+
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+ { props.insert(_prop.get()); }
private:
void doEval(float& value) const
{ if (_prop) value = _prop->getFloatValue(); }
return getOperand()->simplify();
return SGUnaryExpression<T>::simplify();
}
+
+ virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const
+ {
+ SGUnaryExpression<T>::collectDependentProperties(props);
+ _enable->collectDependentProperties(props);
+ }
using SGUnaryExpression<T>::getOperand;
private:
typedef SGExpression<double> SGExpressiond;
typedef SGExpression<bool> SGExpressionb;
+typedef SGSharedPtr<SGExpressioni> SGExpressioni_ref;
+typedef SGSharedPtr<SGExpressionf> SGExpressionf_ref;
+typedef SGSharedPtr<SGExpressiond> SGExpressiond_ref;
+typedef SGSharedPtr<SGExpressionb> SGExpressionb_ref;
+
/**
* Global function to make an expression out of properties.
{
struct ParseError : public sg_exception
{
- ParseError(const string& message = std::string())
+ ParseError(const std::string& message = std::string())
: sg_exception(message) {}
};
{
public:
size_t addBinding(const std::string& name, expression::Type type);
- bool findBinding(const string& name, VariableBinding& result) const;
+ bool findBinding(const std::string& name, VariableBinding& result) const;
std::vector<VariableBinding> bindings;
};
ParserMap& map = getParserMap();
ParserMap::iterator itr = map.find(exp->getName());
if (itr == map.end())
- throw ParseError(string("unknown expression ") + exp->getName());
+ throw ParseError(std::string("unknown expression ") + exp->getName());
exp_parser parser = itr->second;
return (*parser)(exp, this);
}