knowrob
2.1.0
A Knowledge Base System for Cognition-enabled Robots
|
#include <Bindings.h>
Public Types | |
using | Map = std::map< std::string_view, std::pair< std::shared_ptr< Variable >, TermPtr > > |
using | VarMap = std::map< std::shared_ptr< Variable >, TermPtr > |
using | Map = std::map< std::string_view, std::pair< std::shared_ptr< Variable >, TermPtr > > |
using | VarMap = std::map< std::shared_ptr< Variable >, TermPtr > |
Public Member Functions | |
Bindings ()=default | |
Bindings (const std::map< std::shared_ptr< Variable >, TermPtr > &mapping) | |
~Bindings () override=default | |
bool | operator== (const Bindings &other) const |
void | operator+= (const Bindings &other) |
bool | empty () const |
auto | size () const |
auto | begin () const |
auto | end () const |
auto | find (std::string_view varName) const |
void | set (const std::shared_ptr< Variable > &var, const TermPtr &term) |
const TermPtr & | get (std::string_view varName) const |
std::shared_ptr< Atomic > | getAtomic (std::string_view varName) const |
bool | contains (std::string_view varName) const |
bool | unifyWith (const Bindings &other) |
bool | isConsistentWith (const Bindings &other) const |
size_t | hash () const |
void | write (std::ostream &os) const override |
Bindings ()=default | |
Bindings (const std::map< std::shared_ptr< Variable >, TermPtr > &mapping) | |
~Bindings () override=default | |
bool | operator== (const Bindings &other) const |
void | operator+= (const Bindings &other) |
bool | empty () const |
auto | size () const |
auto | begin () const |
auto | end () const |
auto | find (std::string_view varName) const |
void | set (const std::shared_ptr< Variable > &var, const TermPtr &term) |
const TermPtr & | get (std::string_view varName) const |
std::shared_ptr< Atomic > | getAtomic (std::string_view varName) const |
bool | contains (std::string_view varName) const |
bool | unifyWith (const Bindings &other) |
bool | isConsistentWith (const Bindings &other) const |
size_t | hash () const |
void | write (std::ostream &os) const override |
Public Member Functions inherited from knowrob::Printable | |
virtual | ~Printable ()=default |
virtual std::string | format () const |
virtual | ~Printable ()=default |
virtual std::string | format () const |
Static Public Member Functions | |
static std::shared_ptr< const Bindings > | emptyBindings () |
static std::shared_ptr< const Bindings > | emptyBindings () |
Protected Attributes | |
Map | mapping_ |
A substitution is a mapping from variable names to terms. For example, {x1 -> t1, ..., xn -> tn} represents a substitution of each variable xi with the corresponding term ti. Applying a substitution to a term t means to replace occurrences of each xi with ti. The resulting term is referred to as an instance of t.
Definition at line 28 of file Bindings.h.
using knowrob::Bindings::Map = std::map<std::string_view, std::pair<std::shared_ptr<Variable>, TermPtr> > |
A mapping from variable names to terms.
Definition at line 33 of file Bindings.h.
using knowrob::Bindings::Map = std::map<std::string_view, std::pair<std::shared_ptr<Variable>, TermPtr> > |
A mapping from variable names to terms.
Definition at line 33 of file Bindings.h.
using knowrob::Bindings::VarMap = std::map<std::shared_ptr<Variable>, TermPtr> |
Definition at line 34 of file Bindings.h.
using knowrob::Bindings::VarMap = std::map<std::shared_ptr<Variable>, TermPtr> |
Definition at line 34 of file Bindings.h.
|
default |
mapping | a mapping from variables to terms. |
Definition at line 22 of file Bindings.cpp.
|
overridedefault |
|
default |
|
explicit |
mapping | a mapping from variables to terms. |
|
overridedefault |
|
inline |
|
inline |
bool Bindings::contains | ( | std::string_view | varName | ) | const |
Returns true if the given var is mapped to a term by this substitution.
varName | a variable. |
Definition at line 56 of file Bindings.cpp.
bool knowrob::Bindings::contains | ( | std::string_view | varName | ) | const |
Returns true if the given var is mapped to a term by this substitution.
varName | a variable. |
|
inline |
Definition at line 60 of file Bindings.h.
|
inline |
Definition at line 60 of file Bindings.h.
|
static |
|
static |
|
inline |
|
inline |
|
inline |
|
inline |
const TermPtr & Bindings::get | ( | std::string_view | varName | ) | const |
Map the name of a variable to a term. A null pointer reference is returned if the given variable is not included in the mapping.
varName | a variable. |
Definition at line 60 of file Bindings.cpp.
const TermPtr& knowrob::Bindings::get | ( | std::string_view | varName | ) | const |
Map the name of a variable to a term. A null pointer reference is returned if the given variable is not included in the mapping.
varName | a variable. |
std::shared_ptr< Atomic > Bindings::getAtomic | ( | std::string_view | varName | ) | const |
Map the name of a variable to a term. A null pointer reference is returned if the given variable is not included in the mapping.
varName | a variable. |
Definition at line 71 of file Bindings.cpp.
std::shared_ptr<Atomic> knowrob::Bindings::getAtomic | ( | std::string_view | varName | ) | const |
Map the name of a variable to a term. A null pointer reference is returned if the given variable is not included in the mapping.
varName | a variable. |
size_t Bindings::hash | ( | ) | const |
Definition at line 82 of file Bindings.cpp.
size_t knowrob::Bindings::hash | ( | ) | const |
bool Bindings::isConsistentWith | ( | const Bindings & | other | ) | const |
Check if this substitution is consistent with another substitution, i.e. if both can be unified.
other | another substitution. |
Definition at line 104 of file Bindings.cpp.
bool knowrob::Bindings::isConsistentWith | ( | const Bindings & | other | ) | const |
Check if this substitution is consistent with another substitution, i.e. if both can be unified.
other | another substitution. |
void Bindings::operator+= | ( | const Bindings & | other | ) |
Combine with another substitution.
other | another substitution. |
Definition at line 46 of file Bindings.cpp.
void knowrob::Bindings::operator+= | ( | const Bindings & | other | ) |
Combine with another substitution.
other | another substitution. |
bool Bindings::operator== | ( | const Bindings & | other | ) | const |
other | another substitution. |
Definition at line 28 of file Bindings.cpp.
bool knowrob::Bindings::operator== | ( | const Bindings & | other | ) | const |
other | another substitution. |
Map a variable to a term.
var | a variable. |
term | a term. |
Definition at line 52 of file Bindings.cpp.
Map a variable to a term.
var | a variable. |
term | a term. |
|
inline |
|
inline |
bool Bindings::unifyWith | ( | const Bindings & | other | ) |
Combine with another substitution. If both substitute the same variable to some term, then the combination maps to the unification of these terms, if one exists.
other | another substitution |
Definition at line 130 of file Bindings.cpp.
bool knowrob::Bindings::unifyWith | ( | const Bindings & | other | ) |
Combine with another substitution. If both substitute the same variable to some term, then the combination maps to the unification of these terms, if one exists.
other | another substitution |
|
overridevirtual |
Print this object to a stream.
os | the stream to print to. |
Implements knowrob::Printable.
Definition at line 156 of file Bindings.cpp.
|
overridevirtual |
|
protected |
Definition at line 147 of file Bindings.h.