Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
IfThenElseExpression.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace storm {
7namespace expressions {
9 public:
18 IfThenElseExpression(ExpressionManager const& manager, Type const& type, std::shared_ptr<BaseExpression const> const& condition,
19 std::shared_ptr<BaseExpression const> const& thenExpression, std::shared_ptr<BaseExpression const> const& elseExpression);
20
21 // Instantiate constructors and assignments with their default implementations.
26
27 virtual ~IfThenElseExpression() = default;
28
29 // Override base class methods.
30 virtual std::shared_ptr<BaseExpression const> getOperand(uint_fast64_t operandIndex) const override;
31 virtual OperatorType getOperator() const override;
32 virtual bool isFunctionApplication() const override;
33 virtual bool containsVariables() const override;
34 virtual uint_fast64_t getArity() const override;
35 virtual bool evaluateAsBool(Valuation const* valuation = nullptr) const override;
36 virtual int_fast64_t evaluateAsInt(Valuation const* valuation = nullptr) const override;
37 virtual double evaluateAsDouble(Valuation const* valuation = nullptr) const override;
38 virtual void gatherVariables(std::set<storm::expressions::Variable>& variables) const override;
39 virtual std::shared_ptr<BaseExpression const> simplify() const override;
40 virtual boost::any accept(ExpressionVisitor& visitor, boost::any const& data) const override;
41 virtual bool isIfThenElseExpression() const override;
42
48 std::shared_ptr<BaseExpression const> getCondition() const;
49
55 std::shared_ptr<BaseExpression const> getThenExpression() const;
56
62 std::shared_ptr<BaseExpression const> getElseExpression() const;
63
64 protected:
65 // Override base class method.
66 virtual void printToStream(std::ostream& stream) const override;
67
68 private:
69 // The condition of the if-then-else.
70 std::shared_ptr<BaseExpression const> condition;
71
72 // The return expression of the if-part.
73 std::shared_ptr<BaseExpression const> thenExpression;
74
75 // The return expression of the else-part.
76 std::shared_ptr<BaseExpression const> elseExpression;
77};
78} // namespace expressions
79} // namespace storm
BaseExpression(ExpressionManager const &manager, Type const &type)
Constructs a base expression with the given return type.
This class is responsible for managing a set of typed variables and all expressions using these varia...
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
std::shared_ptr< BaseExpression const > getElseExpression() const
Retrieves the else expression of the if-then-else expression.
IfThenElseExpression(ExpressionManager const &manager, Type const &type, std::shared_ptr< BaseExpression const > const &condition, std::shared_ptr< BaseExpression const > const &thenExpression, std::shared_ptr< BaseExpression const > const &elseExpression)
Creates an if-then-else expression with the given return type, condition and operands.
virtual bool isIfThenElseExpression() const override
IfThenElseExpression & operator=(IfThenElseExpression &&)=delete
virtual bool evaluateAsBool(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
virtual uint_fast64_t getArity() const override
Returns the arity of the expression.
virtual int_fast64_t evaluateAsInt(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
virtual bool isFunctionApplication() const override
Checks if the expression is a function application (of any sort).
virtual bool containsVariables() const override
Retrieves whether the expression contains a variable.
std::shared_ptr< BaseExpression const > getCondition() const
Retrieves the condition expression of the if-then-else expression.
virtual OperatorType getOperator() const override
Retrieves the operator of a function application.
virtual double evaluateAsDouble(Valuation const *valuation=nullptr) const override
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
IfThenElseExpression(IfThenElseExpression const &other)=default
virtual std::shared_ptr< BaseExpression const > simplify() const override
Simplifies the expression according to some simple rules.
virtual void printToStream(std::ostream &stream) const override
Prints the expression to the given stream.
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const override
Accepts the given visitor by calling its visit method.
IfThenElseExpression(IfThenElseExpression &&)=default
virtual void gatherVariables(std::set< storm::expressions::Variable > &variables) const override
Retrieves the set of all variables that appear in the expression.
IfThenElseExpression & operator=(IfThenElseExpression const &other)=delete
std::shared_ptr< BaseExpression const > getThenExpression() const
Retrieves the then expression of the if-then-else expression.
The base class of all valuations of variables.
Definition Valuation.h:15