diff --git a/include/dlplan/core.h b/include/dlplan/core.h index 54ac317d..1018ca2e 100644 --- a/include/dlplan/core.h +++ b/include/dlplan/core.h @@ -709,80 +709,89 @@ class State { }; -/// @brief Represents the abstract base class of an element with functionality -/// for computing string representations and its complexity. +/// @brief Represents the abstract base class of an object +/// with functionality for computing string representations. template -class BaseElement { +class Base { protected: - std::shared_ptr m_vocabulary_info; - ElementIndex m_index; - /** - * if true then element is evaluated per instance rather than per state. - */ - bool m_is_static; + int m_index; - BaseElement(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) - : m_vocabulary_info(vocabulary_info), m_index(index), m_is_static(is_static) { } + Base(int index) : m_index(index) { } public: - ~BaseElement() { } + ~Base() { } - bool operator==(const Derived& other) const { - return static_cast(this)->operator==(other); + bool operator==(const Base& other) const { + return static_cast(this)->are_equal_impl(static_cast(other)); } - bool operator<(const Derived& other) const { + bool operator<(const Base& other) const { return m_index < other.m_index; } - /// @brief Computes a hash value for this element. - /// @return - size_t hash() const { + /// @brief Computes a hash value for this object. + size_t hash() const { return static_cast(this)->hash_impl(); } - /// @brief Compute the canonical string representation of this element. - /// @return The canonical string representation of this element. + /// @brief Compute a canonical string representation of this object. std::string compute_repr() const { - std::stringstream ss; + std::stringstream ss; compute_repr(ss); return ss.str(); } - /// @brief Helper function to compute the canonical string representation of this element. + /// @brief Overload of the output stream insertion operator (operator<<). + friend std::ostream& operator<<(std::ostream& os, const Base& element) { + os << element.str(); + return os; + } + + /// @brief Compute a canonical string representation of this object. void compute_repr(std::stringstream& out) const { static_cast(this)->compute_repr_impl(out); } + /// @brief Compute a string representation of this object. + std::string str() const { + return static_cast(this)->str_impl(); + } + + /* Getters. */ + int get_index() const { return m_index; } +}; + + +template +class BaseElement : public Base { +protected: + std::shared_ptr m_vocabulary_info; + bool m_is_static; + +public: + BaseElement(int index, std::shared_ptr vocabulary_info, bool is_static) + : Base(index), m_vocabulary_info(vocabulary_info), m_is_static(is_static) { } + + ~BaseElement() { } + /// @brief Returns the complexity of the element /// measured in the size of the abstract syntax tree. - /// @return An integer that represents the number of element constructors in the represenation. int compute_complexity() const { return static_cast(this)->compute_complexity_impl(); } /// @brief Computes a time score for evaluating this element relative to other elements. /// The scoring assumes evaluation that uses caching. - /// @return An integer that represents the score. int compute_evaluate_time_score() const { return static_cast(this)->compute_evaluate_time_score_impl(); } - /// @brief Overload of the output stream insertion operator (operator<<) for the BaseElement class. - /// Outputs a string representation of a BaseElement object to the specified output stream. - /// @param os The output stream to write the string representation to. - /// @param denotation The BaseElement to be represented as a string. - /// @return A reference to the output stream after writing the string representation. - friend std::ostream& operator<<(std::ostream& os, const BaseElement& element) { - os << element.compute_repr(); - return os; + // For elements we simply return repr as a string representation. + std::string str_impl() const { + return Base::compute_repr(); } - /// @brief Compute a string representation of this element. - /// @return A string representation of this element. - std::string str() const { return compute_repr(); } - - ElementIndex get_index() const { return m_index; } + /* Getters. */ std::shared_ptr get_vocabulary_info() const { return m_vocabulary_info; } bool is_static() const { return m_is_static; } }; @@ -804,8 +813,7 @@ class Concept : public BaseElement { Concept& operator=(Concept&& other); ~Concept(); - virtual bool operator==(const Concept& other) const = 0; - + virtual bool are_equal_impl(const Concept& other) const = 0; virtual size_t hash_impl() const = 0; virtual void compute_repr_impl(std::stringstream& out) const = 0; virtual int compute_complexity_impl() const = 0; @@ -833,8 +841,7 @@ class Role : public BaseElement { Role& operator=(Role&& other); ~Role(); - virtual bool operator==(const Role& other) const = 0; - + virtual bool are_equal_impl(const Role& other) const = 0; virtual size_t hash_impl() const = 0; virtual void compute_repr_impl(std::stringstream& out) const = 0; virtual int compute_complexity_impl() const = 0; @@ -862,8 +869,7 @@ class Numerical : public BaseElement { Numerical& operator=(Numerical&& other); ~Numerical(); - virtual bool operator==(const Numerical& other) const = 0; - + virtual bool are_equal_impl(const Numerical& other) const = 0; virtual size_t hash_impl() const = 0; virtual void compute_repr_impl(std::stringstream& out) const = 0; virtual int compute_complexity_impl() const = 0; @@ -891,8 +897,7 @@ class Boolean : public BaseElement { Boolean& operator=(Boolean&& other); ~Boolean(); - virtual bool operator==(const Boolean& other) const = 0; - + virtual bool are_equal_impl(const Boolean& other) const = 0; virtual size_t hash_impl() const = 0; virtual void compute_repr_impl(std::stringstream& out) const = 0; virtual int compute_complexity_impl() const = 0; diff --git a/include/dlplan/core/elements/booleans/empty.h b/include/dlplan/core/elements/booleans/empty.h index bcc5c64b..36fa506f 100644 --- a/include/dlplan/core/elements/booleans/empty.h +++ b/include/dlplan/core/elements/booleans/empty.h @@ -58,7 +58,7 @@ class EmptyBoolean : public Boolean { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Boolean& other) const override { + bool are_equal_impl(const Boolean& other) const override { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast&>(other); return m_is_static == other_derived.m_is_static diff --git a/include/dlplan/core/elements/booleans/inclusion.h b/include/dlplan/core/elements/booleans/inclusion.h index fccaa8dd..adc888c1 100644 --- a/include/dlplan/core/elements/booleans/inclusion.h +++ b/include/dlplan/core/elements/booleans/inclusion.h @@ -64,7 +64,7 @@ class InclusionBoolean : public Boolean { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Boolean& other) const override { + bool are_equal_impl(const Boolean& other) const override { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast&>(other); return m_is_static == other_derived.m_is_static diff --git a/include/dlplan/core/elements/booleans/nullary.h b/include/dlplan/core/elements/booleans/nullary.h index e23437b8..52a0fd22 100644 --- a/include/dlplan/core/elements/booleans/nullary.h +++ b/include/dlplan/core/elements/booleans/nullary.h @@ -34,7 +34,7 @@ class NullaryBoolean : public Boolean { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Boolean& other) const override; + bool are_equal_impl(const Boolean& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/all.h b/include/dlplan/core/elements/concepts/all.h index 62ad8d26..bd70e802 100644 --- a/include/dlplan/core/elements/concepts/all.h +++ b/include/dlplan/core/elements/concepts/all.h @@ -34,7 +34,7 @@ class AllConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/and.h b/include/dlplan/core/elements/concepts/and.h index be9121ca..1af77677 100644 --- a/include/dlplan/core/elements/concepts/and.h +++ b/include/dlplan/core/elements/concepts/and.h @@ -36,7 +36,7 @@ class AndConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/bot.h b/include/dlplan/core/elements/concepts/bot.h index 97997d99..16fcaab8 100644 --- a/include/dlplan/core/elements/concepts/bot.h +++ b/include/dlplan/core/elements/concepts/bot.h @@ -29,7 +29,7 @@ class BotConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/diff.h b/include/dlplan/core/elements/concepts/diff.h index b5168dcb..852b7f55 100644 --- a/include/dlplan/core/elements/concepts/diff.h +++ b/include/dlplan/core/elements/concepts/diff.h @@ -33,7 +33,7 @@ class DiffConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/equal.h b/include/dlplan/core/elements/concepts/equal.h index 910dc236..41dcbb68 100644 --- a/include/dlplan/core/elements/concepts/equal.h +++ b/include/dlplan/core/elements/concepts/equal.h @@ -34,7 +34,7 @@ class EqualConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/not.h b/include/dlplan/core/elements/concepts/not.h index cb0674ca..b1810f6b 100644 --- a/include/dlplan/core/elements/concepts/not.h +++ b/include/dlplan/core/elements/concepts/not.h @@ -33,7 +33,7 @@ class NotConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/one_of.h b/include/dlplan/core/elements/concepts/one_of.h index a0140b5b..586a4e29 100644 --- a/include/dlplan/core/elements/concepts/one_of.h +++ b/include/dlplan/core/elements/concepts/one_of.h @@ -34,7 +34,7 @@ class OneOfConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/or.h b/include/dlplan/core/elements/concepts/or.h index 76215e1d..d9568818 100644 --- a/include/dlplan/core/elements/concepts/or.h +++ b/include/dlplan/core/elements/concepts/or.h @@ -34,7 +34,7 @@ class OrConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/primitive.h b/include/dlplan/core/elements/concepts/primitive.h index d4fa0bb3..6f9195ab 100644 --- a/include/dlplan/core/elements/concepts/primitive.h +++ b/include/dlplan/core/elements/concepts/primitive.h @@ -35,7 +35,7 @@ class PrimitiveConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/projection.h b/include/dlplan/core/elements/concepts/projection.h index deacdcc8..72c76ca4 100644 --- a/include/dlplan/core/elements/concepts/projection.h +++ b/include/dlplan/core/elements/concepts/projection.h @@ -34,7 +34,7 @@ class ProjectionConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/some.h b/include/dlplan/core/elements/concepts/some.h index 1200011d..4f3ea4e1 100644 --- a/include/dlplan/core/elements/concepts/some.h +++ b/include/dlplan/core/elements/concepts/some.h @@ -33,7 +33,7 @@ class SomeConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/subset.h b/include/dlplan/core/elements/concepts/subset.h index 7d3ad3fc..fd418ff5 100644 --- a/include/dlplan/core/elements/concepts/subset.h +++ b/include/dlplan/core/elements/concepts/subset.h @@ -33,7 +33,7 @@ class SubsetConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/concepts/top.h b/include/dlplan/core/elements/concepts/top.h index 58d3903c..3c604867 100644 --- a/include/dlplan/core/elements/concepts/top.h +++ b/include/dlplan/core/elements/concepts/top.h @@ -29,7 +29,7 @@ class TopConcept : public Concept { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Concept& other) const override; + bool are_equal_impl(const Concept& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/numericals/concept_distance.h b/include/dlplan/core/elements/numericals/concept_distance.h index 61d933e8..727fccf6 100644 --- a/include/dlplan/core/elements/numericals/concept_distance.h +++ b/include/dlplan/core/elements/numericals/concept_distance.h @@ -34,7 +34,7 @@ class ConceptDistanceNumerical : public Numerical { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Numerical& other) const override; + bool are_equal_impl(const Numerical& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/numericals/count.h b/include/dlplan/core/elements/numericals/count.h index da8b5cff..8dfe9fe2 100644 --- a/include/dlplan/core/elements/numericals/count.h +++ b/include/dlplan/core/elements/numericals/count.h @@ -63,7 +63,7 @@ class CountNumerical : public Numerical { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Numerical& other) const override { + bool are_equal_impl(const Numerical& other) const override { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/include/dlplan/core/elements/numericals/role_distance.h b/include/dlplan/core/elements/numericals/role_distance.h index 2b83a14b..8f1e3113 100644 --- a/include/dlplan/core/elements/numericals/role_distance.h +++ b/include/dlplan/core/elements/numericals/role_distance.h @@ -34,7 +34,7 @@ class RoleDistanceNumerical : public Numerical { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Numerical& other) const override; + bool are_equal_impl(const Numerical& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/numericals/sum_concept_distance.h b/include/dlplan/core/elements/numericals/sum_concept_distance.h index 5fb1f1aa..650c9048 100644 --- a/include/dlplan/core/elements/numericals/sum_concept_distance.h +++ b/include/dlplan/core/elements/numericals/sum_concept_distance.h @@ -34,7 +34,7 @@ class SumConceptDistanceNumerical : public Numerical { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Numerical& other) const override; + bool are_equal_impl(const Numerical& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/numericals/sum_role_distance.h b/include/dlplan/core/elements/numericals/sum_role_distance.h index f73b145f..b9912bb5 100644 --- a/include/dlplan/core/elements/numericals/sum_role_distance.h +++ b/include/dlplan/core/elements/numericals/sum_role_distance.h @@ -35,7 +35,7 @@ class SumRoleDistanceNumerical : public Numerical { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Numerical& other) const override; + bool are_equal_impl(const Numerical& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/and.h b/include/dlplan/core/elements/roles/and.h index 51a74ef6..2285ed55 100644 --- a/include/dlplan/core/elements/roles/and.h +++ b/include/dlplan/core/elements/roles/and.h @@ -33,7 +33,7 @@ class AndRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/compose.h b/include/dlplan/core/elements/roles/compose.h index b9b01fad..d4145916 100644 --- a/include/dlplan/core/elements/roles/compose.h +++ b/include/dlplan/core/elements/roles/compose.h @@ -33,7 +33,7 @@ class ComposeRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/diff.h b/include/dlplan/core/elements/roles/diff.h index 83f11e97..80792e5a 100644 --- a/include/dlplan/core/elements/roles/diff.h +++ b/include/dlplan/core/elements/roles/diff.h @@ -35,7 +35,7 @@ class DiffRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/identity.h b/include/dlplan/core/elements/roles/identity.h index d41529eb..48fa3070 100644 --- a/include/dlplan/core/elements/roles/identity.h +++ b/include/dlplan/core/elements/roles/identity.h @@ -33,7 +33,7 @@ class IdentityRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/inverse.h b/include/dlplan/core/elements/roles/inverse.h index 57755480..0d75b3aa 100644 --- a/include/dlplan/core/elements/roles/inverse.h +++ b/include/dlplan/core/elements/roles/inverse.h @@ -33,7 +33,7 @@ class InverseRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/not.h b/include/dlplan/core/elements/roles/not.h index 5250fd8b..f243a524 100644 --- a/include/dlplan/core/elements/roles/not.h +++ b/include/dlplan/core/elements/roles/not.h @@ -33,7 +33,7 @@ class NotRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/or.h b/include/dlplan/core/elements/roles/or.h index ed467507..4041314c 100644 --- a/include/dlplan/core/elements/roles/or.h +++ b/include/dlplan/core/elements/roles/or.h @@ -33,7 +33,7 @@ class OrRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/primitive.h b/include/dlplan/core/elements/roles/primitive.h index 433234a3..6818e047 100644 --- a/include/dlplan/core/elements/roles/primitive.h +++ b/include/dlplan/core/elements/roles/primitive.h @@ -33,7 +33,7 @@ class PrimitiveRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; RoleDenotation evaluate(const State& state) const override; diff --git a/include/dlplan/core/elements/roles/restrict.h b/include/dlplan/core/elements/roles/restrict.h index 4bbf494e..287fddc5 100644 --- a/include/dlplan/core/elements/roles/restrict.h +++ b/include/dlplan/core/elements/roles/restrict.h @@ -33,7 +33,7 @@ class RestrictRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/top.h b/include/dlplan/core/elements/roles/top.h index 421cf71a..6376edeb 100644 --- a/include/dlplan/core/elements/roles/top.h +++ b/include/dlplan/core/elements/roles/top.h @@ -29,7 +29,7 @@ class TopRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/transitive_closure.h b/include/dlplan/core/elements/roles/transitive_closure.h index c2de2126..4c553866 100644 --- a/include/dlplan/core/elements/roles/transitive_closure.h +++ b/include/dlplan/core/elements/roles/transitive_closure.h @@ -34,7 +34,7 @@ class TransitiveClosureRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/include/dlplan/core/elements/roles/transitive_reflexive_closure.h b/include/dlplan/core/elements/roles/transitive_reflexive_closure.h index ce3267e2..15700333 100644 --- a/include/dlplan/core/elements/roles/transitive_reflexive_closure.h +++ b/include/dlplan/core/elements/roles/transitive_reflexive_closure.h @@ -32,7 +32,7 @@ class TransitiveReflexiveClosureRole : public Role { friend class dlplan::ReferenceCountedObjectFactory; public: - bool operator==(const Role& other) const override; + bool are_equal_impl(const Role& other) const override; size_t hash_impl() const override; diff --git a/src/core/boolean.cpp b/src/core/boolean.cpp index 60604591..90bcb30f 100644 --- a/src/core/boolean.cpp +++ b/src/core/boolean.cpp @@ -3,7 +3,7 @@ namespace dlplan::core { Boolean::Boolean(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) - : BaseElement(vocabulary_info, index, is_static) { + : BaseElement(index, vocabulary_info, is_static) { } Boolean::Boolean(const Boolean& other) = default; diff --git a/src/core/concept.cpp b/src/core/concept.cpp index a1480be7..ecde168f 100644 --- a/src/core/concept.cpp +++ b/src/core/concept.cpp @@ -4,7 +4,7 @@ namespace dlplan::core { Concept::Concept(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) - : BaseElement(vocabulary_info, index, is_static) { + : BaseElement(index, vocabulary_info, is_static) { } Concept::Concept(const Concept& other) = default; diff --git a/src/core/elements/booleans/nullary.cpp b/src/core/elements/booleans/nullary.cpp index b5b57ccd..77b2e1c6 100644 --- a/src/core/elements/booleans/nullary.cpp +++ b/src/core/elements/booleans/nullary.cpp @@ -41,7 +41,7 @@ NullaryBoolean::NullaryBoolean(ElementIndex index, std::shared_ptr(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/all.cpp b/src/core/elements/concepts/all.cpp index 13650fbd..a64c0915 100644 --- a/src/core/elements/concepts/all.cpp +++ b/src/core/elements/concepts/all.cpp @@ -40,7 +40,7 @@ ConceptDenotations AllConcept::evaluate_impl(const States& states, DenotationsCa AllConcept::AllConcept(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role, std::shared_ptr concept) : Concept(vocabulary_info, index, role->is_static() && concept->is_static()), m_role(role), m_concept(concept) { } -bool AllConcept::operator==(const Concept& other) const { +bool AllConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/and.cpp b/src/core/elements/concepts/and.cpp index e7e95a62..ebd5ba7e 100644 --- a/src/core/elements/concepts/and.cpp +++ b/src/core/elements/concepts/and.cpp @@ -38,7 +38,7 @@ AndConcept::AndConcept(ElementIndex index, std::shared_ptr vocab m_concept_left(concept_1->get_index() < concept_2->get_index() ? concept_1 : concept_2), m_concept_right(concept_1->get_index() < concept_2->get_index() ? concept_2 : concept_1) { } -bool AndConcept::operator==(const Concept& other) const { +bool AndConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/bot.cpp b/src/core/elements/concepts/bot.cpp index ebff12d8..3dadc3a1 100644 --- a/src/core/elements/concepts/bot.cpp +++ b/src/core/elements/concepts/bot.cpp @@ -19,7 +19,7 @@ ConceptDenotations BotConcept::evaluate_impl(const States& states, DenotationsCa BotConcept::BotConcept(ElementIndex index, std::shared_ptr vocabulary_info) : Concept(vocabulary_info, index, true) { } -bool BotConcept::operator==(const Concept& other) const { +bool BotConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static; diff --git a/src/core/elements/concepts/diff.cpp b/src/core/elements/concepts/diff.cpp index 74305b2f..f2865c95 100644 --- a/src/core/elements/concepts/diff.cpp +++ b/src/core/elements/concepts/diff.cpp @@ -35,7 +35,7 @@ ConceptDenotations DiffConcept::evaluate_impl(const States& states, DenotationsC DiffConcept::DiffConcept(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr concept_1, std::shared_ptr concept_2) : Concept(vocabulary_info, index, concept_1->is_static() && concept_2->is_static()), m_concept_left(concept_1), m_concept_right(concept_2) { } -bool DiffConcept::operator==(const Concept& other) const { +bool DiffConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/equal.cpp b/src/core/elements/concepts/equal.cpp index e1785c84..73c4535b 100644 --- a/src/core/elements/concepts/equal.cpp +++ b/src/core/elements/concepts/equal.cpp @@ -43,7 +43,7 @@ EqualConcept::EqualConcept(ElementIndex index, std::shared_ptr v : Concept(vocabulary_info, index, role_left->is_static() && role_right->is_static()), m_role_left(role_left), m_role_right(role_right) { } -bool EqualConcept::operator==(const Concept& other) const { +bool EqualConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/not.cpp b/src/core/elements/concepts/not.cpp index aa9f15f9..86ee4c42 100644 --- a/src/core/elements/concepts/not.cpp +++ b/src/core/elements/concepts/not.cpp @@ -34,7 +34,7 @@ ConceptDenotations NotConcept::evaluate_impl(const States& states, DenotationsCa NotConcept::NotConcept(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr concept) : Concept(vocabulary_info, index, concept->is_static()), m_concept(concept){ } -bool NotConcept::operator==(const Concept& other) const { +bool NotConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/one_of.cpp b/src/core/elements/concepts/one_of.cpp index 0eda6ed2..9fa8dea5 100644 --- a/src/core/elements/concepts/one_of.cpp +++ b/src/core/elements/concepts/one_of.cpp @@ -40,7 +40,7 @@ ConceptDenotations OneOfConcept::evaluate_impl(const States& states, Denotations OneOfConcept::OneOfConcept(ElementIndex index, std::shared_ptr vocabulary_info, const Constant& constant) : Concept(vocabulary_info, index, true), m_constant(constant) { } -bool OneOfConcept::operator==(const Concept& other) const { +bool OneOfConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/or.cpp b/src/core/elements/concepts/or.cpp index 5ccfaf3a..7be034e8 100644 --- a/src/core/elements/concepts/or.cpp +++ b/src/core/elements/concepts/or.cpp @@ -38,7 +38,7 @@ OrConcept::OrConcept(ElementIndex index, std::shared_ptr vocabul m_concept_left(concept_1->get_index() < concept_2->get_index() ? concept_1 : concept_2), m_concept_right(concept_1->get_index() < concept_2->get_index() ? concept_2 : concept_1) { } -bool OrConcept::operator==(const Concept& other) const { +bool OrConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/primitive.cpp b/src/core/elements/concepts/primitive.cpp index 4d6befa8..dafdc536 100644 --- a/src/core/elements/concepts/primitive.cpp +++ b/src/core/elements/concepts/primitive.cpp @@ -50,7 +50,7 @@ PrimitiveConcept::PrimitiveConcept(ElementIndex index, std::shared_ptr(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/projection.cpp b/src/core/elements/concepts/projection.cpp index 441b7313..b291d30d 100644 --- a/src/core/elements/concepts/projection.cpp +++ b/src/core/elements/concepts/projection.cpp @@ -38,7 +38,7 @@ ProjectionConcept::ProjectionConcept(ElementIndex index, std::shared_ptr(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/some.cpp b/src/core/elements/concepts/some.cpp index bbe4d574..03c20e30 100644 --- a/src/core/elements/concepts/some.cpp +++ b/src/core/elements/concepts/some.cpp @@ -39,7 +39,7 @@ ConceptDenotations SomeConcept::evaluate_impl(const States& states, DenotationsC SomeConcept::SomeConcept(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role, std::shared_ptr concept) : Concept(vocabulary_info, index, role->is_static() && concept->is_static()), m_role(role), m_concept(concept) { } -bool SomeConcept::operator==(const Concept& other) const { +bool SomeConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/subset.cpp b/src/core/elements/concepts/subset.cpp index c462065d..47920a5b 100644 --- a/src/core/elements/concepts/subset.cpp +++ b/src/core/elements/concepts/subset.cpp @@ -39,7 +39,7 @@ ConceptDenotations SubsetConcept::evaluate_impl(const States& states, Denotation SubsetConcept::SubsetConcept(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role_left, std::shared_ptr role_right) : Concept(vocabulary_info, index, role_left->is_static() && role_right->is_static()), m_role_left(role_left), m_role_right(role_right) { } -bool SubsetConcept::operator==(const Concept& other) const { +bool SubsetConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/concepts/top.cpp b/src/core/elements/concepts/top.cpp index d1a6daf0..ed2335f9 100644 --- a/src/core/elements/concepts/top.cpp +++ b/src/core/elements/concepts/top.cpp @@ -23,7 +23,7 @@ TopConcept::TopConcept(ElementIndex index, std::shared_ptr vocab : Concept(vocabulary_info, index, true) { } -bool TopConcept::operator==(const Concept& other) const { +bool TopConcept::are_equal_impl(const Concept& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static; diff --git a/src/core/elements/numericals/concept_distance.cpp b/src/core/elements/numericals/concept_distance.cpp index b1de40b2..9759d9b3 100644 --- a/src/core/elements/numericals/concept_distance.cpp +++ b/src/core/elements/numericals/concept_distance.cpp @@ -61,7 +61,7 @@ ConceptDistanceNumerical::ConceptDistanceNumerical(ElementIndex index, std::shar : Numerical(vocabulary_info, index, concept_from->is_static() && role->is_static() && concept_to->is_static()), m_concept_from(concept_from), m_role(role), m_concept_to(concept_to) { } -bool ConceptDistanceNumerical::operator==(const Numerical& other) const { +bool ConceptDistanceNumerical::are_equal_impl(const Numerical& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/numericals/role_distance.cpp b/src/core/elements/numericals/role_distance.cpp index baea3a49..7e2f71e3 100644 --- a/src/core/elements/numericals/role_distance.cpp +++ b/src/core/elements/numericals/role_distance.cpp @@ -64,7 +64,7 @@ RoleDistanceNumerical::RoleDistanceNumerical(ElementIndex index, std::shared_ptr : Numerical(vocabulary_info, index, role_from->is_static() && role->is_static() && role_to->is_static()), m_role_from(role_from), m_role(role), m_role_to(role_to) { } -bool RoleDistanceNumerical::operator==(const Numerical& other) const { +bool RoleDistanceNumerical::are_equal_impl(const Numerical& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/numericals/sum_concept_distance.cpp b/src/core/elements/numericals/sum_concept_distance.cpp index 94f5f714..79135c78 100644 --- a/src/core/elements/numericals/sum_concept_distance.cpp +++ b/src/core/elements/numericals/sum_concept_distance.cpp @@ -61,7 +61,7 @@ SumConceptDistanceNumerical::SumConceptDistanceNumerical(ElementIndex index, std : Numerical(vocabulary_info, index, concept_from->is_static() && role->is_static() && concept_to->is_static()), m_concept_from(concept_from), m_role(role), m_concept_to(concept_to) { } -bool SumConceptDistanceNumerical::operator==(const Numerical& other) const { +bool SumConceptDistanceNumerical::are_equal_impl(const Numerical& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/numericals/sum_role_distance.cpp b/src/core/elements/numericals/sum_role_distance.cpp index af9c85a0..56dbca4d 100644 --- a/src/core/elements/numericals/sum_role_distance.cpp +++ b/src/core/elements/numericals/sum_role_distance.cpp @@ -66,7 +66,7 @@ SumRoleDistanceNumerical::SumRoleDistanceNumerical(ElementIndex index, std::shar : Numerical(vocabulary_info, index, role_from->is_static() && role->is_static() && role_to->is_static()), m_role_from(role_from), m_role(role), m_role_to(role_to) { } -bool SumRoleDistanceNumerical::operator==(const Numerical& other) const { +bool SumRoleDistanceNumerical::are_equal_impl(const Numerical& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/and.cpp b/src/core/elements/roles/and.cpp index d50a2490..4f9f0d57 100644 --- a/src/core/elements/roles/and.cpp +++ b/src/core/elements/roles/and.cpp @@ -38,7 +38,7 @@ AndRole::AndRole(ElementIndex index, std::shared_ptr vocabulary_ m_role_left(role_1->get_index() < role_2->get_index() ? role_1 : role_2), m_role_right(role_1->get_index() < role_2->get_index() ? role_2 : role_1) { } -bool AndRole::operator==(const Role& other) const { +bool AndRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/compose.cpp b/src/core/elements/roles/compose.cpp index 789a6536..b7a606f1 100644 --- a/src/core/elements/roles/compose.cpp +++ b/src/core/elements/roles/compose.cpp @@ -43,7 +43,7 @@ RoleDenotations ComposeRole::evaluate_impl(const States& states, DenotationsCach ComposeRole::ComposeRole(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role_left, std::shared_ptr role_right) : Role(vocabulary_info, index, role_left->is_static() && role_right->is_static()), m_role_left(role_left), m_role_right(role_right) { } -bool ComposeRole::operator==(const Role& other) const { +bool ComposeRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/diff.cpp b/src/core/elements/roles/diff.cpp index b9a1e821..ff79a2f5 100644 --- a/src/core/elements/roles/diff.cpp +++ b/src/core/elements/roles/diff.cpp @@ -35,7 +35,7 @@ RoleDenotations DiffRole::evaluate_impl(const States& states, DenotationsCaches& DiffRole::DiffRole(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role_left, std::shared_ptr role_right) : Role(vocabulary_info, index, (role_left->is_static() && role_right->is_static())), m_role_left(role_left), m_role_right(role_right) { } -bool DiffRole::operator==(const Role& other) const { +bool DiffRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/identity.cpp b/src/core/elements/roles/identity.cpp index 55922eab..ee33c61c 100644 --- a/src/core/elements/roles/identity.cpp +++ b/src/core/elements/roles/identity.cpp @@ -33,7 +33,7 @@ RoleDenotations IdentityRole::evaluate_impl(const States& states, DenotationsCac IdentityRole::IdentityRole(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr concept) : Role(vocabulary_info, index, concept->is_static()), m_concept(concept) { } -bool IdentityRole::operator==(const Role& other) const { +bool IdentityRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/inverse.cpp b/src/core/elements/roles/inverse.cpp index 89548cee..338351ef 100644 --- a/src/core/elements/roles/inverse.cpp +++ b/src/core/elements/roles/inverse.cpp @@ -33,7 +33,7 @@ RoleDenotations InverseRole::evaluate_impl(const States& states, DenotationsCach InverseRole::InverseRole(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role) : Role(vocabulary_info, index, role->is_static()), m_role(role) { } -bool InverseRole::operator==(const Role& other) const { +bool InverseRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/not.cpp b/src/core/elements/roles/not.cpp index 0d731319..827b208e 100644 --- a/src/core/elements/roles/not.cpp +++ b/src/core/elements/roles/not.cpp @@ -32,7 +32,7 @@ RoleDenotations NotRole::evaluate_impl(const States& states, DenotationsCaches& NotRole::NotRole(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role) : Role(vocabulary_info, index, role->is_static()), m_role(role) { } -bool NotRole::operator==(const Role& other) const { +bool NotRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/or.cpp b/src/core/elements/roles/or.cpp index 4f41e404..58962744 100644 --- a/src/core/elements/roles/or.cpp +++ b/src/core/elements/roles/or.cpp @@ -37,7 +37,7 @@ OrRole::OrRole(ElementIndex index, std::shared_ptr vocabulary_in m_role_left(role_1->get_index() < role_2->get_index() ? role_1 : role_2), m_role_right(role_1->get_index() < role_2->get_index() ? role_2 : role_1) { } -bool OrRole::operator==(const Role& other) const { +bool OrRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/primitive.cpp b/src/core/elements/roles/primitive.cpp index 3e50bfda..84a2f99a 100644 --- a/src/core/elements/roles/primitive.cpp +++ b/src/core/elements/roles/primitive.cpp @@ -56,7 +56,7 @@ PrimitiveRole::PrimitiveRole(ElementIndex index, std::shared_ptr } } -bool PrimitiveRole::operator==(const Role& other) const { +bool PrimitiveRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/restrict.cpp b/src/core/elements/roles/restrict.cpp index 5e10b20c..57eeba02 100644 --- a/src/core/elements/roles/restrict.cpp +++ b/src/core/elements/roles/restrict.cpp @@ -39,7 +39,7 @@ RoleDenotations RestrictRole::evaluate_impl(const States& states, DenotationsCac RestrictRole::RestrictRole(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role, std::shared_ptr concept) : Role(vocabulary_info, index, role->is_static() && concept->is_static()), m_role(role), m_concept(concept) { } -bool RestrictRole::operator==(const Role& other) const { +bool RestrictRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/top.cpp b/src/core/elements/roles/top.cpp index 09f927c0..c22276dc 100644 --- a/src/core/elements/roles/top.cpp +++ b/src/core/elements/roles/top.cpp @@ -22,7 +22,7 @@ RoleDenotations TopRole::evaluate_impl(const States& states, DenotationsCaches& TopRole::TopRole(ElementIndex index, std::shared_ptr vocabulary_info) : Role(vocabulary_info, index, true) { } -bool TopRole::operator==(const Role& other) const { +bool TopRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static; diff --git a/src/core/elements/roles/transitive_closure.cpp b/src/core/elements/roles/transitive_closure.cpp index 37641d55..848f22b8 100644 --- a/src/core/elements/roles/transitive_closure.cpp +++ b/src/core/elements/roles/transitive_closure.cpp @@ -45,7 +45,7 @@ RoleDenotations TransitiveClosureRole::evaluate_impl(const States& states, Denot TransitiveClosureRole::TransitiveClosureRole(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role) : Role(vocabulary_info, index, role->is_static()), m_role(role) { } -bool TransitiveClosureRole::operator==(const Role& other) const { +bool TransitiveClosureRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/elements/roles/transitive_reflexive_closure.cpp b/src/core/elements/roles/transitive_reflexive_closure.cpp index 87f739f1..28583220 100644 --- a/src/core/elements/roles/transitive_reflexive_closure.cpp +++ b/src/core/elements/roles/transitive_reflexive_closure.cpp @@ -50,7 +50,7 @@ RoleDenotations TransitiveReflexiveClosureRole::evaluate_impl(const States& stat TransitiveReflexiveClosureRole::TransitiveReflexiveClosureRole(ElementIndex index, std::shared_ptr vocabulary_info, std::shared_ptr role) : Role(vocabulary_info, index, role->is_static()), m_role(role) { } -bool TransitiveReflexiveClosureRole::operator==(const Role& other) const { +bool TransitiveReflexiveClosureRole::are_equal_impl(const Role& other) const { if (typeid(*this) == typeid(other)) { const auto& other_derived = static_cast(other); return m_is_static == other_derived.m_is_static diff --git a/src/core/numerical.cpp b/src/core/numerical.cpp index 9d927fb6..53563aa9 100644 --- a/src/core/numerical.cpp +++ b/src/core/numerical.cpp @@ -4,7 +4,7 @@ namespace dlplan::core { Numerical::Numerical(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) - : BaseElement(vocabulary_info, index, is_static) { + : BaseElement(index, vocabulary_info, is_static) { } Numerical::Numerical(const Numerical& other) = default; diff --git a/src/core/role.cpp b/src/core/role.cpp index 060c1df7..2f9d2cd3 100644 --- a/src/core/role.cpp +++ b/src/core/role.cpp @@ -4,7 +4,7 @@ namespace dlplan::core { Role::Role(std::shared_ptr vocabulary_info, ElementIndex index, bool is_static) - : BaseElement(vocabulary_info, index, is_static) { + : BaseElement(index, vocabulary_info, is_static) { } Role::Role(const Role& other) = default;