knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::Blank Class Reference

#include <Blank.h>

Inheritance diagram for knowrob::Blank:
Collaboration diagram for knowrob::Blank:

Public Member Functions

 Blank (std::string_view name)
 
 Blank (std::string_view name)
 
- Public Member Functions inherited from knowrob::Atom
 Atom (std::string_view stringForm, AtomType atomType=AtomType::REGULAR)
 
bool isSameAtom (const Atom &other) const
 
AtomType atomType () const
 
std::string_view stringForm () const final
 
void write (std::ostream &os) const override
 
 Atom (std::string_view stringForm, AtomType atomType=AtomType::REGULAR)
 
bool isSameAtom (const Atom &other) const
 
AtomType atomType () const
 
std::string_view stringForm () const final
 
void write (std::ostream &os) const override
 
- Public Member Functions inherited from knowrob::Atomic
 Atomic (AtomicType atomicType)
 
 ~Atomic () override=default
 
bool isSameAtomic (const Atomic &other) const
 
AtomicType atomicType () const
 
size_t hashOfAtomic () const
 
const std::set< std::string_view > & variables () const final
 
 Atomic (AtomicType atomicType)
 
 ~Atomic () override=default
 
bool isSameAtomic (const Atomic &other) const
 
AtomicType atomicType () const
 
size_t hashOfAtomic () const
 
const std::set< std::string_view > & variables () const final
 
void write (std::ostream &os) const override
 
- Public Member Functions inherited from knowrob::Term
 Term (TermType termType)
 
 ~Term () override=default
 
bool operator== (const Term &other) const
 
bool operator!= (const Term &other) const
 
TermType termType () const
 
bool isGround () const
 
bool isAtomic () const
 
bool isAtom () const
 
bool isVariable () const
 
bool isFunction () const
 
bool isNumeric () const
 
bool isString () const
 
bool isIRI () const
 
bool isBlank () const
 
size_t hash () const
 
 Term (TermType termType)
 
 ~Term () override=default
 
bool operator== (const Term &other) const
 
bool operator!= (const Term &other) const
 
TermType termType () const
 
bool isGround () const
 
bool isAtomic () const
 
bool isAtom () const
 
bool isVariable () const
 
bool isFunction () const
 
bool isNumeric () const
 
bool isString () const
 
bool isIRI () const
 
bool isBlank () const
 
size_t hash () const
 
- Public Member Functions inherited from knowrob::Printable
virtual ~Printable ()=default
 
virtual std::string format () const
 
virtual ~Printable ()=default
 
virtual std::string format () const
 
- Public Member Functions inherited from knowrob::RDFNode
 RDFNode (RDFNodeType rdfNodeType)
 
auto rdfNodeType () const
 
 RDFNode (RDFNodeType rdfNodeType)
 
auto rdfNodeType () const
 

Static Public Member Functions

static std::shared_ptr< BlankTabled (std::string_view stringForm)
 
static std::shared_ptr< BlankTabled (std::string_view stringForm)
 
- Static Public Member Functions inherited from knowrob::Atom
static std::shared_ptr< knowrob::AtomTabled (std::string_view stringForm)
 
static std::shared_ptr< knowrob::AtomTabled (std::string_view stringForm)
 
- Static Public Member Functions inherited from knowrob::Atomic
static std::shared_ptr< AtomicmakeTripleValue (const Triple &triple)
 
static std::shared_ptr< AtomicmakeTripleValue (const Triple &triple)
 

Additional Inherited Members

- Protected Types inherited from knowrob::Atom
using AtomTable = std::map< std::string, std::optional< std::weak_ptr< Atom > >, std::less<> >
 
using AtomTable = std::map< std::string, std::optional< std::weak_ptr< Atom > >, std::less<> >
 
- Static Protected Member Functions inherited from knowrob::Atom
static AtomTabletable ()
 
static AtomTabletable ()
 
- Protected Attributes inherited from knowrob::Atom
std::string_view stringForm_
 
const AtomType atomType_
 
- Protected Attributes inherited from knowrob::Atomic
const AtomicType atomicType_
 
- Protected Attributes inherited from knowrob::Term
const TermType termType_
 
bool isBlank_ = false
 
bool isIRI_ = false
 
- Protected Attributes inherited from knowrob::RDFNode
const RDFNodeType rdfNodeType_
 
- Static Protected Attributes inherited from knowrob::Term
static const std::set< std::string_view > noVariables_ = {}
 

Detailed Description

A blank node is a node in an RDF graph that is neither a URI nor a literal.

Definition at line 16 of file Blank.h.

Constructor & Destructor Documentation

◆ Blank() [1/2]

knowrob::Blank::Blank ( std::string_view  name)
inlineexplicit

Constructs a blank node from a name.

Parameters
namethe name of the blank node

Definition at line 22 of file Blank.h.

22  : Atom(name), RDFNode(RDFNodeType::BLANK) {
23  isBlank_ = true;
24  }
Atom(std::string_view stringForm, AtomType atomType=AtomType::REGULAR)
Definition: Atom.cpp:16
RDFNode(RDFNodeType rdfNodeType)
Definition: RDFNode.h:29
bool isBlank_
Definition: Term.h:112

◆ Blank() [2/2]

knowrob::Blank::Blank ( std::string_view  name)
inlineexplicit

Constructs a blank node from a name.

Parameters
namethe name of the blank node

Definition at line 22 of file Blank.h.

22  : Atom(name), RDFNode(RDFNodeType::BLANK) {
23  isBlank_ = true;
24  }

Member Function Documentation

◆ Tabled() [1/2]

std::shared_ptr< knowrob::Blank > Blank::Tabled ( std::string_view  stringForm)
static
Parameters
stringFormthe string form of the IRI
Returns
a shared pointer to an IRI atom

Definition at line 12 of file Blank.cpp.

12  {
13  auto it = Atom::table().find(name);
14  if (it != table().end()) {
15  if (auto atomPtr = it->second.value().lock()) {
16  if (atomPtr->isBlank()) {
17  return std::static_pointer_cast<Blank>(atomPtr);
18  }
19  }
20  }
21  // Atom does not exist or was destroyed, create a new one
22  auto inserted = table().emplace(name, std::nullopt);
23  auto &jt = inserted.first;
24  auto atom = std::make_shared<knowrob::Blank>(jt->first);
25  jt->second = atom;
26  auto locked = jt->second.value().lock();
27  if (!locked) {
28  throw std::runtime_error("Failed to lock Blank");
29  }
30  return std::static_pointer_cast<Blank>(locked);
31 }
static AtomTable & table()
Definition: Atom.cpp:11
StringRule & atom()
Definition: strings.cpp:54

◆ Tabled() [2/2]

static std::shared_ptr<Blank> knowrob::Blank::Tabled ( std::string_view  stringForm)
static
Parameters
stringFormthe string form of the IRI
Returns
a shared pointer to an IRI atom

The documentation for this class was generated from the following files: