Refactored expressions to inherit from base class.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/Variable.h>
|
||||
#include <plasp/utils/Parser.h>
|
||||
|
||||
@@ -25,14 +26,18 @@ class Action
|
||||
public:
|
||||
const std::string &name() const;
|
||||
|
||||
const Variables ¶meters() const;
|
||||
const Expression &precondition() const;
|
||||
const Expression &effect() const;
|
||||
|
||||
private:
|
||||
Action(std::string name);
|
||||
|
||||
void parsePrecondition(utils::Parser &parser, Context &context);
|
||||
|
||||
std::string m_name;
|
||||
|
||||
std::vector<Variable> m_parameters;
|
||||
Variables m_parameters;
|
||||
std::unique_ptr<Expression> m_precondition;
|
||||
std::unique_ptr<Expression> m_effect;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <plasp/pddl/Action.h>
|
||||
#include <plasp/pddl/Constant.h>
|
||||
#include <plasp/pddl/Predicate.h>
|
||||
#include <plasp/pddl/Type.h>
|
||||
@@ -33,6 +34,8 @@ class Context
|
||||
|
||||
std::vector<std::unique_ptr<Predicate>> predicates;
|
||||
std::unordered_map<PredicateHashMapKey, Predicate *> predicatesHashMap;
|
||||
|
||||
std::vector<std::unique_ptr<Action>> actions;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -31,6 +31,7 @@ class Domain
|
||||
const std::vector<std::unique_ptr<PrimitiveType>> &types() const;
|
||||
const std::vector<std::unique_ptr<Constant>> &constants() const;
|
||||
const std::vector<std::unique_ptr<Predicate>> &predicates() const;
|
||||
const std::vector<std::unique_ptr<Action>> &actions() const;
|
||||
|
||||
private:
|
||||
Domain(Context &context);
|
||||
@@ -47,6 +48,8 @@ class Domain
|
||||
|
||||
void parsePredicateSection(utils::Parser &parser);
|
||||
|
||||
void parseActionSection(utils::Parser &parser);
|
||||
|
||||
void checkConsistency();
|
||||
|
||||
Context &m_context;
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#ifndef __PLASP__PDDL__EXPRESSION_H
|
||||
#define __PLASP__PDDL__EXPRESSION_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <plasp/utils/Parser.h>
|
||||
@@ -17,17 +19,19 @@ namespace pddl
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Context;
|
||||
|
||||
namespace expression
|
||||
{
|
||||
class And;
|
||||
}
|
||||
class ExpressionVisitor;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using ExpressionPtr = boost::variant<void *>;
|
||||
class Expression
|
||||
{
|
||||
public:
|
||||
virtual void accept(ExpressionVisitor &expressionVisitor) const = 0;
|
||||
};
|
||||
|
||||
ExpressionPtr parsePreconditionExpression(utils::Parser &parser, Context &context);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::unique_ptr<Expression> parsePreconditionExpression(utils::Parser &parser, Context &context);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Reference in New Issue
Block a user