knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
PredicateIndicator.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/formulas/PredicateIndicator.h"
7 #include "knowrob/terms/Function.h"
8 #include "knowrob/terms/Numeric.h"
9 #include "knowrob/integration/python/utils.h"
10 
11 using namespace knowrob;
12 
14  return arity_ == other.arity_ && *functor_ == *other.functor_;
15 }
16 
18  if (arity_ != other.arity_) {
19  return arity_ < other.arity_;
20  }
21  return functor_->stringForm() < other.functor_->stringForm();
22 }
23 
24 void PredicateIndicator::write(std::ostream &os) const {
25  os << *functor_ << '/' << arity_;
26 }
27 
28 std::shared_ptr<Term> PredicateIndicator::toTerm() const {
29  return std::make_shared<Function>(Function("/", {
30  functor(),
31  std::make_shared<Long>(arity())
32  }));
33 }
34 
35 namespace knowrob::py {
36  template<>
38  using namespace boost::python;
39  class_<PredicateIndicator, std::shared_ptr<PredicateIndicator>>
40  ("PredicateIndicator", init<const std::string &, unsigned int>())
41  .def(init<AtomPtr, unsigned int>())
42  .def("__eq__", &PredicateIndicator::operator==)
43  .def(self < self)
44  .def("name", &PredicateIndicator::functor, return_value_policy<copy_const_reference>())
45  .def("arity", &PredicateIndicator::arity)
46  .def("toTerm", &PredicateIndicator::toTerm);
47  }
48 }
bool operator<(const PredicateIndicator &other) const
void write(std::ostream &os) const override
std::shared_ptr< Term > toTerm() const
bool operator==(const PredicateIndicator &other) const
void createType< PredicateIndicator >()