knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::Numeric Class Referenceabstract

#include <Numeric.h>

Inheritance diagram for knowrob::Numeric:
Collaboration diagram for knowrob::Numeric:

Public Member Functions

 Numeric (XSDType xsdType)
 
 ~Numeric () override=default
 
virtual bool isSameNumeric (const Numeric &other) const =0
 
virtual double asDouble () const =0
 
virtual float asFloat () const =0
 
virtual int asInteger () const =0
 
virtual long asLong () const =0
 
virtual short asShort () const =0
 
virtual unsigned int asUnsignedInteger () const =0
 
virtual unsigned long asUnsignedLong () const =0
 
virtual unsigned short asUnsignedShort () const =0
 
virtual bool asBoolean () const =0
 
bool isFloatingNumber () const
 
 Numeric (XSDType xsdType)
 
 ~Numeric () override=default
 
virtual bool isSameNumeric (const Numeric &other) const =0
 
virtual double asDouble () const =0
 
virtual float asFloat () const =0
 
virtual int asInteger () const =0
 
virtual long asLong () const =0
 
virtual short asShort () const =0
 
virtual unsigned int asUnsignedInteger () const =0
 
virtual unsigned long asUnsignedLong () const =0
 
virtual unsigned short asUnsignedShort () const =0
 
virtual bool asBoolean () const =0
 
bool isFloatingNumber () const
 
- Public Member Functions inherited from knowrob::XSDAtomic
 XSDAtomic (XSDType xsdType)
 
std::string_view xsdTypeIRI () const
 
XSDType xsdType () const
 
 XSDAtomic (XSDType xsdType)
 
std::string_view xsdTypeIRI () const
 
XSDType xsdType () const
 
- Public Member Functions inherited from knowrob::RDFNode
 RDFNode (RDFNodeType rdfNodeType)
 
auto rdfNodeType () const
 
 RDFNode (RDFNodeType rdfNodeType)
 
auto rdfNodeType () const
 
- Public Member Functions inherited from knowrob::Atomic
 Atomic (AtomicType atomicType)
 
 ~Atomic () override=default
 
bool isSameAtomic (const Atomic &other) const
 
AtomicType atomicType () const
 
size_t hashOfAtomic () const
 
virtual std::string_view stringForm () const =0
 
const std::set< std::string_view > & variables () const final
 
void write (std::ostream &os) const override
 
 Atomic (AtomicType atomicType)
 
 ~Atomic () override=default
 
bool isSameAtomic (const Atomic &other) const
 
AtomicType atomicType () const
 
size_t hashOfAtomic () const
 
virtual std::string_view stringForm () const =0
 
const std::set< std::string_view > & variables () const final
 
void write (std::ostream &os) const override
 
- Public Member Functions inherited from knowrob::Term
 Term (TermType termType)
 
 ~Term () override=default
 
bool operator== (const Term &other) const
 
bool operator!= (const Term &other) const
 
TermType termType () const
 
bool isGround () const
 
bool isAtomic () const
 
bool isAtom () const
 
bool isVariable () const
 
bool isFunction () const
 
bool isNumeric () const
 
bool isString () const
 
bool isIRI () const
 
bool isBlank () const
 
size_t hash () const
 
 Term (TermType termType)
 
 ~Term () override=default
 
bool operator== (const Term &other) const
 
bool operator!= (const Term &other) const
 
TermType termType () const
 
bool isGround () const
 
bool isAtomic () const
 
bool isAtom () const
 
bool isVariable () const
 
bool isFunction () const
 
bool isNumeric () const
 
bool isString () const
 
bool isIRI () const
 
bool isBlank () const
 
size_t hash () const
 
- Public Member Functions inherited from knowrob::Printable
virtual ~Printable ()=default
 
virtual std::string format () const
 
virtual ~Printable ()=default
 
virtual std::string format () const
 

Static Public Member Functions

static std::shared_ptr< NumerictrueAtom ()
 
static std::shared_ptr< NumericfalseAtom ()
 
static std::shared_ptr< NumerictrueAtom ()
 
static std::shared_ptr< NumericfalseAtom ()
 
- Static Public Member Functions inherited from knowrob::XSDAtomic
static std::shared_ptr< XSDAtomiccreate (std::string_view lexicalForm, std::string_view xsdTypeIRI)
 
static std::shared_ptr< XSDAtomiccreate (std::string_view lexicalForm, std::string_view xsdTypeIRI)
 
- Static Public Member Functions inherited from knowrob::Atomic
static std::shared_ptr< AtomicmakeTripleValue (const Triple &triple)
 
static std::shared_ptr< AtomicmakeTripleValue (const Triple &triple)
 

Additional Inherited Members

- Protected Attributes inherited from knowrob::XSDAtomic
XSDType xsdType_
 
- Protected Attributes inherited from knowrob::RDFNode
const RDFNodeType rdfNodeType_
 
- Protected Attributes inherited from knowrob::Atomic
const AtomicType atomicType_
 
- Protected Attributes inherited from knowrob::Term
const TermType termType_
 
bool isBlank_ = false
 
bool isIRI_ = false
 
- Static Protected Attributes inherited from knowrob::Term
static const std::set< std::string_view > noVariables_ = {}
 

Detailed Description

Base class for numeric terms.

Definition at line 18 of file Numeric.h.

Constructor & Destructor Documentation

◆ Numeric() [1/2]

knowrob::Numeric::Numeric ( XSDType  xsdType)
inlineexplicit

Definition at line 20 of file Numeric.h.

20 : XSDAtomic(xsdType) {}
XSDType xsdType() const
Definition: XSDAtomic.h:43
XSDAtomic(XSDType xsdType)
Definition: XSDAtomic.h:20

◆ ~Numeric() [1/2]

knowrob::Numeric::~Numeric ( )
overridedefault

◆ Numeric() [2/2]

knowrob::Numeric::Numeric ( XSDType  xsdType)
inlineexplicit

Definition at line 20 of file Numeric.h.

20 : XSDAtomic(xsdType) {}

◆ ~Numeric() [2/2]

knowrob::Numeric::~Numeric ( )
overridedefault

Member Function Documentation

◆ asBoolean() [1/2]

virtual bool knowrob::Numeric::asBoolean ( ) const
pure virtual
Returns
the numeric as a boolean

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asBoolean() [2/2]

virtual bool knowrob::Numeric::asBoolean ( ) const
pure virtual
Returns
the numeric as a boolean

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asDouble() [1/2]

virtual double knowrob::Numeric::asDouble ( ) const
pure virtual
Returns
the numeric as a double

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asDouble() [2/2]

virtual double knowrob::Numeric::asDouble ( ) const
pure virtual
Returns
the numeric as a double

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asFloat() [1/2]

virtual float knowrob::Numeric::asFloat ( ) const
pure virtual
Returns
the numeric as a float

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asFloat() [2/2]

virtual float knowrob::Numeric::asFloat ( ) const
pure virtual
Returns
the numeric as a float

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asInteger() [1/2]

virtual int knowrob::Numeric::asInteger ( ) const
pure virtual
Returns
the numeric as an integer

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asInteger() [2/2]

virtual int knowrob::Numeric::asInteger ( ) const
pure virtual
Returns
the numeric as an integer

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asLong() [1/2]

virtual long knowrob::Numeric::asLong ( ) const
pure virtual
Returns
the numeric as a long

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asLong() [2/2]

virtual long knowrob::Numeric::asLong ( ) const
pure virtual
Returns
the numeric as a long

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asShort() [1/2]

virtual short knowrob::Numeric::asShort ( ) const
pure virtual
Returns
the numeric as a short

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asShort() [2/2]

virtual short knowrob::Numeric::asShort ( ) const
pure virtual
Returns
the numeric as a short

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asUnsignedInteger() [1/2]

virtual unsigned int knowrob::Numeric::asUnsignedInteger ( ) const
pure virtual
Returns
the numeric as an unsigned integer

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asUnsignedInteger() [2/2]

virtual unsigned int knowrob::Numeric::asUnsignedInteger ( ) const
pure virtual
Returns
the numeric as an unsigned integer

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asUnsignedLong() [1/2]

virtual unsigned long knowrob::Numeric::asUnsignedLong ( ) const
pure virtual
Returns
the numeric as an unsigned long

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asUnsignedLong() [2/2]

virtual unsigned long knowrob::Numeric::asUnsignedLong ( ) const
pure virtual
Returns
the numeric as an unsigned long

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asUnsignedShort() [1/2]

virtual unsigned short knowrob::Numeric::asUnsignedShort ( ) const
pure virtual
Returns
the numeric as an unsigned short

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ asUnsignedShort() [2/2]

virtual unsigned short knowrob::Numeric::asUnsignedShort ( ) const
pure virtual
Returns
the numeric as an unsigned short

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ falseAtom() [1/2]

std::shared_ptr< Numeric > Numeric::falseAtom ( )
static
Returns
a boolean typed numeric with value false

Definition at line 20 of file Numeric.cpp.

20  {
21  static auto falseAtom = std::make_shared<Boolean>(false);
22  return falseAtom;
23 }
static std::shared_ptr< Numeric > falseAtom()
Definition: Numeric.cpp:20

◆ falseAtom() [2/2]

static std::shared_ptr<Numeric> knowrob::Numeric::falseAtom ( )
static
Returns
a boolean typed numeric with value false

◆ isFloatingNumber() [1/2]

bool Numeric::isFloatingNumber ( ) const
Returns
true if the numeric is a floating number

Definition at line 11 of file Numeric.cpp.

11  {
12  return xsdType() == XSDType::FLOAT || xsdType() == XSDType::DOUBLE;
13 }

◆ isFloatingNumber() [2/2]

bool knowrob::Numeric::isFloatingNumber ( ) const
Returns
true if the numeric is a floating number

◆ isSameNumeric() [1/2]

virtual bool knowrob::Numeric::isSameNumeric ( const Numeric other) const
pure virtual
Parameters
otheranother numeric
Returns
true if both numerics are equal

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ isSameNumeric() [2/2]

virtual bool knowrob::Numeric::isSameNumeric ( const Numeric other) const
pure virtual
Parameters
otheranother numeric
Returns
true if both numerics are equal

Implemented in knowrob::NumericTemplate< T1, T2 >, and knowrob::NumericTemplate< T1, T2 >.

◆ trueAtom() [1/2]

std::shared_ptr< Numeric > Numeric::trueAtom ( )
static
Returns
a boolean typed numeric with value true

Definition at line 15 of file Numeric.cpp.

15  {
16  static auto trueAtom = std::make_shared<Boolean>(true);
17  return trueAtom;
18 }
static std::shared_ptr< Numeric > trueAtom()
Definition: Numeric.cpp:15

◆ trueAtom() [2/2]

static std::shared_ptr<Numeric> knowrob::Numeric::trueAtom ( )
static
Returns
a boolean typed numeric with value true

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