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

#include <Perspective.h>

Public Member Functions

 Perspective (std::string_view iri)
 
 Perspective (IRIAtomPtr atom)
 
auto iri () const
 
auto atom () const
 
 Perspective (std::string_view iri)
 
 Perspective (IRIAtomPtr atom)
 
auto iri () const
 
auto atom () const
 

Static Public Member Functions

static std::shared_ptr< PerspectivegetEgoPerspective ()
 
static bool isEgoPerspective (std::string_view iri)
 
static std::shared_ptr< Perspectiveget (std::string_view iri)
 
static std::shared_ptr< PerspectivegetEgoPerspective ()
 
static bool isEgoPerspective (std::string_view iri)
 
static std::shared_ptr< Perspectiveget (std::string_view iri)
 

Protected Attributes

IRIAtomPtr atom_
 

Static Protected Attributes

static std::map< std::string_view, std::shared_ptr< Perspective > > perspectiveMap_
 

Detailed Description

A perspective is a point of view from which a statement is true or false. Usually a perspective is associated with an IRI denoting an agent or a group of agents.

Definition at line 21 of file Perspective.h.

Constructor & Destructor Documentation

◆ Perspective() [1/4]

Perspective::Perspective ( std::string_view  iri)
explicit

Create a new perspective with the given IRI.

Parameters
irithe IRI of the perspective

Definition at line 15 of file Perspective.cpp.

static std::shared_ptr< IRIAtom > Tabled(std::string_view stringForm)
Definition: IRIAtom.cpp:25
auto iri() const
Definition: Perspective.h:38

◆ Perspective() [2/4]

knowrob::Perspective::Perspective ( IRIAtomPtr  atom)
inlineexplicit

Create a new perspective with the given IRI atom.

Parameters
atomthe IRI atom of the perspective

Definition at line 33 of file Perspective.h.

33 : atom_(std::move(atom)) {}
auto atom() const
Definition: Perspective.h:43

◆ Perspective() [3/4]

knowrob::Perspective::Perspective ( std::string_view  iri)
explicit

Create a new perspective with the given IRI.

Parameters
irithe IRI of the perspective

◆ Perspective() [4/4]

knowrob::Perspective::Perspective ( IRIAtomPtr  atom)
inlineexplicit

Create a new perspective with the given IRI atom.

Parameters
atomthe IRI atom of the perspective

Definition at line 33 of file Perspective.h.

33 : atom_(std::move(atom)) {}

Member Function Documentation

◆ atom() [1/2]

auto knowrob::Perspective::atom ( ) const
inline
Returns
the IRI atom of the perspective

Definition at line 43 of file Perspective.h.

43 { return atom_; }

◆ atom() [2/2]

auto knowrob::Perspective::atom ( ) const
inline
Returns
the IRI atom of the perspective

Definition at line 43 of file Perspective.h.

43 { return atom_; }

◆ get() [1/2]

std::shared_ptr< Perspective > Perspective::get ( std::string_view  iri)
static
Parameters
irian IRI
Returns
the perspective with the given IRI

Definition at line 31 of file Perspective.cpp.

31  {
32  auto it = perspectiveMap_.find(iri);
33  if (it == perspectiveMap_.end()) {
34  auto agent = std::make_shared<Perspective>(iri);
35  perspectiveMap_[iri] = agent;
36  return agent;
37  } else {
38  return it->second;
39  }
40 }
static std::map< std::string_view, std::shared_ptr< Perspective > > perspectiveMap_
Definition: Perspective.h:64

◆ get() [2/2]

static std::shared_ptr<Perspective> knowrob::Perspective::get ( std::string_view  iri)
static
Parameters
irian IRI
Returns
the perspective with the given IRI

◆ getEgoPerspective() [1/2]

std::shared_ptr< Perspective > Perspective::getEgoPerspective ( )
static

The egoIRI perspective is a special perspective taken by the agent running the knowledge base.

Returns
the egoIRI perspective

Definition at line 18 of file Perspective.cpp.

18  {
19  static std::shared_ptr<Perspective> egoPerspective;
20  if (egoPerspective == nullptr) {
21  egoPerspective = std::make_shared<Perspective>(GlobalSettings::egoIRI());
22  perspectiveMap_[egoPerspective->iri()] = egoPerspective;
23  }
24  return egoPerspective;
25 }
static IRIAtomPtr egoIRI()
Definition: knowrob.h:79

◆ getEgoPerspective() [2/2]

static std::shared_ptr<Perspective> knowrob::Perspective::getEgoPerspective ( )
static

The egoIRI perspective is a special perspective taken by the agent running the knowledge base.

Returns
the egoIRI perspective

◆ iri() [1/2]

auto knowrob::Perspective::iri ( ) const
inline
Returns
the IRI of the perspective

Definition at line 38 of file Perspective.h.

38 { return atom_->stringForm(); }

◆ iri() [2/2]

auto knowrob::Perspective::iri ( ) const
inline
Returns
the IRI of the perspective

Definition at line 38 of file Perspective.h.

38 { return atom_->stringForm(); }

◆ isEgoPerspective() [1/2]

bool Perspective::isEgoPerspective ( std::string_view  iri)
static
Parameters
irian IRI
Returns
true if the IRI denotes the egoIRI perspective

Definition at line 27 of file Perspective.cpp.

27  {
28  return iri.empty() || iri == GlobalSettings::egoIRI()->stringForm();
29 }

◆ isEgoPerspective() [2/2]

static bool knowrob::Perspective::isEgoPerspective ( std::string_view  iri)
static
Parameters
irian IRI
Returns
true if the IRI denotes the egoIRI perspective

Member Data Documentation

◆ atom_

IRIAtomPtr knowrob::Perspective::atom_
protected

Definition at line 65 of file Perspective.h.

◆ perspectiveMap_

std::map< std::string_view, std::shared_ptr< Perspective > > Perspective::perspectiveMap_
staticprotected
Initial value:
=
std::map<std::string_view, std::shared_ptr<Perspective>>()

Definition at line 64 of file Perspective.h.


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