CoreSegmentBase.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4
5// BaseClass
9
10#include "MemoryItem.h"
11#include "ProviderSegmentBase.h"
12
14{
15 /// @brief Interface functions for the longterm memory classes
16 template <class _ProviderSegmentT>
18 {
19 public:
21 {
23 };
24
25 public:
26 using ProviderSegmentT = _ProviderSegmentT;
27
29
30 /// return the full sub-ltm as a wm::CoreSegment with only references
31 /// the ltm may be huge, use with caution
32 void
37
38 void
40 {
41 _loadLatestNReferences(n, coreSeg);
42 }
43
44 /// convert the references of the input into a wm::Memory
45 void
47 {
48 _resolve(coreSeg);
49 }
50
51 /// encode the content of a wm::Memory and store
52 void
53 store(const armem::wm::CoreSegment& coreSeg, bool simulatedVersion)
54 {
55 _store(coreSeg, simulatedVersion);
56 }
57
58 /// statistics
59 void
61 {
62 statistics.recordedProviderSegments = 0;
63 }
64
65 Statistics
67 {
68 return statistics;
69 }
70
71 /// iterate over all provider segments of this ltm
72 bool
73 forEachProviderSegment(std::function<void(ProviderSegmentT&)> func) const
74 {
75 return _implForEachProviderSegment(func);
76 }
77
78 /// check if provider segment exists
79 bool
80 hasProviderSegment(const std::string& providerSegmentName) const
81 {
82 return _implHasProviderSegment(providerSegmentName);
83 }
84
85 /// find provider segment
86 std::shared_ptr<ProviderSegmentT>
87 findProviderSegment(const std::string& providerSegmentName) const
88 {
89 return _implFindProviderSegment(providerSegmentName);
90 }
91
92 /// get aron type
94 aronType() const
95 {
96 return nullptr;
97 }
98
99 /// get level name
100 static std::string
102 {
103 return "LT-CoreSegment";
104 }
105
106 protected:
110 virtual void _store(const armem::wm::CoreSegment& c, bool simulatedVersion = false) = 0;
111
112 // Implementation methods - subclasses override these
113 // Thread safety is handled by DiskPersistence's per-directory mutexes
114 virtual bool _implForEachProviderSegment(std::function<void(ProviderSegmentT&)> func) const = 0;
115 virtual bool _implHasProviderSegment(const std::string& providerSegmentName) const = 0;
116 virtual std::shared_ptr<ProviderSegmentT> _implFindProviderSegment(const std::string& providerSegmentName) const = 0;
117
118 protected:
120 };
121} // namespace armarx::armem::server::ltm::detail
constexpr T c
Interface functions for the longterm memory classes.
virtual bool _implForEachProviderSegment(std::function< void(ProviderSegmentT &)> func) const =0
virtual void _loadAllReferences(armem::wm::CoreSegment &)=0
virtual void _loadLatestNReferences(int n, armem::wm::CoreSegment &c)=0
void store(const armem::wm::CoreSegment &coreSeg, bool simulatedVersion)
encode the content of a wm::Memory and store
void resolve(armem::wm::CoreSegment &coreSeg)
convert the references of the input into a wm::Memory
std::shared_ptr< ProviderSegmentT > findProviderSegment(const std::string &providerSegmentName) const
find provider segment
void loadAllReferences(armem::wm::CoreSegment &coreSeg)
return the full sub-ltm as a wm::CoreSegment with only references the ltm may be huge,...
virtual void _store(const armem::wm::CoreSegment &c, bool simulatedVersion=false)=0
bool hasProviderSegment(const std::string &providerSegmentName) const
check if provider segment exists
bool forEachProviderSegment(std::function< void(ProviderSegmentT &)> func) const
iterate over all provider segments of this ltm
virtual bool _implHasProviderSegment(const std::string &providerSegmentName) const =0
static std::string getLevelName()
get level name
virtual void _resolve(armem::wm::CoreSegment &)=0
aron::type::ObjectPtr aronType() const
get aron type
virtual std::shared_ptr< ProviderSegmentT > _implFindProviderSegment(const std::string &providerSegmentName) const =0
void loadLatestNReferences(int n, armem::wm::CoreSegment &coreSeg)
MemoryItem(const std::string &exportName, const MemoryID &)
MemoryItem(const std::string &exportName, const MemoryID &)
Client-side working memory core segment.
std::shared_ptr< Object > ObjectPtr
Definition Object.h:36