ProviderSegmentBase.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4
8
9#include "EntityBase.h"
10#include "MemoryItem.h"
11
13{
14 /// @brief Interface functions for the longterm memory classes
15 template <class _EntityT>
17 {
18 public:
20 {
22 };
23
24 public:
25 using EntityT = _EntityT;
26
28
29 /// return the full sub-ltm as a wm::ProviderSegment with only references
30 /// the ltm may be huge, use with caution
31 void
36
37 void
42
43 /// convert the references of the input into a wm::Memory
44 void
46 {
47 _resolve(provSeg);
48 }
49
50 /// encode the content of a wm::Memory and store
51 void
52 store(const armem::wm::ProviderSegment& provSeg, bool simulatedVersion)
53 {
54 _store(provSeg, simulatedVersion);
55 }
56
57 /// statistics
58 void
60 {
61 statistics.recordedEntities = 0;
62 }
63
64 Statistics
66 {
67 return statistics;
68 }
69
70 /// iterate over all core segments of this ltm
71 bool
72 forEachEntity(std::function<void(EntityT&)> func) const
73 {
74 return _implForEachEntity(func);
75 }
76
77 /// check if entity segment exists
78 bool
79 hasEntity(const std::string& entityName) const
80 {
81 return _implHasEntity(entityName);
82 }
83
84 /// find entity segment
85 std::shared_ptr<EntityT>
86 findEntity(const std::string& entityName) const
87 {
88 return _implFindEntity(entityName);
89 }
90
91 ///get aron type
93 aronType() const
94 {
95 return nullptr;
96 }
97
98 static std::string
100 {
101 return "LT-ProviderSegment";
102 }
103
104 protected:
108 virtual void _store(const armem::wm::ProviderSegment& p, bool simulatedVersion = false) = 0;
109
110 // Implementation methods - subclasses override these
111 // Thread safety is handled by DiskPersistence's per-directory mutexes
112 virtual bool _implForEachEntity(std::function<void(EntityT&)> func) const = 0;
113 virtual bool _implHasEntity(const std::string& entityName) const = 0;
114 virtual std::shared_ptr<EntityT> _implFindEntity(const std::string& entityName) const = 0;
115
116 protected:
118 };
119} // namespace armarx::armem::server::ltm::detail
MemoryItem(const std::string &exportName, const MemoryID &)
Interface functions for the longterm memory classes.
virtual bool _implHasEntity(const std::string &entityName) const =0
virtual void _resolve(armem::wm::ProviderSegment &)=0
void loadLatestNReferences(int n, armem::wm::ProviderSegment &provSeg)
virtual void _store(const armem::wm::ProviderSegment &p, bool simulatedVersion=false)=0
virtual std::shared_ptr< EntityT > _implFindEntity(const std::string &entityName) const =0
virtual bool _implForEachEntity(std::function< void(EntityT &)> func) const =0
bool hasEntity(const std::string &entityName) const
check if entity segment exists
void store(const armem::wm::ProviderSegment &provSeg, bool simulatedVersion)
encode the content of a wm::Memory and store
aron::type::ObjectPtr aronType() const
get aron type
void loadAllReferences(armem::wm::ProviderSegment &provSeg)
return the full sub-ltm as a wm::ProviderSegment with only references the ltm may be huge,...
std::shared_ptr< EntityT > findEntity(const std::string &entityName) const
find entity segment
virtual void _loadLatestNReferences(int n, armem::wm::ProviderSegment &p)=0
virtual void _loadAllReferences(armem::wm::ProviderSegment &)=0
bool forEachEntity(std::function< void(EntityT &)> func) const
iterate over all core segments of this ltm
void resolve(armem::wm::ProviderSegment &provSeg)
convert the references of the input into a wm::Memory
MemoryItem(const std::string &exportName, const MemoryID &)
Client-side working memory provider segment.
std::shared_ptr< Object > ObjectPtr
Definition Object.h:36