Added unique ID to derived predicates for easier translation.

This commit is contained in:
Patrick Lühne 2016-09-09 17:08:31 +02:00
parent a62cc8b3b9
commit 0ca51236bd
4 changed files with 22 additions and 2 deletions

View File

@ -24,12 +24,18 @@ class DerivedPredicate: public ExpressionCRTP<DerivedPredicate>
// TODO: consider implementing parsing functions for compatibility with older PDDL versions // TODO: consider implementing parsing functions for compatibility with older PDDL versions
public: public:
explicit DerivedPredicate(size_t id);
size_t id() const;
void setArgument(ExpressionPointer argument); void setArgument(ExpressionPointer argument);
ExpressionPointer argument() const; ExpressionPointer argument() const;
void print(std::ostream &ostream) const override; void print(std::ostream &ostream) const override;
private: private:
size_t m_id;
ExpressionPointer m_argument; ExpressionPointer m_argument;
}; };

View File

@ -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) void DerivedPredicate::setArgument(ExpressionPointer argument)
{ {
m_argument = argument; m_argument = argument;

View File

@ -24,7 +24,7 @@ const std::string ForAll::Identifier = "forall";
ExpressionPointer ForAll::decomposed(DerivedPredicates &derivedPredicates) ExpressionPointer ForAll::decomposed(DerivedPredicates &derivedPredicates)
{ {
auto derivedPredicate = DerivedPredicatePointer(new DerivedPredicate); auto derivedPredicate = DerivedPredicatePointer(new DerivedPredicate(derivedPredicates.size()));
derivedPredicates.push_back(derivedPredicate); derivedPredicates.push_back(derivedPredicate);
derivedPredicate->setArgument(this); derivedPredicate->setArgument(this);

View File

@ -28,7 +28,7 @@ ExpressionPointer Or::decomposed(DerivedPredicates &derivedPredicates)
argument = argument->decomposed(derivedPredicates); argument = argument->decomposed(derivedPredicates);
}); });
auto derivedPredicate = DerivedPredicatePointer(new DerivedPredicate); auto derivedPredicate = DerivedPredicatePointer(new DerivedPredicate(derivedPredicates.size()));
derivedPredicates.push_back(derivedPredicate); derivedPredicates.push_back(derivedPredicate);
derivedPredicate->setArgument(this); derivedPredicate->setArgument(this);