6 #include <boost/python.hpp>
7 #include "knowrob/terms/IRIAtom.h"
8 #include "knowrob/integration/python/utils.h"
9 #include "knowrob/semweb/Resource.h"
10 #include "knowrob/semweb/PrefixRegistry.h"
11 #include "knowrob/Logger.h"
17 return std::make_shared<Predicate>(functor, std::vector<TermPtr>{s, o});
22 return std::make_shared<Predicate>(functor, std::vector<TermPtr>{s});
27 if (it !=
table().end()) {
28 if (
auto atomPtr = it->second.value().lock()) {
29 if (atomPtr->isIRI()) {
30 return std::static_pointer_cast<IRIAtom>(atomPtr);
35 auto inserted =
table().emplace(name, std::nullopt);
36 auto &jt = inserted.first;
37 auto atom = std::make_shared<knowrob::IRIAtom>(jt->first);
39 auto locked = jt->second.value().lock();
41 throw std::runtime_error(
"Failed to lock IRIAtom");
43 return std::static_pointer_cast<IRIAtom>(locked);
50 if (alias.has_value()) {
53 os << alias.value().get() <<
":" << name;
64 if (o_iri.has_value()) {
67 KB_WARN(
"Failed to create IRI from namespace \"{}\" and name {}.", ns, name);
78 class_<IRIAtom, std::shared_ptr<IRIAtom>, bases<Atom, RDFNode>>(
"IRIAtom", no_init)
void write(std::ostream &os) const override
static AtomTable & table()
std::string_view stringForm_
std::string_view stringForm() const final
void write(std::ostream &os) const override
PredicatePtr operator()(const TermPtr &s, const TermPtr &o) const
static std::shared_ptr< IRIAtom > Tabled(std::string_view stringForm)
static OptionalStringRef uriToAlias(std::string_view uri)
static std::optional< std::string > createIRI(std::string_view alias, std::string_view entityName)
static std::string_view iri_name(std::string_view iri)
static std::string_view iri_ns(std::string_view iri, bool includeDelimiter=false)
void createType< IRIAtom >()
std::shared_ptr< Term > TermPtr
std::shared_ptr< Predicate > PredicatePtr
IRIAtomPtr iri(std::string_view ns, std::string_view name)
std::shared_ptr< IRIAtom > IRIAtomPtr