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

#include <ListTerm.h>

Inheritance diagram for knowrob::ListTerm:
Collaboration diagram for knowrob::ListTerm:

Public Member Functions

 ListTerm (const std::vector< TermPtr > &elements)
 
bool isNIL () const
 
auto & elements () const
 
auto begin ()
 
auto end ()
 
void write (std::ostream &os) const override
 
 ListTerm (const std::vector< TermPtr > &elements)
 
bool isNIL () const
 
auto & elements () const
 
auto begin ()
 
auto end ()
 
void write (std::ostream &os) const override
 
- Public Member Functions inherited from knowrob::Function
 Function (AtomPtr functor, const std::vector< TermPtr > &arguments)
 
 Function (std::string_view functor, const std::vector< TermPtr > &arguments)
 
bool isSameFunction (const Function &other) const
 
auto & functor () const
 
auto & arguments () const
 
auto arity () const
 
size_t hashOfFunction () const
 
const std::set< std::string_view > & variables () const override
 
 Function (AtomPtr functor, const std::vector< TermPtr > &arguments)
 
 Function (std::string_view functor, const std::vector< TermPtr > &arguments)
 
bool isSameFunction (const Function &other) const
 
auto & functor () const
 
auto & arguments () const
 
auto arity () const
 
size_t hashOfFunction () const
 
const std::set< std::string_view > & variables () 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
 

Static Public Member Functions

static const AtomPtrlistFunctor ()
 
static std::shared_ptr< ListTermnil ()
 
static const AtomPtrlistFunctor ()
 
static std::shared_ptr< ListTermnil ()
 

Additional Inherited Members

- Protected Member Functions inherited from knowrob::Function
std::set< std::string_view > getVariables1 () const
 
std::set< std::string_view > getVariables1 () const
 
- Protected Attributes inherited from knowrob::Function
const std::shared_ptr< Atomfunctor_
 
const std::vector< TermPtrarguments_
 
const std::set< std::string_view > variables_
 
- Protected Attributes inherited from knowrob::Term
const TermType termType_
 
bool isBlank_ = false
 
bool isIRI_ = false
 
- Static Protected Attributes inherited from knowrob::Term
static const std::set< std::string_view > noVariables_ = {}
 

Detailed Description

A Function representing a list of terms, the functor '[]' is used. The empty list is a special constant NIL represented as null-ary '[]'.

Definition at line 19 of file ListTerm.h.

Constructor & Destructor Documentation

◆ ListTerm() [1/2]

ListTerm::ListTerm ( const std::vector< TermPtr > &  elements)
explicit

Definition at line 13 of file ListTerm.cpp.

15 }
Function(AtomPtr functor, const std::vector< TermPtr > &arguments)
Definition: Function.cpp:13
auto & elements() const
Definition: ListTerm.h:39
static const AtomPtr & listFunctor()
Definition: ListTerm.cpp:17

◆ ListTerm() [2/2]

knowrob::ListTerm::ListTerm ( const std::vector< TermPtr > &  elements)
explicit

Member Function Documentation

◆ begin() [1/2]

auto knowrob::ListTerm::begin ( )
inline
Returns
an iterator ovr the elements of this list.

Definition at line 44 of file ListTerm.h.

44 { return arguments_.begin(); }
const std::vector< TermPtr > arguments_
Definition: Function.h:67

◆ begin() [2/2]

auto knowrob::ListTerm::begin ( )
inline
Returns
an iterator ovr the elements of this list.

Definition at line 44 of file ListTerm.h.

44 { return arguments_.begin(); }

◆ elements() [1/2]

auto& knowrob::ListTerm::elements ( ) const
inline

Get the elements of this list.

Returns
a vector of list elements.

Definition at line 39 of file ListTerm.h.

39 { return arguments_; }

◆ elements() [2/2]

auto& knowrob::ListTerm::elements ( ) const
inline

Get the elements of this list.

Returns
a vector of list elements.

Definition at line 39 of file ListTerm.h.

39 { return arguments_; }

◆ end() [1/2]

auto knowrob::ListTerm::end ( )
inline
Returns
the iterator object indicating the end of iteration.

Definition at line 49 of file ListTerm.h.

49 { return arguments_.end(); }

◆ end() [2/2]

auto knowrob::ListTerm::end ( )
inline
Returns
the iterator object indicating the end of iteration.

Definition at line 49 of file ListTerm.h.

49 { return arguments_.end(); }

◆ isNIL() [1/2]

bool ListTerm::isNIL ( ) const
Returns
true if this list term is the NIL constant.

Definition at line 28 of file ListTerm.cpp.

28  {
29  return arguments_.empty();
30 }

◆ isNIL() [2/2]

bool knowrob::ListTerm::isNIL ( ) const
Returns
true if this list term is the NIL constant.

◆ listFunctor() [1/2]

const AtomPtr & ListTerm::listFunctor ( )
static

Definition at line 17 of file ListTerm.cpp.

17  {
18  static const AtomPtr fun = Atom::Tabled("[]");
19  return fun;
20 }
static std::shared_ptr< knowrob::Atom > Tabled(std::string_view stringForm)
Definition: Atom.cpp:40
std::shared_ptr< Atom > AtomPtr
Definition: Atom.h:69

◆ listFunctor() [2/2]

static const AtomPtr& knowrob::ListTerm::listFunctor ( )
static

◆ nil() [1/2]

std::shared_ptr< ListTerm > ListTerm::nil ( )
static
Returns
the NIL constant.

Definition at line 22 of file ListTerm.cpp.

22  {
23  static std::shared_ptr<ListTerm> x(new ListTerm(
24  std::vector<std::shared_ptr<Term>>(0)));
25  return x;
26 }
ListTerm(const std::vector< TermPtr > &elements)
Definition: ListTerm.cpp:13

◆ nil() [2/2]

static std::shared_ptr<ListTerm> knowrob::ListTerm::nil ( )
static
Returns
the NIL constant.

◆ write() [1/2]

void ListTerm::write ( std::ostream &  os) const
overridevirtual

Print this object to a stream.

Parameters
osthe stream to print to.

Reimplemented from knowrob::Function.

Definition at line 32 of file ListTerm.cpp.

32  {
33  os << '[';
34  for (uint32_t i = 0; i < arguments_.size(); i++) {
35  os << *arguments_[i];
36  if (i + 1 < arguments_.size()) {
37  os << ',' << ' ';
38  }
39  }
40  os << ']';
41 }

◆ write() [2/2]

void knowrob::ListTerm::write ( std::ostream &  os) const
overridevirtual

Print this object to a stream.

Parameters
osthe stream to print to.

Reimplemented from knowrob::Function.


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