Skip to content
Snippets Groups Projects
Commit b7dd22aa authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Remove duplicated function def, rename variables

parent 6a246e9a
No related branches found
No related tags found
No related merge requests found
#include "Visitor.h"
#include "FunctionalVisitor.h"
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
......@@ -9,183 +9,4 @@
namespace armarx::armem::wm
{
Visitor::Visitor()
{
}
Visitor::~Visitor()
{
}
bool Visitor::applyTo(Memory& memory)
{
bool cont = true;
visitEnter(memory);
for (auto& [_, coreSeg] : memory)
{
if (!applyTo(coreSeg))
{
cont = false;
break;
}
}
visitExit(memory);
return cont;
}
bool Visitor::applyTo(CoreSegment& coreSegment)
{
bool cont = true;
visitEnter(coreSegment);
for (auto& [_, provSeg] : coreSegment)
{
if (!applyTo(provSeg))
{
cont = false;
break;
}
}
visitExit(coreSegment);
return cont;
}
bool Visitor::applyTo(ProviderSegment& providerSegment)
{
bool cont = true;
visitEnter(providerSegment);
for (auto& [_, entity] : providerSegment)
{
if (!applyTo(entity))
{
cont = false;
break;
}
}
visitExit(providerSegment);
return cont;
}
bool Visitor::applyTo(Entity& entity)
{
bool cont = true;
visitEnter(entity);
for (auto& [_, snapshot] : entity)
{
if (!applyTo(snapshot))
{
cont = false;
break;
}
}
visitExit(entity);
return cont;
}
bool Visitor::applyTo(EntitySnapshot& snapshot)
{
bool cont = true;
visitEnter(snapshot);
for (auto& instance : snapshot)
{
if (!applyTo(instance))
{
cont = false;
break;
}
}
visitExit(snapshot);
return cont;
}
bool Visitor::applyTo(EntityInstance& instance)
{
return visit(instance);
}
bool Visitor::applyTo(const Memory& memory)
{
bool cont = true;
visitEnter(memory);
for (const auto& [_, coreSeg] : memory)
{
if (!applyTo(coreSeg))
{
cont = false;
break;
}
}
visitExit(memory);
return cont;
}
bool Visitor::applyTo(const CoreSegment& coreSegment)
{
bool cont = true;
visitEnter(coreSegment);
for (const auto& [_, provSeg] : coreSegment)
{
if (!applyTo(provSeg))
{
cont = false;
break;
}
}
visitExit(coreSegment);
return cont;
}
bool Visitor::applyTo(const ProviderSegment& providerSegment)
{
bool cont = true;
visitEnter(providerSegment);
for (const auto& [_, entity] : providerSegment)
{
if (!applyTo(entity))
{
cont = false;
break;
}
}
visitExit(providerSegment);
return cont;
}
bool Visitor::applyTo(const Entity& entity)
{
bool cont = true;
visitEnter(entity);
for (const auto& [_, snapshot] : entity)
{
if (!applyTo(snapshot))
{
cont = false;
break;
}
}
visitExit(entity);
return cont;
}
bool Visitor::applyTo(const EntitySnapshot& snapshot)
{
bool cont = true;
visitEnter(snapshot);
for (const auto& instance : snapshot)
{
if (!applyTo(instance))
{
cont = false;
break;
}
}
visitExit(snapshot);
return cont;
}
bool Visitor::applyTo(const EntityInstance& instance)
{
return visit(instance);
}
}
......@@ -59,48 +59,48 @@ namespace armarx::armem::wm
bool visitEnter(const Memory& memory) override
{
return memoryFn ? constMemoryFn(memory) : Visitor::visitEnter(memory);
return memoryFn ? memoryConstFn(memory) : Visitor::visitEnter(memory);
}
bool visitEnter(const CoreSegment& coreSegment) override
{
return coreSegmentFn ? constCoreSegmentFn(coreSegment) : Visitor::visitEnter(coreSegment);
return coreSegmentFn ? coreSegmentConstFn(coreSegment) : Visitor::visitEnter(coreSegment);
}
bool visitEnter(const ProviderSegment& providerSegment) override
{
return providerSegmentFn ? constProviderSegmentFn(providerSegment) : Visitor::visitEnter(providerSegment);
return providerSegmentFn ? providerSegmentConstFn(providerSegment) : Visitor::visitEnter(providerSegment);
}
bool visitEnter(const Entity& entity) override
{
return entityFn ? constEntityFn(entity) : Visitor::visitEnter(entity);
return entityFn ? entityConstFn(entity) : Visitor::visitEnter(entity);
}
bool visitEnter(const EntitySnapshot& snapshot) override
{
return memoryFn ? constSnapshotFn(snapshot) : Visitor::visitEnter(snapshot);
return memoryFn ? snapshotConstFn(snapshot) : Visitor::visitEnter(snapshot);
}
bool visit(const EntityInstance& instance) override
{
return instanceFn ? constInstanceFn(instance) : Visitor::visit(instance);
return instanceFn ? instanceConstFn(instance) : Visitor::visit(instance);
}
std::function<bool(Memory& memory)> memoryFn;
std::function<bool(const Memory& memory)> constMemoryFn;
std::function<bool(const Memory& memory)> memoryConstFn;
std::function<bool(CoreSegment& coreSegment)> coreSegmentFn;
std::function<bool(const CoreSegment& coreSegment)> constCoreSegmentFn;
std::function<bool(const CoreSegment& coreSegment)> coreSegmentConstFn;
std::function<bool(ProviderSegment& providerSegment)> providerSegmentFn;
std::function<bool(const ProviderSegment& providerSegment)> constProviderSegmentFn;
std::function<bool(const ProviderSegment& providerSegment)> providerSegmentConstFn;
std::function<bool(Entity& entity)> entityFn;
std::function<bool(const Entity& entity)> constEntityFn;
std::function<bool(const Entity& entity)> entityConstFn;
std::function<bool(EntitySnapshot& snapshot)> snapshotFn;
std::function<bool(const EntitySnapshot& snapshot)> constSnapshotFn;
std::function<bool(const EntitySnapshot& snapshot)> snapshotConstFn;
std::function<bool(EntityInstance& instance)> instanceFn;
std::function<bool(const EntityInstance& instance)> constInstanceFn;
std::function<bool(const EntityInstance& instance)> instanceConstFn;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment