Started refactoring Types with variants.
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
#ifndef __PLASP__PDDL__TYPE_H
|
||||
#define __PLASP__PDDL__TYPE_H
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <plasp/utils/Parser.h>
|
||||
#include <plasp/pddl/TypePrimitive.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
@@ -19,45 +16,11 @@ namespace pddl
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Context;
|
||||
|
||||
class Type;
|
||||
using Type = boost::variant<TypePrimitive>;
|
||||
using TypeHashMap = std::unordered_map<std::string, Type>;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Type
|
||||
{
|
||||
public:
|
||||
static Type &parse(utils::Parser &parser, Context &context);
|
||||
static Type &parseDeclaration(utils::Parser &parser, Context &context);
|
||||
|
||||
public:
|
||||
const std::string &name() const;
|
||||
const std::vector<const Type *> &parentTypes() const;
|
||||
|
||||
bool isDeclared() const;
|
||||
|
||||
private:
|
||||
Type(std::string name);
|
||||
|
||||
void setDirty(bool isDirty = true);
|
||||
bool isDirty() const;
|
||||
|
||||
void setDeclared();
|
||||
|
||||
void addParentType(const Type &parentType);
|
||||
|
||||
bool m_isDirty;
|
||||
bool m_isDeclared;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
std::vector<const Type *> m_parentTypes;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
61
include/plasp/pddl/TypePrimitive.h
Normal file
61
include/plasp/pddl/TypePrimitive.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef __PLASP__PDDL__TYPE_PRIMITIVE_H
|
||||
#define __PLASP__PDDL__TYPE_PRIMITIVE_H
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <plasp/utils/Parser.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TypePrimitive
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class TypePrimitive
|
||||
{
|
||||
public:
|
||||
static TypePrimitive &parse(utils::Parser &parser, Context &context);
|
||||
static TypePrimitive &parseDeclaration(utils::Parser &parser, Context &context);
|
||||
|
||||
public:
|
||||
const std::string &name() const;
|
||||
const std::vector<const TypePrimitive *> &parentTypes() const;
|
||||
|
||||
bool isDeclared() const;
|
||||
|
||||
private:
|
||||
TypePrimitive(std::string name);
|
||||
|
||||
void setDirty(bool isDirty = true);
|
||||
bool isDirty() const;
|
||||
|
||||
void setDeclared();
|
||||
|
||||
void addParentType(const TypePrimitive &parentType);
|
||||
|
||||
bool m_isDirty;
|
||||
bool m_isDeclared;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
std::vector<const TypePrimitive *> m_parentTypes;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user