Expressions: Added App::BooleanExpression class.

This commit is contained in:
Eivind Kvedalen 2016-03-04 01:00:54 +01:00 committed by wmayer
parent 34135e5d2e
commit 26f4d1ae8e
3 changed files with 22 additions and 1 deletions

View File

@ -1139,7 +1139,7 @@ void Application::initTypes(void)
App ::ConditionalExpression ::init();
App ::StringExpression ::init();
App ::FunctionExpression ::init();
App ::BooleanExpression ::init();
}
void Application::initConfig(int argc, char ** argv)

View File

@ -1262,6 +1262,18 @@ Expression *ConstantExpression::copy() const
return new ConstantExpression(owner, name.c_str(), quantity);
}
TYPESYSTEM_SOURCE_ABSTRACT(App::BooleanExpression, App::NumberExpression);
BooleanExpression::BooleanExpression(const DocumentObject *_owner, bool _value)
: NumberExpression(owner, _value ? 1.0 : 0.0)
{
}
Expression *BooleanExpression::copy() const
{
return new BooleanExpression(owner, getValue() > 0.5 ? true : false);
}
namespace App {
namespace ExpressionParser {

View File

@ -190,6 +190,15 @@ protected:
std::string name; /**< Constant's name */
};
class AppExport BooleanExpression : public NumberExpression {
TYPESYSTEM_HEADER();
public:
BooleanExpression(const App::DocumentObject *_owner = 0, bool _value = false);
virtual Expression * copy() const;
};
/**
* Class implementing an infix expression.