ReadWritePluginUser.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <RobotAPI/interface/armem/server/MemoryInterface.h>
9
11{
12
13 class Plugin;
14
15 /**
16 * @brief Base class of memory server components.
17 *
18 * Implements the server ice interfaces using the ice adapter of the plugin.
19 */
21 virtual public ManagedIceObject,
22 virtual public MemoryInterface,
24 {
25 public:
27 virtual ~ReadWritePluginUser() override;
28
29
30 void setMemoryName(const std::string& memoryName);
31
32
33 // WritingInterface interface
34 virtual data::AddSegmentsResult
35 addSegments(const data::AddSegmentsInput& input,
36 const Ice::Current& = Ice::emptyCurrent) override;
37 data::AddSegmentsResult addSegments(const data::AddSegmentsInput& input,
38 bool addCoreSegments);
39
40 virtual data::CommitResult commit(const data::Commit& commit,
41 const Ice::Current& = Ice::emptyCurrent) override;
42
43 /**
44 * Clears the working memory usings its clear feature.
45 */
46 virtual void clearWorkingMemory(const Ice::Current& = Ice::emptyCurrent) override;
47
48 // ReadingInterface interface
49 virtual armem::query::data::Result query(const armem::query::data::Input& input,
50 const Ice::Current& = Ice::emptyCurrent) override;
51
52 /**
53 * Queries only the LTMs of the memory server.
54 * @param storeIntoWM if set, the result is also stored into the working memory
55 * no matter how the recording mode is set.
56 */
57 virtual armem::query::data::Result
58 queryLTM(const armem::query::data::Input& input,
59 bool storeIntoWM,
60 const Ice::Current& = Ice::emptyCurrent) override;
61
62 virtual armem::structure::data::GetServerStructureResult
63 getServerStructure(const Ice::Current& = Ice::emptyCurrent) override;
64
65
66 // StoringInterface interface
67 virtual dto::DirectlyStoreResult
68 directlyStore(const dto::DirectlyStoreInput&,
69 const Ice::Current& = Ice::emptyCurrent) override;
70 virtual dto::StartRecordResult
71 startRecord(const dto::StartRecordInput& startRecordInput,
72 const Ice::Current& = Ice::emptyCurrent) override;
73 virtual dto::StopRecordResult stopRecord(const Ice::Current& = Ice::emptyCurrent) override;
74 virtual dto::RecordStatusResult
75 getRecordStatus(const Ice::Current& = Ice::emptyCurrent) override;
76
77 // ActionsInterface interface
78 virtual armem::actions::GetActionsOutputSeq
79 getActions(const armem::actions::GetActionsInputSeq& inputs);
80 virtual armem::actions::ExecuteActionOutputSeq
81 executeActions(const armem::actions::ExecuteActionInputSeq& inputs);
82
83 virtual armem::actions::GetActionsOutputSeq
84 getActions(const armem::actions::GetActionsInputSeq& inputs,
85 const ::Ice::Current&) override;
86 virtual armem::actions::ExecuteActionOutputSeq
87 executeActions(const armem::actions::ExecuteActionInputSeq& inputs,
88 const ::Ice::Current&) override;
89
90 // PredictingInterface interface
91 virtual armem::prediction::data::PredictionResultSeq
92 predict(const armem::prediction::data::PredictionRequestSeq& requests);
93
94 // Unless you need very unusual behavior from this method for your memory server,
95 // it is better to set the available prediction engines in the memory itself
96 // and let it handle the requests than to override this.
97 virtual armem::prediction::data::EngineSupportMap getAvailableEngines();
98
99 virtual armem::prediction::data::PredictionResultSeq
100 predict(const armem::prediction::data::PredictionRequestSeq& requests,
101 const ::Ice::Current&) override;
102 virtual armem::prediction::data::EngineSupportMap
103 getAvailableEngines(const ::Ice::Current&) override;
104
105 //ReloadFromLTMOnStartup
107
108 /**
109 * Loads the data of the LTMs into the WM.
110 */
111 virtual void loadLTMintoWM(bool complete, const ::Ice::Current&) override;
112
113 /**
114 * @brief loads data from a specified LTM export into the currently running WM (needs to already have the CoreSegments)
115 *
116 * This function loads an LTM specified by export_path and memoryName into the current WM.
117 * It handles if the path is not a correct LTM export.
118 * If you do this multiple times the LTM is always appended to the WM ,meaning you can load several LTM exports into the same WM.
119 * This does not exclude the maxHistory size from working! If you load to much snapshots they will still be discarded.
120 *
121 * @param export_path path to the export folder (needs to be a string with '/' as delimiter)
122 * @param memoryName name of the memory server (e.g. 'Object', 'Skill')
123 * @param coreSegmentNames list (std::vector) of names of core segments which should be loaded, keep empty or do not provide if you want to load all core segments
124 * @param addNonExistingCoreSegments (not yet supported)
125 * @param amountOfSnapshotsPerSegmentToLoad amount of snapshots loaded (per core segment); is the same for all core segments
126 *
127 * @return bool true if everything worked fine, false if some error arose permitting the LTM to be loaded
128 */
129 bool loadExportIntoWM(const std::string& export_path,
130 const std::string& memoryName,
131 const std::vector<std::string>& coreSegmentName = {},
132 bool addNonExistingCoreSegments = false,
133 int amountOfSnapshotsPerSegmentToLoad = -1,
134 const ::Ice::Current& = Ice::emptyCurrent) override;
135
136 /**
137 * @brief loads data from a specified LTM export into the currently running WM (needs to already have the CoreSegments)
138 *
139 * This function loads an LTM specified by directory, exportName and memoryName into the current WM.
140 * It handles if the path is not a correct LTM export.
141 * If you do this multiple times the LTM is always appended to the WM ,meaning you can load several LTM exports into the same WM.
142 * This does not exclude the maxHistory size from working! If you load to much snapshots they will still be discarded.
143 *
144 * @param directory path (as string) to the export directory
145 * @param exportName name of the export folder (often 'MemoryExport')
146 * @param memoryName name of the memory server (e.g. 'Object', 'Skill')
147 * @param coreSegmentNames list (std::vector) of names of core segments which should be loaded, keep empty or do not provide if you want to load all core segments
148 * @param addNonExistingCoreSegments (not yet supported)
149 * @param amountOfSnapshotsPerSegmentToLoad amount of snapshots loaded (per core segment); is the same for all core segments
150 *
151 * @return bool true if everything worked fine, false if some error arose permitting the LTM to be loaded
152 */
153 bool loadExportIntoWM(const std::string& directory,
154 const std::string& exportName,
155 const std::string& memoryName,
156 const std::vector<std::string>& coreSegmentName = {},
157 bool addNonExistingCoreSegments = false,
158 int amountOfSnapshotsPerSegmentToLoad = -1);
159
160 /**
161 * @brief Use a rest persistence strategy for storing the wm as ltm
162 * Uses a rest server as ltm sink.
163 *
164 * @param identifier unique strategy name
165 * @param exportName memory export name
166 * @param host name of the host where the rest server is running
167 * @param port network port at which the rest server is running
168 * @param overwritePrevStrategy if set the ltm only contains this new strategy, if false it will be appended to the other(s)
169 */
170 virtual void useRestPersistenceStrategy(const std::string& identifier,
171 const std::string& exportName,
172 const std::string& host,
173 int port,
174 bool overwritePrevStrategy,
175 const ::Ice::Current&) override;
176
177 /**
178 * @brief Use a disk persistence strategy for storing the wm as ltm
179 * Uses the disk as ltm sink.
180 *
181 * @param identifier unique strategy name
182 * @param exportName memory export name
183 * @param exportPath path where the export is stored on disk
184 * @param overwritePrevStrategy if set the ltm only contains this new strategy, if false it will be appended to the other(s)
185 */
186 virtual void useDiskPersistenceStrategy(const std::string& identifier,
187 const std::string& exportName,
188 const std::string& exportPath,
189 bool overwritePrevStrategy,
190 const ::Ice::Current&) override;
191
192 /**
193 * @brief Use a mongodb persistence strategy for storing the wm as ltm
194 * Uses a mongodb as ltm sink.
195 *
196 * NOTE (TODO): Not implemented
197 */
198 virtual void useMongoDbPersistenceStrategy(const std::string& identifier,
199 const std::string& exportName,
200 bool overwritePrevStrategy,
201 const ::Ice::Current&) override;
202
203 public:
205
208
210
211
212 private:
213 plugins::Plugin* plugin = nullptr;
214 };
215
216} // namespace armarx::armem::server::plugins
217
218namespace armarx::armem::server
219{
221}
ManagedIceObject(ManagedIceObject const &other)
A memory name system client which listens to the memory updates topic (MemoryListenerInterface).
Helps connecting a Memory server to the Ice interface.
A memory storing data on the hard drive and in mongodb (needs 'armarx memory start' to start the mong...
Definition Memory.h:24
Base class of memory server components.
virtual void useDiskPersistenceStrategy(const std::string &identifier, const std::string &exportName, const std::string &exportPath, bool overwritePrevStrategy, const ::Ice::Current &) override
Use a disk persistence strategy for storing the wm as ltm Uses the disk as ltm sink.
virtual dto::StopRecordResult stopRecord(const Ice::Current &=Ice::emptyCurrent) override
virtual armem::query::data::Result query(const armem::query::data::Input &input, const Ice::Current &=Ice::emptyCurrent) override
virtual data::CommitResult commit(const data::Commit &commit, const Ice::Current &=Ice::emptyCurrent) override
virtual armem::query::data::Result queryLTM(const armem::query::data::Input &input, bool storeIntoWM, const Ice::Current &=Ice::emptyCurrent) override
Queries only the LTMs of the memory server.
virtual void loadLTMintoWM(bool complete, const ::Ice::Current &) override
Loads the data of the LTMs into the WM.
virtual dto::RecordStatusResult getRecordStatus(const Ice::Current &=Ice::emptyCurrent) override
virtual armem::actions::ExecuteActionOutputSeq executeActions(const armem::actions::ExecuteActionInputSeq &inputs)
virtual data::AddSegmentsResult addSegments(const data::AddSegmentsInput &input, const Ice::Current &=Ice::emptyCurrent) override
bool loadExportIntoWM(const std::string &export_path, const std::string &memoryName, const std::vector< std::string > &coreSegmentName={}, bool addNonExistingCoreSegments=false, int amountOfSnapshotsPerSegmentToLoad=-1, const ::Ice::Current &=Ice::emptyCurrent) override
loads data from a specified LTM export into the currently running WM (needs to already have the CoreS...
virtual dto::StartRecordResult startRecord(const dto::StartRecordInput &startRecordInput, const Ice::Current &=Ice::emptyCurrent) override
virtual dto::DirectlyStoreResult directlyStore(const dto::DirectlyStoreInput &, const Ice::Current &=Ice::emptyCurrent) override
virtual void useMongoDbPersistenceStrategy(const std::string &identifier, const std::string &exportName, bool overwritePrevStrategy, const ::Ice::Current &) override
Use a mongodb persistence strategy for storing the wm as ltm Uses a mongodb as ltm sink.
virtual armem::actions::GetActionsOutputSeq getActions(const armem::actions::GetActionsInputSeq &inputs)
virtual void clearWorkingMemory(const Ice::Current &=Ice::emptyCurrent) override
Clears the working memory usings its clear feature.
virtual armem::structure::data::GetServerStructureResult getServerStructure(const Ice::Current &=Ice::emptyCurrent) override
virtual void useRestPersistenceStrategy(const std::string &identifier, const std::string &exportName, const std::string &host, int port, bool overwritePrevStrategy, const ::Ice::Current &) override
Use a rest persistence strategy for storing the wm as ltm Uses a rest server as ltm sink.
virtual armem::prediction::data::EngineSupportMap getAvailableEngines()
virtual armem::prediction::data::PredictionResultSeq predict(const armem::prediction::data::PredictionRequestSeq &requests)
Result of a Commit.
Definition Commit.h:111