}
return output;
}
+
+ if (name == "difference" || name == "dif" ) {
+ if (expression->nChildren() < 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGDifferenceExpression<T>* output = new SGDifferenceExpression<T>;
+ if (!SGReadNaryOperands(output, inputRoot, expression)) {
+ delete output;
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return output;
+ }
+
if (name == "prod" || name == "product") {
if (expression->nChildren() < 1) {
SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
using SGNaryExpression<T>::getOperand;
};
+template<typename T>
+class SGDifferenceExpression : public SGNaryExpression<T> {
+public:
+ SGDifferenceExpression()
+ { }
+ SGDifferenceExpression(SGExpression<T>* expr0, SGExpression<T>* expr1)
+ : SGNaryExpression<T>(expr0, expr1)
+ { }
+ virtual void eval(T& value, const simgear::expression::Binding* b) const
+ {
+ value = T(0);
+ unsigned sz = SGNaryExpression<T>::getNumOperands();
+ for (unsigned i = 0; i < sz; ++i)
+ value -= getOperand(i)->getValue(b);
+ }
+ using SGNaryExpression<T>::getValue;
+ using SGNaryExpression<T>::getOperand;
+};
+
template<typename T>
class SGProductExpression : public SGNaryExpression<T> {
public: