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

#include <CompoundFormula.h>

Inheritance diagram for knowrob::CompoundFormula:
Collaboration diagram for knowrob::CompoundFormula:

Public Member Functions

 CompoundFormula (FormulaType type, const std::vector< FormulaPtr > &formulae)
 
virtual ~CompoundFormula ()=default
 
const std::vector< FormulaPtr > & formulae () const
 
virtual const char * operator_symbol () const =0
 
void write (std::ostream &os) const override
 
 CompoundFormula (FormulaType type, const std::vector< FormulaPtr > &formulae)
 
virtual ~CompoundFormula ()=default
 
const std::vector< FormulaPtr > & formulae () const
 
virtual const char * operator_symbol () const =0
 
void write (std::ostream &os) const override
 
- 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 isGround1 () const
 
bool isGround1 () const
 
- Protected Member Functions inherited from knowrob::Formula
virtual bool isEqual (const Formula &other) const =0
 
virtual bool isEqual (const Formula &other) const =0
 

Protected Attributes

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

Detailed Description

A formula with sub-formulas linked via logical connectives.

Definition at line 18 of file CompoundFormula.h.

Constructor & Destructor Documentation

◆ CompoundFormula() [1/2]

knowrob::CompoundFormula::CompoundFormula ( FormulaType  type,
const std::vector< FormulaPtr > &  formulae 
)
Parameters
typethe type of the formula.
formulaelist of connected formulae.

◆ ~CompoundFormula() [1/2]

virtual knowrob::CompoundFormula::~CompoundFormula ( )
virtualdefault

◆ CompoundFormula() [2/2]

knowrob::CompoundFormula::CompoundFormula ( FormulaType  type,
const std::vector< FormulaPtr > &  formulae 
)
Parameters
typethe type of the formula.
formulaelist of connected formulae.

◆ ~CompoundFormula() [2/2]

virtual knowrob::CompoundFormula::~CompoundFormula ( )
virtualdefault

Member Function Documentation

◆ formulae() [1/2]

const std::vector<FormulaPtr>& knowrob::CompoundFormula::formulae ( ) const
inline
Returns
the sub-formulas associated to this formula.

Definition at line 31 of file CompoundFormula.h.

31 { return formulae_; }
const std::vector< FormulaPtr > formulae_

◆ formulae() [2/2]

const std::vector<FormulaPtr>& knowrob::CompoundFormula::formulae ( ) const
inline
Returns
the sub-formulas associated to this formula.

Definition at line 31 of file CompoundFormula.h.

31 { return formulae_; }

◆ isGround1() [1/2]

bool CompoundFormula::isGround1 ( ) const
protected

Definition at line 19 of file CompoundFormula.cpp.

19  {
20  return std::all_of(formulae_.begin(), formulae_.end(),
21  [](const std::shared_ptr<Formula> &x) { return x->isGround(); });
22 }

◆ isGround1() [2/2]

bool knowrob::CompoundFormula::isGround1 ( ) const
protected

◆ operator_symbol() [1/2]

virtual const char* knowrob::CompoundFormula::operator_symbol ( ) const
pure virtual

◆ operator_symbol() [2/2]

virtual const char* knowrob::CompoundFormula::operator_symbol ( ) const
pure virtual

◆ write() [1/2]

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

Print this object to a stream.

Parameters
osthe stream to print to.

Implements knowrob::Printable.

Reimplemented in knowrob::ModalFormula, and knowrob::ModalFormula.

Definition at line 24 of file CompoundFormula.cpp.

24  {
25  if (formulae_.size() == 1) {
26  os << operator_symbol() << ' ';
27  os << *(formulae_[0].get());
28  } else {
29  os << '(';
30  for (uint32_t i = 0; i < formulae_.size(); i++) {
31  os << *(formulae_[i].get());
32  if (i + 1 < formulae_.size()) {
33  os << ' ' << operator_symbol() << ' ';
34  }
35  }
36  os << ')';
37  }
38 }
virtual const char * operator_symbol() const =0

◆ write() [2/2]

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

Print this object to a stream.

Parameters
osthe stream to print to.

Implements knowrob::Printable.

Reimplemented in knowrob::ModalFormula.

Member Data Documentation

◆ formulae_

const std::vector< FormulaPtr > knowrob::CompoundFormula::formulae_
protected

Definition at line 42 of file CompoundFormula.h.


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