8 #include "knowrob/storage/ReificationContainer.h"
9 #include "knowrob/storage/ReifiedTriple.h"
16 : originalTriples_(std::move(originalTriples)),
17 vocabulary_(std::move(vocabulary)),
18 reifiedNames_(std::move(reifiedNames)) {
25 uint32_t tripleIndex) {
26 std::shared_ptr<ReifiedTriple> reified;
27 if (reifiedNames && !reifiedNames->empty()) {
28 reified = std::make_shared<ReifiedTriple>(triple, vocabulary, (*reifiedNames)[tripleIndex - 1]);
30 reified = std::make_shared<ReifiedTriple>(triple, vocabulary);
32 return [reified, it = reified->begin()]()
mutable ->
const TriplePtr * {
33 if (it == reified->end())
return nullptr;
39 struct IterationData {
42 : vocabulary(std::move(vocabulary)),
44 it(originalTriples->begin()),
45 end(originalTriples->end()),
46 reifiedNames(std::move(reifiedNames)),
60 auto data = std::make_shared<reification::IterationData>(
63 return [data]()
mutable ->
const TriplePtr * {
64 if (data->reifiedGen) {
66 const TriplePtr *nextReified = data->reifiedGen();
67 if (nextReified)
return nextReified;
68 else data->reifiedGen =
nullptr;
71 if (data->it == data->end)
return nullptr;
72 data->tripleIndex += 1;
75 data->reifiedGen =
getReifiedGenerator(*next->ptr, data->vocabulary, data->reifiedNames, data->tripleIndex);
76 return data->reifiedGen();
TripleContainer::ConstGenerator getReifiedGenerator(const Triple &triple, const VocabularyPtr &vocabulary, const ReifiedNames &reifiedNames, uint32_t tripleIndex)
TripleContainerPtr originalTriples_
ReifiedNames reifiedNames_
ReificationContainer(TripleContainerPtr originalTriples, VocabularyPtr vocabulary, ReifiedNames reifiedNames)
VocabularyPtr vocabulary_
ConstGenerator cgenerator() const override
static bool isReifiable(const Triple &triple)
std::function< const TriplePtr *()> ConstGenerator
std::shared_ptr< TripleContainer > TripleContainerPtr
std::shared_ptr< std::vector< IRIAtomPtr > > ReifiedNames
std::shared_ptr< Vocabulary > VocabularyPtr