knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Numeric.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/terms/Numeric.h"
7 #include "knowrob/integration/python/utils.h"
8 
9 using namespace knowrob;
10 
12  return xsdType() == XSDType::FLOAT || xsdType() == XSDType::DOUBLE;
13 }
14 
15 std::shared_ptr<Numeric> Numeric::trueAtom() {
16  static auto trueAtom = std::make_shared<Boolean>(true);
17  return trueAtom;
18 }
19 
20 std::shared_ptr<Numeric> Numeric::falseAtom() {
21  static auto falseAtom = std::make_shared<Boolean>(false);
22  return falseAtom;
23 }
24 
25 namespace knowrob::py {
26  template<>
28  using namespace boost::python;
29  class_<Numeric, std::shared_ptr<Numeric>, bases<XSDAtomic>, boost::noncopyable>
30  ("Numeric", no_init)
31  .def("isFloatingNumber", &Numeric::isFloatingNumber)
32  .def("isSameNumeric", &Numeric::isSameNumeric);
33  class_<Double, std::shared_ptr<Double>, bases<Numeric>>
34  ("Double", init<double>())
35  .def(init<std::string_view>())
36  .def("__repr__", &Double::stringForm)
37  .def("numericForm", &Double::numericForm);
38  class_<Float, std::shared_ptr<Float>, bases<Numeric>>
39  ("Float", init<float>())
40  .def(init<std::string_view>())
41  .def("__repr__", &Float::stringForm)
42  .def("numericForm", &Float::numericForm);
43  class_<Integer, std::shared_ptr<Integer>, bases<Numeric>>
44  ("Integer", init<int>())
45  .def(init<std::string_view>())
46  .def("__repr__", &Integer::stringForm)
47  .def("numericForm", &Integer::numericForm);
48  class_<Long, std::shared_ptr<Long>, bases<Numeric>>
49  ("Long", init<long>())
50  .def(init<std::string_view>())
51  .def("__repr__", &Long::stringForm)
52  .def("numericForm", &Long::numericForm);
53  class_<Short, std::shared_ptr<Short>, bases<Numeric>>
54  ("Short", init<short>())
55  .def(init<std::string_view>())
56  .def("__repr__", &Short::stringForm)
57  .def("numericForm", &Short::numericForm);
58  }
59 }
static std::shared_ptr< Numeric > trueAtom()
Definition: Numeric.cpp:15
bool isFloatingNumber() const
Definition: Numeric.cpp:11
virtual bool isSameNumeric(const Numeric &other) const =0
static std::shared_ptr< Numeric > falseAtom()
Definition: Numeric.cpp:20
std::string_view stringForm() const override
Definition: Numeric.h:156
T1 numericForm() const
Definition: Numeric.h:117
XSDType xsdType() const
Definition: XSDAtomic.h:43
void createType< Numeric >()
Definition: Numeric.cpp:27