Added back reference expressions to make the expression tree structure simpler.

This commit is contained in:
Patrick Lühne 2016-09-04 14:49:34 +02:00
parent da88a8816c
commit f10f4ac29c
2 changed files with 81 additions and 0 deletions

View File

@ -62,6 +62,11 @@ class PrimitiveType;
using PrimitiveTypePointer = std::unique_ptr<PrimitiveType>;
using PrimitiveTypes = std::vector<PrimitiveTypePointer>;
template<class Type>
class Reference;
template<class Type>
using ReferencePointer = std::unique_ptr<Reference<Type>>;
class Unsupported;
using UnsupportedPointer = std::unique_ptr<Unsupported>;
@ -89,6 +94,7 @@ class Expression
PredicateDeclaration,
Predicate,
PrimitiveType,
Reference,
Unsupported,
Variable,
};

View File

@ -0,0 +1,75 @@
#ifndef __PLASP__PDDL__EXPRESSIONS__REFERENCE_H
#define __PLASP__PDDL__EXPRESSIONS__REFERENCE_H
#include <plasp/pddl/Expression.h>
namespace plasp
{
namespace pddl
{
namespace expressions
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Reference
//
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class Type>
class Reference: public ExpressionCRTP<Reference<Type>>
{
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<class Type>
Reference<Type>::Reference(Type *value)
: m_value{value}
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class Type>
Type *Reference<Type>::get()
{
return m_value;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class Type>
const Type *Reference<Type>::get() const
{
return m_value;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class Type>
ExpressionPointer Reference<Type>::normalize()
{
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
}
#endif