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

#include <FirstOrderLiteral.h>

Inheritance diagram for knowrob::FirstOrderLiteral:
Collaboration diagram for knowrob::FirstOrderLiteral:

Public Member Functions

 FirstOrderLiteral (const PredicatePtr &predicate, bool isNegative)
 
const auto & predicate () const
 
auto isNegated () const
 
void setIsNegated (bool isNegated)
 
auto & functor () const
 
auto arity () const
 
virtual uint32_t numVariables () const
 
void write (std::ostream &os) const override
 
 FirstOrderLiteral (const PredicatePtr &predicate, bool isNegative)
 
const auto & predicate () const
 
auto isNegated () const
 
void setIsNegated (bool isNegated)
 
auto & functor () const
 
auto arity () const
 
virtual uint32_t numVariables () const
 
void write (std::ostream &os) const override
 
- Public Member Functions inherited from knowrob::Printable
virtual ~Printable ()=default
 
virtual std::string format () const
 
virtual ~Printable ()=default
 
virtual std::string format () const
 

Protected Attributes

const PredicatePtr predicate_
 
bool isNegated_
 

Detailed Description

A FOL literal is a predicate or its negation.

Definition at line 17 of file FirstOrderLiteral.h.

Constructor & Destructor Documentation

◆ FirstOrderLiteral() [1/2]

FirstOrderLiteral::FirstOrderLiteral ( const PredicatePtr predicate,
bool  isNegative 
)

Definition at line 11 of file FirstOrderLiteral.cpp.

13  isNegated_(isNegative) {}
const auto & predicate() const
const PredicatePtr predicate_

◆ FirstOrderLiteral() [2/2]

knowrob::FirstOrderLiteral::FirstOrderLiteral ( const PredicatePtr predicate,
bool  isNegative 
)

Member Function Documentation

◆ arity() [1/2]

auto knowrob::FirstOrderLiteral::arity ( ) const
inline

Get the arity of this predicate.

Returns
arity of predicate

Definition at line 49 of file FirstOrderLiteral.h.

49 { return predicate_->arity(); }

◆ arity() [2/2]

auto knowrob::FirstOrderLiteral::arity ( ) const
inline

Get the arity of this predicate.

Returns
arity of predicate

Definition at line 49 of file FirstOrderLiteral.h.

49 { return predicate_->arity(); }

◆ functor() [1/2]

auto& knowrob::FirstOrderLiteral::functor ( ) const
inline

Get the functor of this literal.

Returns
the functor name.

Definition at line 42 of file FirstOrderLiteral.h.

42 { return predicate_->functor(); }

◆ functor() [2/2]

auto& knowrob::FirstOrderLiteral::functor ( ) const
inline

Get the functor of this literal.

Returns
the functor name.

Definition at line 42 of file FirstOrderLiteral.h.

42 { return predicate_->functor(); }

◆ isNegated() [1/2]

auto knowrob::FirstOrderLiteral::isNegated ( ) const
inline
Returns
true if this is a negative literal.

Definition at line 29 of file FirstOrderLiteral.h.

29 { return isNegated_; }

◆ isNegated() [2/2]

auto knowrob::FirstOrderLiteral::isNegated ( ) const
inline
Returns
true if this is a negative literal.

Definition at line 29 of file FirstOrderLiteral.h.

29 { return isNegated_; }

◆ numVariables() [1/2]

virtual uint32_t knowrob::FirstOrderLiteral::numVariables ( ) const
inlinevirtual
Returns
The number of variables contained in this literal.

Reimplemented in knowrob::TriplePattern, and knowrob::TriplePattern.

Definition at line 54 of file FirstOrderLiteral.h.

54 { return predicate_->variables().size(); }

◆ numVariables() [2/2]

virtual uint32_t knowrob::FirstOrderLiteral::numVariables ( ) const
inlinevirtual
Returns
The number of variables contained in this literal.

Reimplemented in knowrob::TriplePattern, and knowrob::TriplePattern.

Definition at line 54 of file FirstOrderLiteral.h.

54 { return predicate_->variables().size(); }

◆ predicate() [1/2]

const auto& knowrob::FirstOrderLiteral::predicate ( ) const
inline
Returns
the predicate of this literal.

Definition at line 24 of file FirstOrderLiteral.h.

24 { return predicate_; }

◆ predicate() [2/2]

const auto& knowrob::FirstOrderLiteral::predicate ( ) const
inline
Returns
the predicate of this literal.

Definition at line 24 of file FirstOrderLiteral.h.

24 { return predicate_; }

◆ setIsNegated() [1/2]

void knowrob::FirstOrderLiteral::setIsNegated ( bool  isNegated)
inline

Set the negated flag of this literal.

Parameters
isNegatedtrue indicates the literal is negated.

Definition at line 35 of file FirstOrderLiteral.h.

◆ setIsNegated() [2/2]

void knowrob::FirstOrderLiteral::setIsNegated ( bool  isNegated)
inline

Set the negated flag of this literal.

Parameters
isNegatedtrue indicates the literal is negated.

Definition at line 35 of file FirstOrderLiteral.h.

35 { isNegated_ = isNegated; }

◆ write() [1/2]

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

Print this object to a stream.

Parameters
osthe stream to print to.

Implements knowrob::Printable.

Definition at line 21 of file FirstOrderLiteral.cpp.

21  {
22  if (isNegated()) {
23  os << "not(" << *predicate_ << ")";
24  } else {
25  os << *predicate_;
26  }
27 }

◆ write() [2/2]

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

Print this object to a stream.

Parameters
osthe stream to print to.

Implements knowrob::Printable.

Member Data Documentation

◆ isNegated_

bool knowrob::FirstOrderLiteral::isNegated_
protected

Definition at line 61 of file FirstOrderLiteral.h.

◆ predicate_

const PredicatePtr knowrob::FirstOrderLiteral::predicate_
protected

Definition at line 60 of file FirstOrderLiteral.h.


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