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

#include <PredicateIndicator.h>

Inheritance diagram for knowrob::PredicateIndicator:
Collaboration diagram for knowrob::PredicateIndicator:

Public Member Functions

 PredicateIndicator (std::string_view functor, uint32_t arity)
 
 PredicateIndicator (AtomPtr functor, uint32_t arity)
 
bool operator== (const PredicateIndicator &other) const
 
bool operator< (const PredicateIndicator &other) const
 
auto & functor () const
 
auto arity () const
 
std::shared_ptr< TermtoTerm () const
 
void write (std::ostream &os) const override
 
 PredicateIndicator (std::string_view functor, uint32_t arity)
 
 PredicateIndicator (AtomPtr functor, uint32_t arity)
 
bool operator== (const PredicateIndicator &other) const
 
bool operator< (const PredicateIndicator &other) const
 
auto & functor () const
 
auto arity () const
 
std::shared_ptr< TermtoTerm () 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
 

Detailed Description

The indicator of a predicate defined by its functor and arity.

Definition at line 19 of file PredicateIndicator.h.

Constructor & Destructor Documentation

◆ PredicateIndicator() [1/4]

knowrob::PredicateIndicator::PredicateIndicator ( std::string_view  functor,
uint32_t  arity 
)
inline
Parameters
functorthe functor name.
aritythr arity of this predicate.

Definition at line 25 of file PredicateIndicator.h.

26  : functor_(Atom::Tabled(functor)), arity_(arity) {}
static std::shared_ptr< knowrob::Atom > Tabled(std::string_view stringForm)
Definition: Atom.cpp:40

◆ PredicateIndicator() [2/4]

knowrob::PredicateIndicator::PredicateIndicator ( AtomPtr  functor,
uint32_t  arity 
)
inline
Parameters
functorthe functor name.
aritythr arity of this predicate.

Definition at line 32 of file PredicateIndicator.h.

33  : functor_(std::move(functor)), arity_(arity) {}

◆ PredicateIndicator() [3/4]

knowrob::PredicateIndicator::PredicateIndicator ( std::string_view  functor,
uint32_t  arity 
)
inline
Parameters
functorthe functor name.
aritythr arity of this predicate.

Definition at line 25 of file PredicateIndicator.h.

26  : functor_(Atom::Tabled(functor)), arity_(arity) {}

◆ PredicateIndicator() [4/4]

knowrob::PredicateIndicator::PredicateIndicator ( AtomPtr  functor,
uint32_t  arity 
)
inline
Parameters
functorthe functor name.
aritythr arity of this predicate.

Definition at line 32 of file PredicateIndicator.h.

33  : functor_(std::move(functor)), arity_(arity) {}

Member Function Documentation

◆ arity() [1/2]

auto knowrob::PredicateIndicator::arity ( ) const
inline

Get the arity of this predicate.

Returns
arity of predicate

Definition at line 53 of file PredicateIndicator.h.

53 { return arity_; }

◆ arity() [2/2]

auto knowrob::PredicateIndicator::arity ( ) const
inline

Get the arity of this predicate.

Returns
arity of predicate

Definition at line 53 of file PredicateIndicator.h.

53 { return arity_; }

◆ functor() [1/2]

auto& knowrob::PredicateIndicator::functor ( ) const
inline

Get the functor of this predicate.

Returns
the functor name.

Definition at line 46 of file PredicateIndicator.h.

46 { return functor_; }

◆ functor() [2/2]

auto& knowrob::PredicateIndicator::functor ( ) const
inline

Get the functor of this predicate.

Returns
the functor name.

Definition at line 46 of file PredicateIndicator.h.

46 { return functor_; }

◆ operator<() [1/2]

bool PredicateIndicator::operator< ( const PredicateIndicator other) const

Definition at line 17 of file PredicateIndicator.cpp.

17  {
18  if (arity_ != other.arity_) {
19  return arity_ < other.arity_;
20  }
21  return functor_->stringForm() < other.functor_->stringForm();
22 }

◆ operator<() [2/2]

bool knowrob::PredicateIndicator::operator< ( const PredicateIndicator other) const

◆ operator==() [1/2]

bool PredicateIndicator::operator== ( const PredicateIndicator other) const

Definition at line 13 of file PredicateIndicator.cpp.

13  {
14  return arity_ == other.arity_ && *functor_ == *other.functor_;
15 }

◆ operator==() [2/2]

bool knowrob::PredicateIndicator::operator== ( const PredicateIndicator other) const

◆ toTerm() [1/2]

std::shared_ptr< Term > PredicateIndicator::toTerm ( ) const

Convert the predicate indicator to a term of the form ‘’/'(Functor,Arity)`.

Returns
the indicator as a term.

Definition at line 28 of file PredicateIndicator.cpp.

28  {
29  return std::make_shared<Function>(Function("/", {
30  functor(),
31  std::make_shared<Long>(arity())
32  }));
33 }

◆ toTerm() [2/2]

std::shared_ptr<Term> knowrob::PredicateIndicator::toTerm ( ) const

Convert the predicate indicator to a term of the form ‘’/'(Functor,Arity)`.

Returns
the indicator as a term.

◆ write() [1/2]

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

Print this object to a stream.

Parameters
osthe stream to print to.

Implements knowrob::Printable.

Definition at line 24 of file PredicateIndicator.cpp.

24  {
25  os << *functor_ << '/' << arity_;
26 }

◆ write() [2/2]

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

Print this object to a stream.

Parameters
osthe stream to print to.

Implements knowrob::Printable.


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