From 0ca51236bd598113278d8ba58aba3da5fe2a3a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 9 Sep 2016 17:08:31 +0200 Subject: [PATCH] Added unique ID to derived predicates for easier translation. --- include/plasp/pddl/expressions/DerivedPredicate.h | 6 ++++++ src/plasp/pddl/expressions/DerivedPredicate.cpp | 14 ++++++++++++++ src/plasp/pddl/expressions/ForAll.cpp | 2 +- src/plasp/pddl/expressions/Or.cpp | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/plasp/pddl/expressions/DerivedPredicate.h b/include/plasp/pddl/expressions/DerivedPredicate.h index 53087f7..3bc3765 100644 --- a/include/plasp/pddl/expressions/DerivedPredicate.h +++ b/include/plasp/pddl/expressions/DerivedPredicate.h @@ -24,12 +24,18 @@ class DerivedPredicate: public ExpressionCRTP // TODO: consider implementing parsing functions for compatibility with older PDDL versions public: + explicit DerivedPredicate(size_t id); + + size_t id() const; + void setArgument(ExpressionPointer argument); ExpressionPointer argument() const; void print(std::ostream &ostream) const override; private: + size_t m_id; + ExpressionPointer m_argument; }; diff --git a/src/plasp/pddl/expressions/DerivedPredicate.cpp b/src/plasp/pddl/expressions/DerivedPredicate.cpp index c211c9b..cf0d10b 100644 --- a/src/plasp/pddl/expressions/DerivedPredicate.cpp +++ b/src/plasp/pddl/expressions/DerivedPredicate.cpp @@ -16,6 +16,20 @@ namespace expressions // //////////////////////////////////////////////////////////////////////////////////////////////////// +DerivedPredicate::DerivedPredicate(size_t id) +: m_id{id} +{ +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +size_t DerivedPredicate::id() const +{ + return m_id; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + void DerivedPredicate::setArgument(ExpressionPointer argument) { m_argument = argument; diff --git a/src/plasp/pddl/expressions/ForAll.cpp b/src/plasp/pddl/expressions/ForAll.cpp index 4013f7f..6ce8550 100644 --- a/src/plasp/pddl/expressions/ForAll.cpp +++ b/src/plasp/pddl/expressions/ForAll.cpp @@ -24,7 +24,7 @@ const std::string ForAll::Identifier = "forall"; ExpressionPointer ForAll::decomposed(DerivedPredicates &derivedPredicates) { - auto derivedPredicate = DerivedPredicatePointer(new DerivedPredicate); + auto derivedPredicate = DerivedPredicatePointer(new DerivedPredicate(derivedPredicates.size())); derivedPredicates.push_back(derivedPredicate); derivedPredicate->setArgument(this); diff --git a/src/plasp/pddl/expressions/Or.cpp b/src/plasp/pddl/expressions/Or.cpp index 5fbedb3..f7c0293 100644 --- a/src/plasp/pddl/expressions/Or.cpp +++ b/src/plasp/pddl/expressions/Or.cpp @@ -28,7 +28,7 @@ ExpressionPointer Or::decomposed(DerivedPredicates &derivedPredicates) argument = argument->decomposed(derivedPredicates); }); - auto derivedPredicate = DerivedPredicatePointer(new DerivedPredicate); + auto derivedPredicate = DerivedPredicatePointer(new DerivedPredicate(derivedPredicates.size())); derivedPredicates.push_back(derivedPredicate); derivedPredicate->setArgument(this);