Skip to content

Commit

Permalink
Expressions: Added App::BooleanExpression class.
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindkv authored and wwmayer committed Mar 8, 2016
1 parent 34135e5 commit 26f4d1a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/App/Application.cpp
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions src/App/Expression.cpp
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions src/App/Expression.h
Expand Up @@ -190,6 +190,15 @@ class AppExport ConstantExpression : public NumberExpression {
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.
Expand Down

0 comments on commit 26f4d1a

Please sign in to comment.