6 #include "knowrob/terms/Atom.h"
7 #include "knowrob/integration/python/utils.h"
18 stringForm_(stringForm),
40 std::shared_ptr<knowrob::Atom>
Atom::Tabled(std::string_view name) {
41 auto it =
table().find(name);
42 if (it !=
table().end()) {
43 if (
auto atomPtr = it->second.value().lock()) {
50 auto inserted =
table().emplace(name, std::nullopt);
51 auto &jt = inserted.first;
52 auto atom = std::make_shared<knowrob::Atom>(jt->first);
54 auto locked = jt->second.value().lock();
56 throw std::runtime_error(
"Failed to lock Atom");
65 enum_<AtomType>(
"AtomType")
69 class_<Atom, std::shared_ptr<Atom>, bases<Atomic>>(
"Atom", no_init)
std::map< std::string, std::optional< std::weak_ptr< Atom > >, std::less<> > AtomTable
static std::shared_ptr< knowrob::Atom > Tabled(std::string_view stringForm)
void write(std::ostream &os) const override
static AtomTable & table()
Atom(std::string_view stringForm, AtomType atomType=AtomType::REGULAR)
AtomType atomType() const
std::string_view stringForm_
std::string_view stringForm() const final
bool isSameAtom(const Atom &other) const
void createType< Atom >()