knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
RDFIndicator.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #include <knowrob/semweb/RDFIndicator.h>
7 
8 using namespace knowrob;
9 
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 }
26 
27 RDFIndicator::RDFIndicator(size_t arity) : arity(arity) {}
28 
29 RDFIndicator::RDFIndicator(std::string_view functor, size_t arity) : functor(functor), arity(arity) {}
static std::shared_ptr< knowrob::Atom > Tabled(std::string_view stringForm)
Definition: Atom.cpp:40
PredicateRule & predicate()
Definition: formula.cpp:221
std::shared_ptr< Predicate > PredicatePtr
Definition: Predicate.h:77
std::shared_ptr< Atom > AtomPtr
Definition: Atom.h:69
std::optional< std::string_view > functor
Definition: RDFIndicator.h:39
RDFIndicator(const PredicatePtr &predicate)