X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGExpression.hxx;h=2cfa3dc8909d629959816210282535f3be13f37c;hb=10375086ed794770fcb97591ec19c60c0fcdaff1;hp=1832c3a34165e7e2090c082b8b3d383af958fd09;hpb=79ae0da927e2d6c2ecb09024f3a9068f3a30f744;p=simgear.git diff --git a/simgear/structure/SGExpression.hxx b/simgear/structure/SGExpression.hxx index 1832c3a3..2cfa3dc8 100644 --- a/simgear/structure/SGExpression.hxx +++ b/simgear/structure/SGExpression.hxx @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -136,6 +138,8 @@ public: { return simgear::expression::TypeTraits::typeTag; } + virtual void collectDependentProperties(std::set& props) const + { } }; /// Constant value expression @@ -184,7 +188,9 @@ public: _expression = _expression->simplify(); return SGExpression::simplify(); } - + + virtual void collectDependentProperties(std::set& props) const + { _expression->collectDependentProperties(props); } protected: SGUnaryExpression(SGExpression* expression = 0) { setOperand(expression); } @@ -218,6 +224,12 @@ public: return SGExpression::simplify(); } + virtual void collectDependentProperties(std::set& props) const + { + _expressions[0]->collectDependentProperties(props); + _expressions[1]->collectDependentProperties(props); + } + protected: SGBinaryExpression(SGExpression* expr0, SGExpression* expr1) { setOperand(0, expr0); setOperand(1, expr1); } @@ -266,6 +278,11 @@ public: return SGExpression::simplify(); } + virtual void collectDependentProperties(std::set& props) const + { + for (size_t i = 0; i < _expressions.size(); ++i) + _expressions[i]->collectDependentProperties(props); + } protected: SGNaryExpression() { } @@ -288,6 +305,9 @@ public: { _prop = prop; } virtual void eval(T& value, const simgear::expression::Binding*) const { doEval(value); } + + virtual void collectDependentProperties(std::set& props) const + { props.insert(_prop.get()); } private: void doEval(float& value) const { if (_prop) value = _prop->getFloatValue(); } @@ -713,6 +733,12 @@ public: return getOperand()->simplify(); return SGUnaryExpression::simplify(); } + + virtual void collectDependentProperties(std::set& props) const + { + SGUnaryExpression::collectDependentProperties(props); + _enable->collectDependentProperties(props); + } using SGUnaryExpression::getOperand; private: @@ -875,6 +901,11 @@ typedef SGExpression SGExpressionf; typedef SGExpression SGExpressiond; typedef SGExpression SGExpressionb; +typedef SGSharedPtr SGExpressioni_ref; +typedef SGSharedPtr SGExpressionf_ref; +typedef SGSharedPtr SGExpressiond_ref; +typedef SGSharedPtr SGExpressionb_ref; + /** * Global function to make an expression out of properties. @@ -919,7 +950,7 @@ namespace simgear { struct ParseError : public sg_exception { - ParseError(const string& message = std::string()) + ParseError(const std::string& message = std::string()) : sg_exception(message) {} }; @@ -984,7 +1015,7 @@ namespace simgear { 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 bindings; }; @@ -1001,7 +1032,7 @@ namespace simgear 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); }