Browse Source
Designed interface of expression classes and started implementing it.
Designed interface of expression classes and started implementing it.
Former-commit-id: 67ac2a1764
main
29 changed files with 822 additions and 43 deletions
-
29src/storage/expressions/BaseExpression.cpp
-
139src/storage/expressions/BaseExpression.h
-
73src/storage/expressions/BinaryBooleanFunctionExpression.cpp
-
54src/storage/expressions/BinaryBooleanFunctionExpression.h
-
47src/storage/expressions/BinaryExpression.cpp
-
60src/storage/expressions/BinaryExpression.h
-
64src/storage/expressions/BinaryNumericalFunctionExpression.cpp
-
55src/storage/expressions/BinaryNumericalFunctionExpression.h
-
50src/storage/expressions/BinaryRelationExpression.cpp
-
54src/storage/expressions/BinaryRelationExpression.h
-
9src/storage/expressions/BooleanConstantExpression.cpp
-
16src/storage/expressions/BooleanConstantExpression.h
-
13src/storage/expressions/ConstantExpression.cpp
-
20src/storage/expressions/ConstantExpression.h
-
9src/storage/expressions/DoubleConstantExpression.cpp
-
16src/storage/expressions/DoubleConstantExpression.h
-
28src/storage/expressions/Expression.h
-
8src/storage/expressions/ExpressionVisitor.h
-
9src/storage/expressions/IntegerConstantExpression.cpp
-
15src/storage/expressions/IntegerConstantExpression.h
-
9src/storage/expressions/UnaryBooleanFunctionExpression.cpp
-
21src/storage/expressions/UnaryBooleanFunctionExpression.h
-
9src/storage/expressions/UnaryExpression.cpp
-
18src/storage/expressions/UnaryExpression.h
-
9src/storage/expressions/UnaryNumericalFunctionExpression.cpp
-
21src/storage/expressions/UnaryNumericalFunctionExpression.h
-
2src/storage/expressions/Valuation.h
-
6src/storage/expressions/VariableExpression.cpp
-
2src/storage/expressions/VariableExpression.h
@ -0,0 +1,73 @@ |
|||
#include "src/storage/expressions/BinaryBooleanFunctionExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
BinaryBooleanFunctionExpression::BinaryBooleanFunctionExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& firstOperand, std::unique_ptr<BaseExpression>&& secondOperand, OperatorType operatorType) : BinaryExpression(returnType, std::move(firstOperand), std::move(secondOperand)), operatorType(operatorType) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
BinaryBooleanFunctionExpression::OperatorType BinaryBooleanFunctionExpression::getOperatorType() const { |
|||
return this->operatorType; |
|||
} |
|||
|
|||
BinaryBooleanFunctionExpression::BinaryBooleanFunctionExpression(BinaryBooleanFunctionExpression const& other) : BinaryExpression(other), operatorType(other.getOperatorType()) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
BinaryBooleanFunctionExpression& BinaryBooleanFunctionExpression::operator=(BinaryBooleanFunctionExpression const& other) { |
|||
if (this != &other) { |
|||
BinaryExpression::operator=(other); |
|||
this->operatorType = other.getOperatorType(); |
|||
} |
|||
return *this; |
|||
} |
|||
|
|||
bool BinaryBooleanFunctionExpression::evaluateAsBool(Valuation const& valuation) const { |
|||
bool firstOperandEvaluation = this->getFirstOperand()->evaluateAsBool(valuation); |
|||
bool secondOperandEvaluation = this->getSecondOperand()->evaluateAsBool(valuation); |
|||
|
|||
bool result; |
|||
switch (this->getOperatorType()) { |
|||
case AND: result = firstOperandEvaluation && secondOperandEvaluation; break; |
|||
case OR: result = firstOperandEvaluation || secondOperandEvaluation; break; |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
std::unique_ptr<BaseExpression> BinaryBooleanFunctionExpression::simplify() const { |
|||
std::unique_ptr<BaseExpression> firstOperandSimplified = this->getFirstOperand()->simplify(); |
|||
std::unique_ptr<BaseExpression> secondOperandSimplified = this->getSecondOperand()->simplify(); |
|||
|
|||
switch (this->getOperatorType()) { |
|||
case AND: if (firstOperandSimplified->isTrue()) { |
|||
return secondOperandSimplified; |
|||
} else if (firstOperandSimplified->isFalse()) { |
|||
return firstOperandSimplified; |
|||
} else if (secondOperandSimplified->isTrue()) { |
|||
return firstOperandSimplified; |
|||
} else if (secondOperandSimplified->isFalse()) { |
|||
return secondOperandSimplified; |
|||
} |
|||
break; |
|||
case OR: if (firstOperandSimplified->isTrue()) { |
|||
return firstOperandSimplified; |
|||
} else if (firstOperandSimplified->isFalse()) { |
|||
return secondOperandSimplified; |
|||
} else if (secondOperandSimplified->isTrue()) { |
|||
return secondOperandSimplified; |
|||
} else if (secondOperandSimplified->isFalse()) { |
|||
return firstOperandSimplified; |
|||
} |
|||
} |
|||
|
|||
return std::unique_ptr<BaseExpression>(new BinaryBooleanFunctionExpression(this->getReturnType(), std::move(firstOperandSimplified), std::move(secondOperandSimplified), this->getOperatorType())); |
|||
} |
|||
|
|||
void BinaryBooleanFunctionExpression::accept(ExpressionVisitor* visitor) const { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
virtual std::unique_ptr<BaseExpression> clone() const override; |
|||
} |
|||
} |
@ -0,0 +1,54 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_BINARYBOOLEANFUNCTIONEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_BINARYBOOLEANFUNCTIONEXPRESSION_H_ |
|||
|
|||
#include "src/storage/expressions/BinaryExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class BinaryBooleanFunctionExpression : public BinaryExpression { |
|||
public: |
|||
/*! |
|||
* An enum type specifying the different operators applicable. |
|||
*/ |
|||
enum OperatorType {AND, OR}; |
|||
|
|||
/*! |
|||
* Creates a binary boolean function expression with the given return type, operands and operator. |
|||
* |
|||
* @param returnType The return type of the expression. |
|||
* @param firstOperand The first operand of the expression. |
|||
* @param secondOperand The second operand of the expression. |
|||
* @param functionType The operator of the expression. |
|||
*/ |
|||
BinaryBooleanFunctionExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& fistOperand, std::unique_ptr<BaseExpression>&& secondOperand, OperatorType operatorType); |
|||
|
|||
// Provide custom versions of copy construction and assignment. |
|||
BinaryBooleanFunctionExpression(BinaryBooleanFunctionExpression const& other); |
|||
BinaryBooleanFunctionExpression& operator=(BinaryBooleanFunctionExpression const& other); |
|||
|
|||
// Create default variants of move construction/assignment and virtual destructor. |
|||
BinaryBooleanFunctionExpression(BinaryBooleanFunctionExpression&&) = default; |
|||
BinaryBooleanFunctionExpression& operator=(BinaryBooleanFunctionExpression&&) = default; |
|||
virtual ~BinaryBooleanFunctionExpression() = default; |
|||
|
|||
// Override base class methods. |
|||
virtual bool evaluateAsBool(Valuation const& valuation) const override; |
|||
virtual std::unique_ptr<BaseExpression> simplify() const override; |
|||
virtual void accept(ExpressionVisitor* visitor) const override; |
|||
virtual std::unique_ptr<BaseExpression> clone() const override; |
|||
|
|||
/*! |
|||
* Retrieves the operator associated with the expression. |
|||
* |
|||
* @return The operator associated with the expression. |
|||
*/ |
|||
OperatorType getOperatorType() const; |
|||
|
|||
private: |
|||
// The operator of the expression. |
|||
OperatorType operatorType; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_BINARYBOOLEANFUNCTIONEXPRESSION_H_ */ |
@ -0,0 +1,47 @@ |
|||
#include "src/storage/expressions/BinaryExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
BinaryExpression::BinaryExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& firstOperand, std::unique_ptr<BaseExpression>&& secondOperand) : BaseExpression(returnType), firstOperand(std::move(firstOperand)), secondOperand(std::move(secondOperand)) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
BinaryExpression::BinaryExpression(BinaryExpression const& other) : BaseExpression(other.getReturnType()), firstOperand(other.getFirstOperand()->clone()), secondOperand(other.getSecondOperand()->clone()) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
BinaryExpression& BinaryExpression::operator=(BinaryExpression const& other) { |
|||
if (this != &other) { |
|||
this->firstOperand = other.getFirstOperand()->clone(); |
|||
this->secondOperand = other.getSecondOperand()->clone(); |
|||
} |
|||
return *this; |
|||
} |
|||
|
|||
bool BinaryExpression::isConstant() const { |
|||
return this->getFirstOperand()->isConstant() && this->getSecondOperand()->isConstant(); |
|||
} |
|||
|
|||
std::set<std::string> BinaryExpression::getVariables() const { |
|||
std::set<std::string> firstVariableSet = this->getFirstOperand()->getVariables(); |
|||
std::set<std::string> secondVariableSet = this->getSecondOperand()->getVariables(); |
|||
firstVariableSet.insert(secondVariableSet.begin(), secondVariableSet.end()); |
|||
return firstVariableSet; |
|||
} |
|||
|
|||
std::set<std::string> BinaryExpression::getConstants() const { |
|||
std::set<std::string> firstConstantSet = this->getFirstOperand()->getVariables(); |
|||
std::set<std::string> secondConstantSet = this->getSecondOperand()->getVariables(); |
|||
firstConstantSet.insert(secondConstantSet.begin(), secondConstantSet.end()); |
|||
return firstConstantSet; |
|||
} |
|||
|
|||
std::unique_ptr<BaseExpression> const& BinaryExpression::getFirstOperand() const { |
|||
return this->firstOperand; |
|||
} |
|||
|
|||
std::unique_ptr<BaseExpression> const& BinaryExpression::getSecondOperand() const { |
|||
return this->secondOperand; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,60 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_BINARYEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_BINARYEXPRESSION_H_ |
|||
|
|||
#include "src/storage/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
/*! |
|||
* The base class of all binary expressions. |
|||
*/ |
|||
class BinaryExpression : public BaseExpression { |
|||
public: |
|||
/*! |
|||
* Constructs a binary expression with the given return type and operands. |
|||
* |
|||
* @param returnType The return type of the expression. |
|||
* @param firstOperand The first operand of the expression. |
|||
* @param secondOperand The second operand of the expression. |
|||
*/ |
|||
BinaryExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& firstOperand, std::unique_ptr<BaseExpression>&& secondOperand); |
|||
|
|||
// Provide custom versions of copy construction and assignment. |
|||
BinaryExpression(BinaryExpression const& other); |
|||
BinaryExpression& operator=(BinaryExpression const& other); |
|||
|
|||
// Create default variants of move construction/assignment and virtual destructor. |
|||
BinaryExpression(BinaryExpression&&) = default; |
|||
BinaryExpression& operator=(BinaryExpression&&) = default; |
|||
virtual ~BinaryExpression() = default; |
|||
|
|||
// Override base class methods. |
|||
virtual bool isConstant() const override; |
|||
virtual std::set<std::string> getVariables() const override; |
|||
virtual std::set<std::string> getConstants() const override; |
|||
|
|||
/*! |
|||
* Retrieves the first operand of the expression. |
|||
* |
|||
* @return The first operand of the expression. |
|||
*/ |
|||
std::unique_ptr<BaseExpression> const& getFirstOperand() const; |
|||
|
|||
/*! |
|||
* Retrieves the second operand of the expression. |
|||
* |
|||
* @return The second operand of the expression. |
|||
*/ |
|||
std::unique_ptr<BaseExpression> const& getSecondOperand() const; |
|||
|
|||
private: |
|||
// The first operand of the expression. |
|||
std::unique_ptr<BaseExpression> firstOperand; |
|||
|
|||
// The second operand of the expression. |
|||
std::unique_ptr<BaseExpression> secondOperand; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_BINARYEXPRESSION_H_ */ |
@ -0,0 +1,64 @@ |
|||
#include <algorithm>
|
|||
|
|||
#include "src/storage/expressions/BinaryNumericalFunctionExpression.h"
|
|||
#include "src/exceptions/ExceptionMacros.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
BinaryNumericalFunctionExpression::BinaryNumericalFunctionExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& firstOperand, std::unique_ptr<BaseExpression>&& secondOperand, OperatorType operatorType) : BinaryExpression(returnType, std::move(firstOperand), std::move(secondOperand)), operatorType(operatorType) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
BinaryNumericalFunctionExpression::BinaryNumericalFunctionExpression(BinaryNumericalFunctionExpression const& other) : BinaryExpression(other), operatorType(this->getOperatorType()) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
BinaryNumericalFunctionExpression& BinaryNumericalFunctionExpression::operator=(BinaryNumericalFunctionExpression const& other) { |
|||
if (this != &other) { |
|||
BinaryExpression::operator=(other); |
|||
this->operatorType = other.getOperatorType(); |
|||
} |
|||
return *this; |
|||
} |
|||
|
|||
int_fast64_t BinaryNumericalFunctionExpression::evaluateAsInt(Valuation const& valuation) const { |
|||
LOG_ASSERT(this->getReturnType() == ExpressionReturnType::int_, "Unable to evaluate expression as integer."); |
|||
int_fast64_t firstOperandEvaluation = this->getFirstOperand()->evaluateAsInt(valuation); |
|||
int_fast64_t secondOperandEvaluation = this->getSecondOperand()->evaluateAsInt(valuation); |
|||
switch (this->getOperatorType()) { |
|||
case PLUS: return firstOperandEvaluation + secondOperandEvaluation; break; |
|||
case MINUS: return firstOperandEvaluation - secondOperandEvaluation; break; |
|||
case TIMES: return firstOperandEvaluation * secondOperandEvaluation; break; |
|||
case DIVIDE: return firstOperandEvaluation / secondOperandEvaluation; break; |
|||
case MIN: return std::min(firstOperandEvaluation, secondOperandEvaluation); break; |
|||
case MAX: return std::max(firstOperandEvaluation, secondOperandEvaluation); break; |
|||
} |
|||
} |
|||
|
|||
double BinaryNumericalFunctionExpression::evaluateAsDouble(Valuation const& valuation) const { |
|||
LOG_ASSERT(this->getReturnType() == ExpressionReturnType::int_, "Unable to evaluate expression as integer."); |
|||
double firstOperandEvaluation = this->getFirstOperand()->evaluateAsInt(valuation); |
|||
double secondOperandEvaluation = this->getSecondOperand()->evaluateAsInt(valuation); |
|||
switch (this->getOperatorType()) { |
|||
case PLUS: return firstOperandEvaluation + secondOperandEvaluation; break; |
|||
case MINUS: return firstOperandEvaluation - secondOperandEvaluation; break; |
|||
case TIMES: return firstOperandEvaluation * secondOperandEvaluation; break; |
|||
case DIVIDE: return firstOperandEvaluation / secondOperandEvaluation; break; |
|||
case MIN: return std::min(firstOperandEvaluation, secondOperandEvaluation); break; |
|||
case MAX: return std::max(firstOperandEvaluation, secondOperandEvaluation); break; |
|||
} |
|||
} |
|||
|
|||
std::unique_ptr<BaseExpression> BinaryNumericalFunctionExpression::simplify() const { |
|||
return std::unique_ptr<BaseExpression>(new BinaryNumericalFunctionExpression(this->getReturnType(), this->getFirstOperand()->simplify(), this->getSecondOperand()->simplify(), this->getOperatorType())); |
|||
} |
|||
|
|||
void BinaryNumericalFunctionExpression::accept(ExpressionVisitor* visitor) const { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
std::unique_ptr<BaseExpression> BinaryNumericalFunctionExpression::clone() const { |
|||
return std::unique_ptr<BaseExpression>(new BinaryNumericalFunctionExpression(*this)); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,55 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_BINARYNUMERICALFUNCTIONEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_BINARYNUMERICALFUNCTIONEXPRESSION_H_ |
|||
|
|||
#include "src/storage/expressions/BinaryExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class BinaryNumericalFunctionExpression : public BinaryExpression { |
|||
public: |
|||
/*! |
|||
* An enum type specifying the different operators applicable. |
|||
*/ |
|||
enum OperatorType {PLUS, MINUS, TIMES, DIVIDE, MIN, MAX}; |
|||
|
|||
/*! |
|||
* Constructs a binary numerical function expression with the given return type, operands and operator. |
|||
* |
|||
* @param returnType The return type of the expression. |
|||
* @param firstOperand The first operand of the expression. |
|||
* @param secondOperand The second operand of the expression. |
|||
* @param functionType The operator of the expression. |
|||
*/ |
|||
BinaryNumericalFunctionExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& firstOperand, std::unique_ptr<BaseExpression>&& secondOperand, OperatorType operatorType); |
|||
|
|||
// Provide custom versions of copy construction and assignment. |
|||
BinaryNumericalFunctionExpression(BinaryNumericalFunctionExpression const& other); |
|||
BinaryNumericalFunctionExpression& operator=(BinaryNumericalFunctionExpression const& other); |
|||
|
|||
// Create default variants of move construction/assignment and virtual destructor. |
|||
BinaryNumericalFunctionExpression(BinaryNumericalFunctionExpression&&) = default; |
|||
BinaryNumericalFunctionExpression& operator=(BinaryNumericalFunctionExpression&&) = default; |
|||
virtual ~BinaryNumericalFunctionExpression() = default; |
|||
|
|||
// Override base class methods. |
|||
virtual int_fast64_t evaluateAsInt(Valuation const& valuation) const override; |
|||
virtual double evaluateAsDouble(Valuation const& valuation) const override; |
|||
virtual std::unique_ptr<BaseExpression> simplify() const override; |
|||
virtual void accept(ExpressionVisitor* visitor) const override; |
|||
virtual std::unique_ptr<BaseExpression> clone() const override; |
|||
|
|||
/*! |
|||
* Retrieves the operator associated with the expression. |
|||
* |
|||
* @return The operator associated with the expression. |
|||
*/ |
|||
OperatorType getOperatorType() const; |
|||
|
|||
private: |
|||
// The operator of the expression. |
|||
OperatorType operatorType; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_BINARYNUMERICALFUNCTIONEXPRESSION_H_ */ |
@ -0,0 +1,50 @@ |
|||
#include "src/storage/expressions/BinaryRelationExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
BinaryRelationExpression::BinaryRelationExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& firstOperand, std::unique_ptr<BaseExpression>&& secondOperand, RelationType relationType) : BinaryExpression(returnType, std::move(firstOperand), std::move(secondOperand)), relationType(relationType) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
BinaryRelationExpression::BinaryRelationExpression(BinaryRelationExpression const& other) : BinaryExpression(other), relationType(other.getRelationType()) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
BinaryRelationExpression& BinaryRelationExpression::operator=(BinaryRelationExpression const& other) { |
|||
if (this != &other) { |
|||
BinaryExpression::operator=(other); |
|||
this->relationType = other.getRelationType(); |
|||
} |
|||
return *this; |
|||
} |
|||
|
|||
bool BinaryRelationExpression::evaluateAsBool(Valuation const& valuation) const { |
|||
double firstOperandEvaluated = this->getFirstOperand()->evaluateAsDouble(valuation); |
|||
double secondOperandEvaluated = this->getSecondOperand()->evaluateAsDouble(valuation); |
|||
switch (this->getRelationType()) { |
|||
case EQUAL: return firstOperandEvaluated == secondOperandEvaluated; break; |
|||
case NOT_EQUAL: return firstOperandEvaluated != secondOperandEvaluated; break; |
|||
case GREATER: return firstOperandEvaluated > secondOperandEvaluated; break; |
|||
case GREATER_OR_EQUAL: return firstOperandEvaluated >= secondOperandEvaluated; break; |
|||
case LESS: return firstOperandEvaluated < secondOperandEvaluated; break; |
|||
case LESS_OR_EQUAL: return firstOperandEvaluated <= secondOperandEvaluated; break; |
|||
} |
|||
} |
|||
|
|||
std::unique_ptr<BaseExpression> BinaryRelationExpression::simplify() const { |
|||
return std::unique_ptr<BaseExpression>(new BinaryRelationExpression(this->getReturnType(), this->getFirstOperand()->simplify(), this->getSecondOperand()->simplify(), this->getRelationType())); |
|||
} |
|||
|
|||
void BinaryRelationExpression::accept(ExpressionVisitor* visitor) const { |
|||
visitor->visit(this); |
|||
} |
|||
|
|||
std::unique_ptr<BaseExpression> BinaryRelationExpression::clone() const { |
|||
return std::unique_ptr<BaseExpression>(new BinaryRelationExpression(*this)); |
|||
} |
|||
|
|||
BinaryRelationExpression::RelationType BinaryRelationExpression::getRelationType() const { |
|||
return this->relationType; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,54 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_BINARYRELATIONEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_BINARYRELATIONEXPRESSION_H_ |
|||
|
|||
#include "src/storage/expressions/BinaryExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class BinaryRelationExpression : public BinaryExpression { |
|||
public: |
|||
/*! |
|||
* An enum type specifying the different relations applicable. |
|||
*/ |
|||
enum RelationType {EQUAL, NOT_EQUAL, LESS, LESS_OR_EQUAL, GREATER, GREATER_OR_EQUAL}; |
|||
|
|||
/*! |
|||
* Creates a binary relation expression with the given return type, operands and relation type. |
|||
* |
|||
* @param returnType The return type of the expression. |
|||
* @param firstOperand The first operand of the expression. |
|||
* @param secondOperand The second operand of the expression. |
|||
* @param relationType The operator of the expression. |
|||
*/ |
|||
BinaryRelationExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& firstOperand, std::unique_ptr<BaseExpression>&& secondOperand, RelationType relationType); |
|||
|
|||
// Provide custom versions of copy construction and assignment. |
|||
BinaryRelationExpression(BinaryRelationExpression const& other); |
|||
BinaryRelationExpression& operator=(BinaryRelationExpression const& other); |
|||
|
|||
// Create default variants of move construction/assignment and virtual destructor. |
|||
BinaryRelationExpression(BinaryRelationExpression&&) = default; |
|||
BinaryRelationExpression& operator=(BinaryRelationExpression&&) = default; |
|||
virtual ~BinaryRelationExpression() = default; |
|||
|
|||
// Override base class methods. |
|||
virtual bool evaluateAsBool(Valuation const& valuation) const override; |
|||
virtual std::unique_ptr<BaseExpression> simplify() const override; |
|||
virtual void accept(ExpressionVisitor* visitor) const override; |
|||
virtual std::unique_ptr<BaseExpression> clone() const override; |
|||
|
|||
/*! |
|||
* Retrieves the relation associated with the expression. |
|||
* |
|||
* @return The relation associated with the expression. |
|||
*/ |
|||
RelationType getRelationType() const; |
|||
|
|||
private: |
|||
// The relation type of the expression. |
|||
RelationType relationType; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_BINARYRELATIONEXPRESSION_H_ */ |
@ -0,0 +1,9 @@ |
|||
#include "src/storage/expressions/BooleanConstantExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
BooleanConstantExpression::BooleanConstantExpression(std::string const& constantName) : ConstantExpression(ReturnType::bool_, constantName) { |
|||
// Intentionally left empty.
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_BOOLEANCONSTANTEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_BOOLEANCONSTANTEXPRESSION_H_ |
|||
|
|||
#include "src/storage/expressions/ConstantExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class BooleanConstantExpression : public ConstantExpression { |
|||
public: |
|||
BooleanConstantExpression(std::string const& constantName); |
|||
virtual ~BooleanConstantExpression() = default; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_BOOLEANCONSTANTEXPRESSION_H_ */ |
@ -0,0 +1,13 @@ |
|||
#include "src/storage/expressions/ConstantExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
ConstantExpression::ConstantExpression(ReturnType returnType, std::string const& constantName) : BaseExpression(returnType), constantName(constantName) { |
|||
// Intentionally left empty.
|
|||
} |
|||
|
|||
std::string const& ConstantExpression::getConstantName() const { |
|||
return this->constantName; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_CONSTANTEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_CONSTANTEXPRESSION_H_ |
|||
|
|||
#include "src/storage/expressions/BaseExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class ConstantExpression : public BaseExpression { |
|||
ConstantExpression(ExpressionReturnType returnType, std::string const& constantName); |
|||
virtual ~ConstantExpression() = default; |
|||
|
|||
std::string const& getConstantName() const; |
|||
|
|||
private: |
|||
std::string constantName; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_CONSTANTEXPRESSION_H_ */ |
@ -0,0 +1,9 @@ |
|||
#include "src/storage/expressions/DoubleConstantExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
DoubleConstantExpression::DoubleConstantExpression(std::string const& constantName) : ConstantExpression(ReturnType::double_, constantName) { |
|||
// Intentionally left empty.
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_DOUBLECONSTANTEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_DOUBLECONSTANTEXPRESSION_H_ |
|||
|
|||
#include "src/storage/expressions/ConstantExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class DoubleConstantExpression : public ConstantExpression { |
|||
public: |
|||
DoubleConstantExpression(std::string const& constantName); |
|||
virtual ~DoubleConstantExpression() = default; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_DOUBLECONSTANTEXPRESSION_H_ */ |
@ -1,10 +1,16 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_EXPRESSIONVISITOR_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_EXPRESSIONVISITOR_H_ |
|||
|
|||
#include "src/storage/expressions/BinaryNumericalFunctionExpression.h" |
|||
#include "src/storage/expressions/BinaryBooleanFunctionExpression.h" |
|||
#include "src/storage/expressions/BinaryRelationExpression.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class ExpressionVisitor { |
|||
|
|||
virtual void visit(BinaryBooleanFunctionExpression const* expression) = 0; |
|||
virtual void visit(BinaryNumericalFunctionExpression const* expression) = 0; |
|||
virtual void visit(BinaryRelationExpression const* expression) = 0; |
|||
}; |
|||
} |
|||
} |
|||
|
@ -0,0 +1,9 @@ |
|||
#include "src/storage/expressions/IntegerConstantExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
IntegerConstantExpression::IntegerConstantExpression(std::string const& constantName) : ConstantExpression(ReturnType::int_, constantName) { |
|||
// Intentionally left empty.
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_INTEGERCONSTANTEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_INTEGERCONSTANTEXPRESSION_H_ |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class IntegerConstantExpression : public ConstantExpression { |
|||
public: |
|||
IntegerConstantExpression(std::string const& constantName); |
|||
virtual ~IntegerConstantExpression() = default; |
|||
|
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_INTEGERCONSTANTEXPRESSION_H_ */ |
@ -0,0 +1,9 @@ |
|||
#include "src/storage/expressions/UnaryBooleanFunctionExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
UnaryBooleanFunctionExpression::UnaryBooleanFunctionExpression(ReturnType returnType, std::unique_ptr<BaseExpression>&& argument, FunctionType functionType) : UnaryExpression(returnType, std::move(argument)), functionType(functionType) { |
|||
// Intentionally left empty.
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_UNARYBOOLEANFUNCTIONEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_UNARYBOOLEANFUNCTIONEXPRESSION_H_ |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class UnaryBooleanFunctionExpression : public UnaryExpression { |
|||
/*! |
|||
* An enum type specifying the different functions applicable. |
|||
*/ |
|||
enum FunctionType {NOT}; |
|||
|
|||
UnaryBooleanFunctionExpression(ReturnType returnType, std::unique_ptr<BaseExpression>&& argument, FunctionType functionType); |
|||
virtual ~UnaryBooleanFunctionExpression() = default; |
|||
|
|||
private: |
|||
FunctionType FunctionType; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_UNARYBOOLEANFUNCTIONEXPRESSION_H_ */ |
@ -0,0 +1,9 @@ |
|||
#include "src/storage/expressions/UnaryExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
UnaryExpression::UnaryExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& argument) : BaseExpression(returnType), argument(std::move(argument)) { |
|||
// Intentionally left empty.
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_UNARYEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_UNARYEXPRESSION_H_ |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class UnaryExpression : public BaseExpression { |
|||
public: |
|||
UnaryExpression(ExpressionReturnType returnType, std::unique_ptr<BaseExpression>&& argument); |
|||
virtual ~UnaryExpression() = default; |
|||
|
|||
std::unique_ptr<BaseExpression> const& getArgument() const; |
|||
private: |
|||
std::unique_ptr<BaseExpression> argument; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_UNARYEXPRESSION_H_ */ |
@ -0,0 +1,9 @@ |
|||
#include "src/storage/expressions/UnaryNumericalFunctionExpression.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
UnaryNumericalFunctionExpression::UnaryNumericalFunctionExpression(ReturnType returnType, std::unique_ptr<BaseExpression>&& argument, FunctionType functionType) : UnaryExpression(returnType, std::move(argument)), functionType(functionType) { |
|||
// Intentionally left empty.
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,21 @@ |
|||
#ifndef STORM_STORAGE_EXPRESSIONS_UNARYNUMERICALFUNCTIONEXPRESSION_H_ |
|||
#define STORM_STORAGE_EXPRESSIONS_UNARYNUMERICALFUNCTIONEXPRESSION_H_ |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
class UnaryNumericalFunctionExpression : public UnaryExpression { |
|||
/*! |
|||
* An enum type specifying the different functions applicable. |
|||
*/ |
|||
enum FunctionType {MINUS, FLOOR, CEIL}; |
|||
|
|||
UnaryNumericalFunctionExpression(ReturnType returnType, std::unique_ptr<BaseExpression>&& argument, FunctionType functionType); |
|||
virtual ~UnaryNumericalFunctionExpression() = default; |
|||
|
|||
private: |
|||
FunctionType FunctionType; |
|||
}; |
|||
} |
|||
} |
|||
|
|||
#endif /* STORM_STORAGE_EXPRESSIONS_UNARYNUMERICALFUNCTIONEXPRESSION_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue