10 #ifndef SYMBOLIC_OBJECTS_H_
11 #define SYMBOLIC_OBJECTS_H_
21 class pddl_typed_symbol;
40 Object(
const Pddl& pddl,
const VAL::pddl_typed_symbol* symbol);
42 Object(
const VAL::pddl_type_list* types,
43 const VAL::pddl_typed_symbol* symbol);
45 Object(
const Pddl& pddl,
const std::string& name_object);
47 const VAL::pddl_typed_symbol* symbol()
const {
return symbol_; }
49 const std::string& name()
const;
51 const Type& type()
const {
return type_; }
53 size_t hash()
const {
return hash_; }
56 static std::vector<Object> ParseArguments(
const Pddl& pddl,
57 const std::string& atom);
59 static std::vector<Object> ParseArguments(
const Pddl& pddl,
60 const std::vector<std::string>& str_args);
63 static std::vector<Object> CreateList(
67 static std::vector<Object> CreateList(
68 const VAL::pddl_type_list* types,
71 friend bool operator<(
const Object& lhs,
const Object& rhs) {
72 return &lhs.name() != &rhs.name() && lhs.name() < rhs.name();
75 friend bool operator==(
const Object& lhs,
const Object& rhs) {
76 return &lhs.name() == &rhs.name() ||
77 std::tie(lhs.hash_, lhs.name()) == std::tie(rhs.hash_, rhs.name());
80 friend bool operator!=(
const Object& lhs,
const Object& rhs) {
84 friend std::ostream& operator<<(std::ostream& os,
const Object&
object) {
93 explicit Type(
const VAL::pddl_type* symbol) : symbol_(symbol) {}
95 const VAL::pddl_type* symbol()
const {
return symbol_; }
97 bool IsSubtype(
const std::string& type)
const;
98 bool IsSubtype(
const Type& type)
const {
return IsSubtype(type.name()); }
100 std::vector<std::string> ListTypes()
const;
102 const std::string& name()
const;
105 return lhs.name() < rhs.name();
109 return lhs.name() == rhs.name();
112 friend std::ostream& operator<<(std::ostream& os,
119 const VAL::pddl_type* symbol_ =
nullptr;
123 const VAL::pddl_typed_symbol* symbol_ =
nullptr;
130 template <
typename T>
131 std::vector<Object> Object::CreateList(
133 std::vector<Object> objects;
134 if (symbols ==
nullptr)
return objects;
135 objects.reserve(symbols->size());
136 for (
const T* symbol : *symbols) {
137 objects.emplace_back(pddl, symbol);
142 template <
typename T>
143 std::vector<Object> Object::CreateList(
144 const VAL::pddl_type_list* types,
146 std::vector<Object> objects;
147 if (symbols ==
nullptr)
return objects;
148 objects.reserve(symbols->size());
149 for (
const T* symbol : *symbols) {
150 objects.emplace_back(types, symbol);
155 std::ostream& operator<<(std::ostream& os,
const std::vector<Object>& objects);
170 #endif // SYMBOLIC_OBJECTS_H_