knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::RDFIndicator Struct Reference

#include <RDFIndicator.h>

Public Member Functions

 RDFIndicator (const PredicatePtr &predicate)
 
 RDFIndicator (std::string_view functor, size_t arity)
 
 RDFIndicator (size_t arity)
 
 RDFIndicator (const PredicatePtr &predicate)
 
 RDFIndicator (std::string_view functor, size_t arity)
 
 RDFIndicator (size_t arity)
 

Public Attributes

std::optional< std::string_view > functor
 
size_t arity
 

Detailed Description

A predicate indicator but in case of RDF predicates the functor can be a variable in which case the functor of the indicator is not defined.

Definition at line 19 of file RDFIndicator.h.

Constructor & Destructor Documentation

◆ RDFIndicator() [1/6]

RDFIndicator::RDFIndicator ( const PredicatePtr predicate)
explicit

Create a new RDF indicator with the given predicate.

Parameters
predicatethe predicate

Definition at line 10 of file RDFIndicator.cpp.

10  {
11 
12  // there is the case of property variables, and representation using triple/3 predicate
13  // which needs special handling here.
14  static const AtomPtr tripleFunctor = Atom::Tabled("triple");
15  if (predicate->arity() == 3 && *predicate->functor() == *tripleFunctor) {
16  auto predicateTerm = predicate->arguments()[1];
17  arity = 2;
18  if (predicateTerm->termType() == TermType::ATOMIC) {
19  functor = std::static_pointer_cast<Atomic>(predicateTerm)->stringForm();
20  }
21  } else {
22  arity = predicate->arity();
23  functor = predicate->functor()->stringForm();
24  }
25 }
static std::shared_ptr< knowrob::Atom > Tabled(std::string_view stringForm)
Definition: Atom.cpp:40
PredicateRule & predicate()
Definition: formula.cpp:221
std::shared_ptr< Atom > AtomPtr
Definition: Atom.h:69
std::optional< std::string_view > functor
Definition: RDFIndicator.h:39

◆ RDFIndicator() [2/6]

RDFIndicator::RDFIndicator ( std::string_view  functor,
size_t  arity 
)

Create a new RDF indicator with the given functor and arity.

Parameters
functorthe functor of the indicator
aritythe arity of the indicator

Definition at line 29 of file RDFIndicator.cpp.

29 : functor(functor), arity(arity) {}

◆ RDFIndicator() [3/6]

RDFIndicator::RDFIndicator ( size_t  arity)
explicit

Create a new RDF indicator with the given arity.

Parameters
aritythe arity of the indicator

Definition at line 27 of file RDFIndicator.cpp.

27 : arity(arity) {}

◆ RDFIndicator() [4/6]

knowrob::RDFIndicator::RDFIndicator ( const PredicatePtr predicate)
explicit

Create a new RDF indicator with the given predicate.

Parameters
predicatethe predicate

◆ RDFIndicator() [5/6]

knowrob::RDFIndicator::RDFIndicator ( std::string_view  functor,
size_t  arity 
)

Create a new RDF indicator with the given functor and arity.

Parameters
functorthe functor of the indicator
aritythe arity of the indicator

◆ RDFIndicator() [6/6]

knowrob::RDFIndicator::RDFIndicator ( size_t  arity)
explicit

Create a new RDF indicator with the given arity.

Parameters
aritythe arity of the indicator

Member Data Documentation

◆ arity

size_t knowrob::RDFIndicator::arity

Definition at line 40 of file RDFIndicator.h.

◆ functor

std::optional< std::string_view > knowrob::RDFIndicator::functor

Definition at line 39 of file RDFIndicator.h.


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