patrick
/
plasp
Archived
1
0
Fork 0
This repository has been archived on 2023-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
plasp/include/plasp/pddl/Predicate.h

88 lines
1.7 KiB
C++

#ifndef __PLASP__PDDL__PREDICATE_H
#define __PLASP__PDDL__PREDICATE_H
#include <unordered_map>
#include <vector>
#include <boost/functional/hash.hpp>
#include <plasp/pddl/Variable.h>
#include <plasp/utils/Parser.h>
namespace plasp
{
namespace pddl
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Predicate
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class Context;
struct PredicateHashMapKey
{
std::string name;
size_t arity;
bool operator==(const PredicateHashMapKey &other) const
{
return arity == other.arity && name == other.name;
}
};
class Predicate;
using PredicateHashMap = std::unordered_map<PredicateHashMapKey, Predicate>;
////////////////////////////////////////////////////////////////////////////////////////////////////
class Predicate
{
public:
static Predicate &parseDeclaration(utils::Parser &parser, Context &context);
public:
const std::string &name() const;
const Variables &arguments() const;
bool isDeclared() const;
private:
Predicate(std::string name);
void setDeclared();
bool m_isDeclared;
std::string m_name;
Variables m_arguments;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
namespace std
{
template<>
struct hash<plasp::pddl::PredicateHashMapKey>
{
std::size_t operator()(const plasp::pddl::PredicateHashMapKey &key) const
{
std::size_t seed = 0;
boost::hash_combine(seed, key.name);
boost::hash_combine(seed, key.arity);
return seed;
}
};
}
#endif