5#ifndef UNARYEXPRESSION_HPP
6#define UNARYEXPRESSION_HPP
13template <
template <IExpression>
class DerivedT, IExpression OperandT>
16 using DerivedSpecialized = DerivedT<OperandT>;
17 using DerivedGeneralized = DerivedT<Expression>;
42 if (!other.Is<DerivedSpecialized>()) {
47 const auto otherGeneralized = other.Generalize();
48 const auto& otherUnaryGeneralized =
dynamic_cast<const DerivedGeneralized&
>(*otherGeneralized);
50 return op->Equals(otherUnaryGeneralized.GetOperand());
55 DerivedGeneralized generalized;
57 generalized.SetOperand(*this->
op->Copy());
74 return this->
GetType() == other.GetType();
80 this->
op = operand.Copy();
89 DerivedT<Expression> comb = DerivedT<Expression> { *right };
90 auto ret = comb.Simplify();
97 const auto& derivedGeneralized =
dynamic_cast<const DerivedGeneralized&
>(*generalized);
An expression.
Definition Expression.hpp:56
virtual auto GetType() const -> ExpressionType
Gets the type of this expression.
Definition Expression.cpp:220
Definition Serialization.hpp:50
virtual void Serialize(const Real &real)=0
Definition UnaryExpression.hpp:14
auto Equals(const Expression &other) const -> bool final
Compares this expression to another expression for equality.
Definition UnaryExpression.hpp:40
UnaryExpression()=default
auto Generalize() const -> std::unique_ptr< Expression > final
Converts this expression to a more general expression.
Definition UnaryExpression.hpp:53
auto StructurallyEquivalent(const Expression &other) const -> bool final
Checks whether this expression is structurally equivalent to another expression.
Definition UnaryExpression.hpp:72
void Serialize(SerializationVisitor &visitor) const override
This function serializes the expression object.
Definition UnaryExpression.hpp:94
auto Copy() const -> std::unique_ptr< Expression > final
Copies this expression.
Definition UnaryExpression.hpp:35
UnaryExpression(const UnaryExpression &other)
Definition UnaryExpression.hpp:22
UnaryExpression(const OperandT &operand)
Definition UnaryExpression.hpp:30
auto HasOperand() const -> bool
Definition UnaryExpression.hpp:67
auto Substitute(const Expression &var, const Expression &val) -> std::unique_ptr< Expression > override
Definition UnaryExpression.hpp:86
auto GetOperand() const -> const OperandT &
Definition UnaryExpression.hpp:62
auto SetOperand(const OperandT &operand) -> void
Definition UnaryExpression.hpp:77
std::unique_ptr< OperandT > op
Definition UnaryExpression.hpp:102