knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::ModalFormula Class Reference

#include <ModalFormula.h>

Inheritance diagram for knowrob::ModalFormula:
Collaboration diagram for knowrob::ModalFormula:

Public Member Functions

 ModalFormula (ModalOperatorPtr modalOperator, const FormulaPtr &formula)
 
const ModalOperatorPtrmodalOperator () const
 
const FormulaPtrmodalFormula () const
 
bool isModalPossibility () const
 
bool isModalNecessity () const
 
const char * operator_symbol () const override
 
void write (std::ostream &os) const override
 
 ModalFormula (ModalOperatorPtr modalOperator, const FormulaPtr &formula)
 
const ModalOperatorPtrmodalOperator () const
 
const FormulaPtrmodalFormula () const
 
bool isModalPossibility () const
 
bool isModalNecessity () const
 
const char * operator_symbol () const override
 
void write (std::ostream &os) const override
 
- Public Member Functions inherited from knowrob::CompoundFormula
 CompoundFormula (FormulaType type, const std::vector< FormulaPtr > &formulae)
 
virtual ~CompoundFormula ()=default
 
const std::vector< FormulaPtr > & formulae () const
 
 CompoundFormula (FormulaType type, const std::vector< FormulaPtr > &formulae)
 
virtual ~CompoundFormula ()=default
 
const std::vector< FormulaPtr > & formulae () const
 
- Public Member Functions inherited from knowrob::Formula
 Formula (const FormulaType &type)
 
virtual ~Formula ()=default
 
bool operator== (const Formula &other) const
 
FormulaType type () const
 
bool isAtomic () const
 
bool isGround () const
 
bool isTop () const
 
bool isBottom () const
 
 Formula (const FormulaType &type)
 
virtual ~Formula ()=default
 
bool operator== (const Formula &other) const
 
FormulaType type () const
 
bool isAtomic () const
 
bool isGround () const
 
bool isTop () const
 
bool isBottom () const
 
- Public Member Functions inherited from knowrob::Printable
virtual ~Printable ()=default
 
virtual std::string format () const
 
virtual ~Printable ()=default
 
virtual std::string format () const
 

Protected Member Functions

bool isEqual (const Formula &other) const override
 
bool isEqual (const Formula &other) const override
 
- Protected Member Functions inherited from knowrob::CompoundFormula
bool isGround1 () const
 
bool isGround1 () const
 

Protected Attributes

const ModalOperatorPtr modalOperator_
 
- Protected Attributes inherited from knowrob::CompoundFormula
const std::vector< FormulaPtrformulae_
 
- Protected Attributes inherited from knowrob::Formula
const FormulaType type_
 
bool isGround_ = true
 

Detailed Description

A higher-order formula using a modal operator.

Definition at line 17 of file ModalFormula.h.

Constructor & Destructor Documentation

◆ ModalFormula() [1/2]

ModalFormula::ModalFormula ( ModalOperatorPtr  modalOperator,
const FormulaPtr formula 
)

Create a new modal formula.

Parameters
modalOperatorthe modal operator.
formulathe formula.

Definition at line 14 of file ModalFormula.cpp.

16  modalOperator_(std::move(modalOperator)) {
17 }
CompoundFormula(FormulaType type, const std::vector< FormulaPtr > &formulae)
const ModalOperatorPtr & modalOperator() const
Definition: ModalFormula.h:29
const ModalOperatorPtr modalOperator_
Definition: ModalFormula.h:53
FormulaRule & formula()
Definition: formula.cpp:283

◆ ModalFormula() [2/2]

knowrob::ModalFormula::ModalFormula ( ModalOperatorPtr  modalOperator,
const FormulaPtr formula 
)

Create a new modal formula.

Parameters
modalOperatorthe modal operator.
formulathe formula.

Member Function Documentation

◆ isEqual() [1/2]

bool ModalFormula::isEqual ( const Formula other) const
overrideprotectedvirtual

Implements knowrob::Formula.

Definition at line 19 of file ModalFormula.cpp.

19  {
20  const auto &x = static_cast<const ModalFormula &>(other); // NOLINT
21  return (*modalOperator() == *x.modalOperator()) && (*modalFormula()) == (*x.modalFormula());
22 }
const FormulaPtr & modalFormula() const
Definition: ModalFormula.h:34

◆ isEqual() [2/2]

bool knowrob::ModalFormula::isEqual ( const Formula other) const
overrideprotectedvirtual

Implements knowrob::Formula.

◆ isModalNecessity() [1/2]

bool ModalFormula::isModalNecessity ( ) const
Returns
true if the modal operator is a necessity operator.

Definition at line 24 of file ModalFormula.cpp.

24  {
25  return modalOperator_->isModalNecessity();
26 }

◆ isModalNecessity() [2/2]

bool knowrob::ModalFormula::isModalNecessity ( ) const
Returns
true if the modal operator is a necessity operator.

◆ isModalPossibility() [1/2]

bool knowrob::ModalFormula::isModalPossibility ( ) const
inline
Returns
true if the modal operator is a possibility operator.

Definition at line 39 of file ModalFormula.h.

39 { return !isModalNecessity(); }
bool isModalNecessity() const

◆ isModalPossibility() [2/2]

bool knowrob::ModalFormula::isModalPossibility ( ) const
inline
Returns
true if the modal operator is a possibility operator.

Definition at line 39 of file ModalFormula.h.

39 { return !isModalNecessity(); }

◆ modalFormula() [1/2]

const FormulaPtr& knowrob::ModalFormula::modalFormula ( ) const
inline
Returns
the modal formula.

Definition at line 34 of file ModalFormula.h.

34 { return formulae_[0]; }
const std::vector< FormulaPtr > formulae_

◆ modalFormula() [2/2]

const FormulaPtr& knowrob::ModalFormula::modalFormula ( ) const
inline
Returns
the modal formula.

Definition at line 34 of file ModalFormula.h.

34 { return formulae_[0]; }

◆ modalOperator() [1/2]

const ModalOperatorPtr& knowrob::ModalFormula::modalOperator ( ) const
inline
Returns
the modal operator.

Definition at line 29 of file ModalFormula.h.

29 { return modalOperator_; }

◆ modalOperator() [2/2]

const ModalOperatorPtr& knowrob::ModalFormula::modalOperator ( ) const
inline
Returns
the modal operator.

Definition at line 29 of file ModalFormula.h.

29 { return modalOperator_; }

◆ operator_symbol() [1/2]

const char * ModalFormula::operator_symbol ( ) const
overridevirtual
Returns
symbol string of the operator

Implements knowrob::CompoundFormula.

Definition at line 28 of file ModalFormula.cpp.

28  {
29  return modalOperator_->symbol();
30 }

◆ operator_symbol() [2/2]

const char* knowrob::ModalFormula::operator_symbol ( ) const
overridevirtual
Returns
symbol string of the operator

Implements knowrob::CompoundFormula.

◆ write() [1/2]

void ModalFormula::write ( std::ostream &  os) const
overridevirtual

Print this object to a stream.

Parameters
osthe stream to print to.

Reimplemented from knowrob::CompoundFormula.

Definition at line 32 of file ModalFormula.cpp.

32  {
33  modalOperator_->write(os);
34  os << *(formulae_[0].get());
35 }

◆ write() [2/2]

void knowrob::ModalFormula::write ( std::ostream &  os) const
overridevirtual

Print this object to a stream.

Parameters
osthe stream to print to.

Reimplemented from knowrob::CompoundFormula.

Member Data Documentation

◆ modalOperator_

const ModalOperatorPtr knowrob::ModalFormula::modalOperator_
protected

Definition at line 53 of file ModalFormula.h.


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