FunctionalVisitor.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4
5#include "Visitor.h"
6
7namespace armarx::armem::wm
8{
9
10 /**
11 * @brief A `Visitor` which can be parametrized by `std::function`
12 * instead of inheriting and overriding.
13 */
15 {
16 public:
18 virtual ~FunctionalVisitor() override;
19
20 bool
25
26 bool
27 visitEnter(CoreSegment& coreSegment) override
28 {
29 return coreSegmentFn ? coreSegmentFn(coreSegment) : Visitor::visitEnter(coreSegment);
30 }
31
32 bool
33 visitEnter(ProviderSegment& providerSegment) override
34 {
35 return providerSegmentFn ? providerSegmentFn(providerSegment)
36 : Visitor::visitEnter(providerSegment);
37 }
38
39 bool
40 visitEnter(Entity& entity) override
41 {
42 return entityFn ? entityFn(entity) : Visitor::visitEnter(entity);
43 }
44
45 bool
46 visitEnter(EntitySnapshot& snapshot) override
47 {
48 return snapshotFn ? snapshotFn(snapshot) : Visitor::visitEnter(snapshot);
49 }
50
51 bool
52 visit(EntityInstance& instance) override
53 {
54 return instanceFn ? instanceFn(instance) : Visitor::visit(instance);
55 }
56
57 // Const versions
58
59
60 bool
65
66 bool
67 visitEnter(const CoreSegment& coreSegment) override
68 {
69 return coreSegmentConstFn ? coreSegmentConstFn(coreSegment)
70 : Visitor::visitEnter(coreSegment);
71 }
72
73 bool
74 visitEnter(const ProviderSegment& providerSegment) override
75 {
76 return providerSegmentConstFn ? providerSegmentConstFn(providerSegment)
77 : Visitor::visitEnter(providerSegment);
78 }
79
80 bool
81 visitEnter(const Entity& entity) override
82 {
83 return entityConstFn ? entityConstFn(entity) : Visitor::visitEnter(entity);
84 }
85
86 bool
87 visitEnter(const EntitySnapshot& snapshot) override
88 {
89 return snapshotConstFn ? snapshotConstFn(snapshot) : Visitor::visitEnter(snapshot);
90 }
91
92 bool
93 visit(const EntityInstance& instance) override
94 {
95 return instanceConstFn ? instanceConstFn(instance) : Visitor::visit(instance);
96 }
97
98 std::function<bool(Memory& memory)> memoryFn;
99 std::function<bool(const Memory& memory)> memoryConstFn;
100
101 std::function<bool(CoreSegment& coreSegment)> coreSegmentFn;
102 std::function<bool(const CoreSegment& coreSegment)> coreSegmentConstFn;
103
104 std::function<bool(ProviderSegment& providerSegment)> providerSegmentFn;
105 std::function<bool(const ProviderSegment& providerSegment)> providerSegmentConstFn;
106
107 std::function<bool(Entity& entity)> entityFn;
108 std::function<bool(const Entity& entity)> entityConstFn;
109
110 std::function<bool(EntitySnapshot& snapshot)> snapshotFn;
111 std::function<bool(const EntitySnapshot& snapshot)> snapshotConstFn;
112
113 std::function<bool(EntityInstance& instance)> instanceFn;
114 std::function<bool(const EntityInstance& instance)> instanceConstFn;
115 };
116
117} // namespace armarx::armem::wm
Client-side working memory core segment.
Client-side working entity instance.
Client-side working memory entity snapshot.
Client-side working memory entity.
bool visitEnter(const ProviderSegment &providerSegment) override
bool visit(const EntityInstance &instance) override
bool visit(EntityInstance &instance) override
std::function< bool(const CoreSegment &coreSegment)> coreSegmentConstFn
bool visitEnter(Entity &entity) override
std::function< bool(const Memory &memory)> memoryConstFn
bool visitEnter(CoreSegment &coreSegment) override
bool visitEnter(const Entity &entity) override
std::function< bool(const EntityInstance &instance)> instanceConstFn
std::function< bool(const EntitySnapshot &snapshot)> snapshotConstFn
bool visitEnter(const Memory &memory) override
std::function< bool(CoreSegment &coreSegment)> coreSegmentFn
bool visitEnter(EntitySnapshot &snapshot) override
std::function< bool(EntitySnapshot &snapshot)> snapshotFn
bool visitEnter(const EntitySnapshot &snapshot) override
std::function< bool(const ProviderSegment &providerSegment)> providerSegmentConstFn
std::function< bool(EntityInstance &instance)> instanceFn
std::function< bool(Entity &entity)> entityFn
std::function< bool(Memory &memory)> memoryFn
bool visitEnter(ProviderSegment &providerSegment) override
std::function< bool(ProviderSegment &providerSegment)> providerSegmentFn
std::function< bool(const Entity &entity)> entityConstFn
bool visitEnter(const CoreSegment &coreSegment) override
bool visitEnter(Memory &memory) override
Client-side working memory.
Client-side working memory provider segment.
virtual bool visit(EntityInstance &instance)
Definition Visitor.h:90
virtual bool visitEnter(Memory &memory)
Definition Visitor.h:30
Brief description of class memory.
Definition memory.h:39