From cf446968a0246794fac8d77108195b49476c0310 Mon Sep 17 00:00:00 2001 From: Rainer Kartmann <rainer.kartmann@kit.edu> Date: Mon, 10 May 2021 18:49:35 +0200 Subject: [PATCH] Fix wm visitor --- .../armem/core/workingmemory/Visitor.cpp | 80 ++++++++++++++----- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/source/RobotAPI/libraries/armem/core/workingmemory/Visitor.cpp b/source/RobotAPI/libraries/armem/core/workingmemory/Visitor.cpp index 986612d1e..ede63a494 100644 --- a/source/RobotAPI/libraries/armem/core/workingmemory/Visitor.cpp +++ b/source/RobotAPI/libraries/armem/core/workingmemory/Visitor.cpp @@ -19,62 +19,82 @@ namespace armarx::armem::wm bool Visitor::applyTo(Memory& memory) { + bool cont = true; + visitEnter(memory); for (auto& [_, coreSeg] : memory) { if (!applyTo(coreSeg)) { - return false; + cont = false; + break; } } - return true; + visitExit(memory); + return cont; } bool Visitor::applyTo(CoreSegment& coreSegment) { + bool cont = true; + visitEnter(coreSegment); for (auto& [_, provSeg] : coreSegment) { if (!applyTo(provSeg)) { - return false; + cont = false; + break; } } - return true; + visitExit(coreSegment); + return cont; } bool Visitor::applyTo(ProviderSegment& providerSegment) { + bool cont = true; + visitEnter(providerSegment); for (auto& [_, entity] : providerSegment) { if (!applyTo(entity)) { - return false; + cont = false; + break; } } - return true; + visitExit(providerSegment); + return cont; } bool Visitor::applyTo(Entity& entity) { + bool cont = true; + visitEnter(entity); for (auto& [_, snapshot] : entity) { if (!applyTo(snapshot)) { - return false; + cont = false; + break; } } - return true; + visitExit(entity); + return cont; } bool Visitor::applyTo(EntitySnapshot& snapshot) { + bool cont = true; + visitEnter(snapshot); for (auto& instance : snapshot) { if (!applyTo(instance)) { - return false; + cont = false; + break; } } - return true; + visitExit(snapshot); + return cont; } bool Visitor::applyTo(EntityInstance& instance) @@ -85,62 +105,82 @@ namespace armarx::armem::wm bool Visitor::applyTo(const Memory& memory) { + bool cont = true; + visitEnter(memory); for (const auto& [_, coreSeg] : memory) { if (!applyTo(coreSeg)) { - return false; + cont = false; + break; } } - return true; + visitExit(memory); + return cont; } bool Visitor::applyTo(const CoreSegment& coreSegment) { + bool cont = true; + visitEnter(coreSegment); for (const auto& [_, provSeg] : coreSegment) { if (!applyTo(provSeg)) { - return false; + cont = false; + break; } } - return true; + visitExit(coreSegment); + return cont; } bool Visitor::applyTo(const ProviderSegment& providerSegment) { + bool cont = true; + visitEnter(providerSegment); for (const auto& [_, entity] : providerSegment) { if (!applyTo(entity)) { - return false; + cont = false; + break; } } - return true; + visitExit(providerSegment); + return cont; } bool Visitor::applyTo(const Entity& entity) { + bool cont = true; + visitEnter(entity); for (const auto& [_, snapshot] : entity) { if (!applyTo(snapshot)) { - return false; + cont = false; + break; } } - return true; + visitExit(entity); + return cont; } bool Visitor::applyTo(const EntitySnapshot& snapshot) { + bool cont = true; + visitEnter(snapshot); for (const auto& instance : snapshot) { if (!applyTo(instance)) { - return false; + cont = false; + break; } } - return true; + visitExit(snapshot); + return cont; } bool Visitor::applyTo(const EntityInstance& instance) -- GitLab