From f10f4ac29ca360dd2507229d24e01502f0019c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sun, 4 Sep 2016 14:49:34 +0200 Subject: [PATCH] Added back reference expressions to make the expression tree structure simpler. --- include/plasp/pddl/Expression.h | 6 ++ include/plasp/pddl/expressions/Reference.h | 75 ++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 include/plasp/pddl/expressions/Reference.h diff --git a/include/plasp/pddl/Expression.h b/include/plasp/pddl/Expression.h index cf5fb35..4b58dca 100644 --- a/include/plasp/pddl/Expression.h +++ b/include/plasp/pddl/Expression.h @@ -62,6 +62,11 @@ class PrimitiveType; using PrimitiveTypePointer = std::unique_ptr; using PrimitiveTypes = std::vector; +template +class Reference; +template +using ReferencePointer = std::unique_ptr>; + class Unsupported; using UnsupportedPointer = std::unique_ptr; @@ -89,6 +94,7 @@ class Expression PredicateDeclaration, Predicate, PrimitiveType, + Reference, Unsupported, Variable, }; diff --git a/include/plasp/pddl/expressions/Reference.h b/include/plasp/pddl/expressions/Reference.h new file mode 100644 index 0000000..b7ca69a --- /dev/null +++ b/include/plasp/pddl/expressions/Reference.h @@ -0,0 +1,75 @@ +#ifndef __PLASP__PDDL__EXPRESSIONS__REFERENCE_H +#define __PLASP__PDDL__EXPRESSIONS__REFERENCE_H + +#include + +namespace plasp +{ +namespace pddl +{ +namespace expressions +{ + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Reference +// +//////////////////////////////////////////////////////////////////////////////////////////////////// + +template +class Reference: public ExpressionCRTP> +{ + public: + static const Expression::Type ExpressionType = Expression::Type::Reference; + + public: + Reference(Type *value); + + Type *get(); + const Type *get() const; + + ExpressionPointer normalize(); + + protected: + Type *m_value = nullptr; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +template +Reference::Reference(Type *value) +: m_value{value} +{ +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +template +Type *Reference::get() +{ + return m_value; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +template +const Type *Reference::get() const +{ + return m_value; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +template +ExpressionPointer Reference::normalize() +{ + return nullptr; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +} +} +} + +#endif