pl_search_cpp 1.4
Loading...
Searching...
No Matches
patom.hpp
Go to the documentation of this file.
1/*
2MIT License
3
4Copyright (c) 2025 [Peter Robinson]
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23*/
24
25#ifndef PL_SEARCH_PATOM_HPP
26#define PL_SEARCH_PATOM_HPP
27
28#include "term.hpp"
29#include "typedefs.hpp"
30
31#include <string>
32#include <typeinfo>
33
39namespace pl_search {
40
47class PAtom : public Term {
48public:
53 PAtom(const std::string &name) : name(name) {}
54
55
60 std::string getName() const { return name; }
61
66 std::string repr() const override { return name; }
67
73 bool isEqualTo(Term &t) const override {
74 PAtom *a = dynamic_cast<PAtom *>(&t);
75 if (a == nullptr)
76 return false;
77 return name == a->name;
78 }
79
85 bool isLessThan(Term &t) const override;
86
87protected:
88 std::string name;
89};
90
91} // namespace pl_search
92
93#endif // PL_SEARCH_PATOM_HPP
Represents a Prolog atom.
Definition patom.hpp:47
std::string repr() const override
Returns a string representation of the atom.
Definition patom.hpp:66
bool isLessThan(Term &t) const override
< operator for a PAtom and a Term
Definition term.cpp:123
PAtom(const std::string &name)
Constructs a PAtom with the given name.
Definition patom.hpp:53
std::string name
The name of the atom.
Definition patom.hpp:88
std::string getName() const
Returns the name of the atom.
Definition patom.hpp:60
bool isEqualTo(Term &t) const override
Checks if the term is equal to another term.
Definition patom.hpp:73
Abstract base class for terms that approximate Prolog terms.
Definition term.hpp:50
Definition choice_iterator.hpp:16
Definition of the Term class.
Definition of common typedefs used in the pl_search library.