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

#include <ReificationContainer.h>

Inheritance diagram for knowrob::ReificationContainer:
Collaboration diagram for knowrob::ReificationContainer:

Public Member Functions

 ReificationContainer (TripleContainerPtr originalTriples, VocabularyPtr vocabulary, ReifiedNames reifiedNames)
 
ConstGenerator cgenerator () const override
 
 ReificationContainer (TripleContainerPtr originalTriples, VocabularyPtr vocabulary, ReifiedNames reifiedNames)
 
ConstGenerator cgenerator () const override
 
- Public Member Functions inherited from knowrob::TripleContainer
virtual ~TripleContainer ()=default
 
iterator begin () const
 
bool empty () const
 
virtual bool isMutable () const
 
virtual ~TripleContainer ()=default
 
iterator begin () const
 
bool empty () const
 
virtual bool isMutable () const
 

Protected Attributes

TripleContainerPtr originalTriples_
 
VocabularyPtr vocabulary_
 
ReifiedNames reifiedNames_
 

Additional Inherited Members

- Public Types inherited from knowrob::TripleContainer
using ConstGenerator = std::function< const TriplePtr *()>
 
using ConstGenerator = std::function< const TriplePtr *()>
 
- Static Public Member Functions inherited from knowrob::TripleContainer
static iterator end ()
 
static iterator end ()
 

Detailed Description

A container that reifies triples of an input container.

Definition at line 20 of file ReificationContainer.h.

Constructor & Destructor Documentation

◆ ReificationContainer() [1/2]

ReificationContainer::ReificationContainer ( TripleContainerPtr  originalTriples,
VocabularyPtr  vocabulary,
ReifiedNames  reifiedNames 
)
explicit

Definition at line 13 of file ReificationContainer.cpp.

16  : originalTriples_(std::move(originalTriples)),
17  vocabulary_(std::move(vocabulary)),
18  reifiedNames_(std::move(reifiedNames)) {
19 }

◆ ReificationContainer() [2/2]

knowrob::ReificationContainer::ReificationContainer ( TripleContainerPtr  originalTriples,
VocabularyPtr  vocabulary,
ReifiedNames  reifiedNames 
)
explicit

Member Function Documentation

◆ cgenerator() [1/2]

TripleContainer::ConstGenerator ReificationContainer::cgenerator ( ) const
overridevirtual
Returns
a generator function that returns a const pointer to a triple.

Implements knowrob::TripleContainer.

Definition at line 59 of file ReificationContainer.cpp.

59  {
60  auto data = std::make_shared<reification::IterationData>(
62 
63  return [data]() mutable -> const TriplePtr * {
64  if (data->reifiedGen) {
65  // if a reified triple is available, return it
66  const TriplePtr *nextReified = data->reifiedGen();
67  if (nextReified) return nextReified;
68  else data->reifiedGen = nullptr;
69  }
70  // else process the next triple from the original container
71  if (data->it == data->end) return nullptr;
72  data->tripleIndex += 1;
73  const TriplePtr *next = &*data->it++;
74  if (ReifiedTriple::isReifiable(*next->ptr)) {
75  data->reifiedGen = getReifiedGenerator(*next->ptr, data->vocabulary, data->reifiedNames, data->tripleIndex);
76  return data->reifiedGen();
77  } else {
78  return next;
79  }
80  };
81 }
TripleContainer::ConstGenerator getReifiedGenerator(const Triple &triple, const VocabularyPtr &vocabulary, const ReifiedNames &reifiedNames, uint32_t tripleIndex)
static bool isReifiable(const Triple &triple)

◆ cgenerator() [2/2]

ConstGenerator knowrob::ReificationContainer::cgenerator ( ) const
overridevirtual
Returns
a generator function that returns a const pointer to a triple.

Implements knowrob::TripleContainer.

Member Data Documentation

◆ originalTriples_

TripleContainerPtr knowrob::ReificationContainer::originalTriples_
protected

Definition at line 30 of file ReificationContainer.h.

◆ reifiedNames_

ReifiedNames knowrob::ReificationContainer::reifiedNames_
protected

Definition at line 32 of file ReificationContainer.h.

◆ vocabulary_

VocabularyPtr knowrob::ReificationContainer::vocabulary_
protected

Definition at line 31 of file ReificationContainer.h.


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