MemoryToIceAdapter.cpp
Go to the documentation of this file.
1 #include "MemoryToIceAdapter.h"
2 
3 #include <iostream>
4 #include <list>
5 #include <sstream>
6 #include <thread>
7 
12 
22 
24 #include "query_proc/wm/wm.h"
25 
26 namespace armarx::armem::server
27 {
28 
30  server::ltm::Memory* longtermMemory) :
31  workingMemory(workingMemory), longtermMemory(longtermMemory)
32  {
33  }
34 
35  void
36  MemoryToIceAdapter::setMemoryListener(client::MemoryListenerInterfacePrx memoryListener)
37  {
38  this->memoryListenerTopic = memoryListener;
39  }
40 
41  // WRITING
42  data::AddSegmentResult
43  MemoryToIceAdapter::addSegment(const data::AddSegmentInput& input, bool addCoreSegments)
44  {
47 
48  ARMARX_DEBUG << "Adding segment using MemoryToIceAdapter";
49 
50  data::AddSegmentResult output;
51 
52  server::wm::CoreSegment* coreSegment = nullptr;
53  try
54  {
55  coreSegment = &workingMemory->getCoreSegment(input.coreSegmentName);
56  }
57  catch (const armem::error::MissingEntry& e)
58  {
59  if (addCoreSegments)
60  {
61  coreSegment = &workingMemory->addCoreSegment(input.coreSegmentName);
62  }
63  else
64  {
65  output.success = false;
66  output.errorMessage = e.what();
67  return output;
68  }
69  }
70  ARMARX_CHECK_NOT_NULL(coreSegment);
71 
72  if (input.providerSegmentName.size() > 0)
73  {
74  coreSegment->doLocked(
75  [&coreSegment, &input]()
76  {
77  try
78  {
79  coreSegment->addProviderSegment(input.providerSegmentName);
80  }
82  {
83  // This is ok.
84  if (input.clearWhenExists)
85  {
86  server::wm::ProviderSegment& provider =
87  coreSegment->getProviderSegment(input.providerSegmentName);
88  provider.clear();
89  }
90  }
91  });
92  }
93 
94  armem::MemoryID segmentID;
95  segmentID.memoryName = workingMemory->name();
96  segmentID.coreSegmentName = input.coreSegmentName;
97  segmentID.providerSegmentName = input.providerSegmentName;
98 
99  output.success = true;
100  output.segmentID = segmentID.str();
101  return output;
102  }
103 
104  data::AddSegmentsResult
105  MemoryToIceAdapter::addSegments(const data::AddSegmentsInput& input, bool addCoreSegments)
106  {
107  ARMARX_TRACE;
109 
110  data::AddSegmentsResult output;
111  for (const auto& i : input)
112  {
113  output.push_back(addSegment(i, addCoreSegments));
114  }
115  return output;
116  }
117 
118  data::CommitResult
119  MemoryToIceAdapter::commit(const data::Commit& commitIce, Time timeArrived)
120  {
121  ARMARX_TRACE;
123  auto handleException = [](const std::string& what)
124  {
125  data::CommitResult result;
126  data::EntityUpdateResult& r = result.results.emplace_back();
127  r.success = false;
128  r.errorMessage = what;
129  return result;
130  };
131 
133  try
134  {
135  ::armarx::armem::fromIce(commitIce, commit, timeArrived);
136  }
137  catch (const aron::error::AronNotValidException& e)
138  {
139  throw;
140  return handleException(e.what());
141  }
142  catch (const Ice::Exception& e)
143  {
144  throw;
145  return handleException(e.what());
146  }
147 
148  armem::CommitResult result = this->commit(commit);
149  data::CommitResult resultIce;
150  toIce(resultIce, result);
151 
152  return resultIce;
153  }
154 
155  data::CommitResult
156  MemoryToIceAdapter::commit(const data::Commit& commitIce)
157  {
158  ARMARX_TRACE;
159  return commit(commitIce, armem::Time::Now());
160  }
161 
164  {
165  ARMARX_TRACE;
166  return this->_commit(commit, false);
167  }
168 
169  data::CommitResult
170  MemoryToIceAdapter::commitLocking(const data::Commit& commitIce, Time timeArrived)
171  {
172  ARMARX_TRACE;
174  auto handleException = [](const std::string& what)
175  {
176  data::CommitResult result;
177  data::EntityUpdateResult& r = result.results.emplace_back();
178  r.success = false;
179  r.errorMessage = what;
180  return result;
181  };
182 
184  try
185  {
186  ::armarx::armem::fromIce(commitIce, commit, timeArrived);
187  }
188  catch (const aron::error::AronNotValidException& e)
189  {
190  throw;
191  return handleException(e.what());
192  }
193  catch (const Ice::Exception& e)
194  {
195  throw;
196  return handleException(e.what());
197  }
198 
199  armem::CommitResult result = this->commitLocking(commit);
200  data::CommitResult resultIce;
201  toIce(resultIce, result);
202 
203  return resultIce;
204  }
205 
206  data::CommitResult
207  MemoryToIceAdapter::commitLocking(const data::Commit& commitIce)
208  {
209  ARMARX_TRACE;
210  return commitLocking(commitIce, armem::Time::Now());
211  }
212 
215  {
216  ARMARX_TRACE;
217  return this->_commit(commit, true);
218  }
219 
221  MemoryToIceAdapter::_commit(const armem::Commit& commit, bool locking)
222  {
223  ARMARX_TRACE;
224  std::vector<data::MemoryID> updatedIDs;
225  const bool publishUpdates = bool(memoryListenerTopic);
226 
227  CommitResult commitResult;
228  for (const EntityUpdate& update : commit.updates)
229  {
230  EntityUpdateResult& result = commitResult.results.emplace_back();
231  try
232  {
233  auto updateResult =
235 
236  result.success = true;
237  result.snapshotID = updateResult.id;
238  result.arrivedTime = update.arrivedTime;
239 
240  for (const auto& snapshot : updateResult.removedSnapshots)
241  {
242  ARMARX_DEBUG << "The id " << snapshot.id() << " was removed from wm";
243  }
244 
245  // Consolidate to ltm(s) if recording mode is CLONE_WM
246  if (longtermMemory->isRecording() &&
249  {
250  // convert snapshots to Memory
252  //m.update(update, true, false); //is maybe not needed as already done above
253  armem::wm::toMemory(m, *workingMemory, updateResult.updatedSnapshots);
254  //this removes information about segments, because new memory (wm) is used
255 
256  // store memory
257  longtermMemory->store(m);
258  }
259 
260 
261  // Consolidate to ltm(s) if recording mode is CONSOLIDATE_REMOVED
262  if (longtermMemory->isRecording() &&
265  {
266  // convert removedSnapshots to Memory
268  armem::wm::toMemory(m, *workingMemory, updateResult.removedSnapshots);
269  //this removes information about segments, because new memory (wm) is used
270 
271  // store memory
272  longtermMemory->store(m);
273  }
274 
275  if (longtermMemory->isRecording() &&
278  {
279  ARMARX_WARNING << deactivateSpam() << "THIS IS NOT IMPLEMENTED YET!!!";
280  }
281 
282  if (publishUpdates)
283  {
284  data::MemoryID& id = updatedIDs.emplace_back();
285  toIce(id, result.snapshotID);
286  }
287  }
288  catch (const error::ArMemError& e)
289  {
290  result.success = false;
291  result.errorMessage = e.what();
292  }
293  catch (const aron::error::AronException& e)
294  {
295  result.success = false;
296  result.errorMessage = e.what();
297  }
298  catch (const Ice::Exception& e)
299  {
300  result.success = false;
301  result.errorMessage = e.what();
302  }
303  catch (...)
304  {
305  ARMARX_INFO << "Error during LTM consollidation";
306  }
307  }
308 
309  if (publishUpdates)
310  {
311  memoryListenerTopic->memoryUpdated(updatedIDs);
312  }
313 
314  return commitResult;
315  }
316 
317  // READING
318  armem::query::data::Result
319  MemoryToIceAdapter::query(const armem::query::data::Input& input)
320  {
321  ARMARX_TRACE;
324 
325  // Core segment processors will aquire the core segment locks.
328  armem::wm::Memory wmResult = wmServerProcessor.process(input, *workingMemory);
329 
330  armem::query::data::Result result;
331 
332 
333  result.memory = armarx::toIce<data::MemoryPtr>(wmResult);
334 
335  result.success = true;
336  if (result.memory->coreSegments.size() == 0)
337  {
338  ARMARX_DEBUG << "No data in memory found after query.";
339  }
340 
341  return result;
342  }
343 
344  armem::query::data::Result
345  MemoryToIceAdapter::queryLTM(const armem::query::data::Input& input, bool storeIntoWM)
346  {
347  ARMARX_TRACE;
348 
350  armem::wm::Memory ltmResult = ltmProcessor.process(input, *longtermMemory);
351 
352  // convert memory ==> meaning resolving references
353  // upon query, the LTM only returns a structure of the data (memory without data)
354  if (input.withData)
355  {
356  longtermMemory->resolve(ltmResult);
357  }
358 
359  if (longtermMemory->isRecording() || storeIntoWM)
360  {
361  this->commit(toCommit(ltmResult));
362 
363  // mark removed entries of wm in viewer
364  // TODO
365  }
366 
367  armem::query::data::Result result;
368 
369  result.memory = armarx::toIce<data::MemoryPtr>(ltmResult);
370 
371  result.success = true;
372  if (result.memory->coreSegments.size() == 0)
373  {
374  ARMARX_DEBUG << "No data in ltm found after query.";
375  }
376 
377  return result;
378  }
379 
382  {
383  ARMARX_TRACE;
384 
385  return client::QueryResult::fromIce(query(input.toIce()));
386  }
387 
388  armem::structure::data::GetServerStructureResult
390  {
391  ARMARX_TRACE;
394 
395  armem::structure::data::GetServerStructureResult ret;
396  ret.success = true;
397 
398  wm::Memory structure;
399  structure.id() = workingMemory->id();
400 
401  // Get all info from the WM
403  builder.all();
404 
405  auto query_result = this->query(builder.buildQueryInput());
406  if (query_result.success)
407  {
408  structure.append(query_result.memory);
409  }
410 
411  // Get all info from the LTM
413 
414  ret.serverStructure = armarx::toIce<data::MemoryPtr>(structure);
415 
416  return ret;
417  }
418 
421  {
422  ARMARX_TRACE;
423 
424  ARMARX_INFO << "Reloading of all core segments from LTM into WM triggered";
425 
426  int maxAmountOfSnapshots = this->longtermMemory->p.maxAmountOfSnapshotsLoaded;
427  //create WM and load latest references
429  this->longtermMemory->loadLatestNReferences(maxAmountOfSnapshots, m);
430 
431  //construct a commit of the loaded data and commit it to the working memory
432  auto com = armem::toCommit(m);
433  auto res = this->commit(com);
434 
435  //the CommitResult contains some information which might be helpful:
436  return res;
437  }
438 
440  MemoryToIceAdapter::reloadCoreSegmentsFromLTM(std::list<std::string>& coreSegmentNames)
441  {
442  ARMARX_TRACE;
443 
444  ARMARX_INFO << "Reloading of specific core segments from LTM into WM triggered";
445 
446  std::ostringstream namesStr;
447  for (auto it = coreSegmentNames.begin(); it != coreSegmentNames.end(); ++it)
448  {
449  if (it != coreSegmentNames.begin())
450  namesStr << ", "; // Add comma before every element except the first
451  namesStr << *it;
452  }
453 
454  ARMARX_INFO << "Loading core segments=" << namesStr.str();
455 
456 
457  int maxAmountOfSnapshots = this->longtermMemory->p.maxAmountOfSnapshotsLoaded;
458  //create WM and load latest references
460  this->longtermMemory->loadLatestNReferences(maxAmountOfSnapshots, m, coreSegmentNames);
461 
462  //construct a commit of the loaded data and commit it to the working memory
463  auto com = armem::toCommit(m);
464  auto res = this->commit(com);
465 
466  //the CommitResult contains some information which might be helpful:
467  return res;
468  }
469 
472  {
473  ARMARX_INFO << "Reloading of coresegment defined in 'loadedCoreSegments' from LTM into WM "
474  "on startup triggered";
475 
476  auto coreNames = this->longtermMemory->p.coreSegmentsToLoad;
477 
478  ARMARX_INFO << "Loading core segments=" << coreNames
479  << " defined in property 'loadedCoreSegments'";
480 
481  //convert string to list of names:
482  std::list<std::string> names;
483  std::stringstream ss(coreNames);
484  std::string item;
485 
486  while (std::getline(ss, item, ','))
487  {
488  names.push_back(item);
489  }
490 
492  }
493 
494  // WM LOADING FROM LTM
497  {
498  ARMARX_TRACE;
499 
500  ARMARX_INFO << "Reloading of data from LTM into WM on startup triggered";
501 
502  if (this->longtermMemory->p.importOnStartUp)
503  {
505  }
506  else
507  {
508  ARMARX_INFO << "Not loading initial data from LTM due to importOnStartup being "
509  << this->longtermMemory->p.importOnStartUp;
511  return r;
512  }
513  }
514 
515  // LTM STORING AND RECORDING
516  dto::DirectlyStoreResult
517  MemoryToIceAdapter::directlyStore(const dto::DirectlyStoreInput& directlStoreInput)
518  {
519  ARMARX_TRACE;
521 
522  dto::DirectlyStoreResult output;
523  output.success = true;
524 
525  armem::wm::Memory m = armarx::fromIce<armem::wm::Memory>(directlStoreInput.memory);
527 
528  return output;
529  }
530 
531  dto::StartRecordResult
532  MemoryToIceAdapter::startRecord(const dto::StartRecordInput& startRecordInput)
533  {
534  ARMARX_TRACE;
536  ARMARX_IMPORTANT << "Enabling the recording of memory " << longtermMemory->id().str();
538 
539  dto::StartRecordResult ret;
540  ret.success = true;
541 
542  return ret;
543  }
544 
545  dto::StopRecordResult
547  {
548  ARMARX_TRACE;
551  ARMARX_IMPORTANT << "Disabling the recording of memory " << longtermMemory->id().str();
552 
554  { //if true this means when stopping LTM recording leftover snapshots are transferred to WM using the simulated consolidation
555  ARMARX_INFO << "Starting to save left-over WM data into LTM";
557  ARMARX_INFO << "Stored leftover WM data into LTM";
558  }
559  else
560  {
561  ARMARX_INFO << "Not storing WM data into LTM on stop, because storeOnStop is "
563  }
564 
565  //put calling stopRecording into a seperate thread and detach to make sure GUI does not freeze
566  auto ltm = longtermMemory;
567 
568  std::thread stopRecordingThread(
569  [&ltm]()
570  {
571  ltm->stopRecording();
572  ltm->bufferFinished();
573  ARMARX_INFO << "Storing finished";
574  });
575  stopRecordingThread.detach();
576 
578  << "Stopped all LTM recordings, please wait with stopping the component until "
579  "all files are written";
580 
581  dto::StopRecordResult ret;
582  ret.success = true;
583 
584  return ret;
585  }
586 
587  dto::RecordStatusResult
589  {
590  dto::RecordStatusResult ret;
591  ret.success = true;
592 
593  long savedSnapshots;
594  long totalSnapshots;
595 
596  ARMARX_DEBUG << "Get record status";
597 
599  [&savedSnapshots, &totalSnapshots](const auto& c)
600  {
601  c.forEachProviderSegment(
602  [&savedSnapshots, &totalSnapshots](const auto& p)
603  {
604  p.forEachEntity(
605  [&savedSnapshots, &totalSnapshots](const auto& e)
606  {
607  savedSnapshots += e.getStatistics().recordedSnapshots;
608 
609  e.forEachSnapshot([&totalSnapshots](const auto&)
610  { totalSnapshots++; });
611  });
612  });
613  });
614 
615  ret.status.savedSnapshots = savedSnapshots;
616  ret.status.totalSnapshots = totalSnapshots;
617 
618  return ret;
619  }
620 
621  // PREDICTION
622  prediction::data::PredictionResultSeq
623  MemoryToIceAdapter::predict(prediction::data::PredictionRequestSeq requests)
624  {
626  armarx::fromIce<std::vector<PredictionRequest>>(requests));
627  return armarx::toIce<prediction::data::PredictionResultSeq>(res);
628  }
629 
630  prediction::data::EngineSupportMap
632  {
633  prediction::data::EngineSupportMap result;
635 
636  // Uncomment once LTM also supports prediction engines.
637 
638  /*prediction::data::EngineSupportMap ltmMap;
639  armarx::toIce(ltmMap, longtermMemory->getAllPredictionEngines());
640  for (const auto& [memoryID, engines] : ltmMap)
641  {
642  auto entryIter = result.find(memoryID);
643  if (entryIter == result.end())
644  {
645  result.emplace(memoryID, engines);
646  }
647  else
648  {
649  // Merge LTM-supported engines with WM-supported engines, removing duplicates
650  std::set<prediction::data::PredictionEngine> engineSet;
651  engineSet.insert(entryIter->second.begin(), entryIter->second.end());
652  engineSet.insert(engines.begin(), engines.end());
653  entryIter->second.assign(engineSet.begin(), engineSet.end());
654  }
655  }*/
656 
657  return result;
658  }
659 
660 } // namespace armarx::armem::server
armarx::armem::server::MemoryToIceAdapter::workingMemory
server::wm::Memory * workingMemory
Definition: MemoryToIceAdapter.h:89
armarx::armem::server::ltm::detail::MemoryBase::isRecording
bool isRecording() const
Definition: MemoryBase.h:318
RestPersistence.h
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:13
memory_conversions.h
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:190
armarx::armem::MemoryID::providerSegmentName
std::string providerSegmentName
Definition: MemoryID.h:52
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
MemoryPersistenceStrategy.h
armarx::armem::client::query::Builder::buildQueryInput
QueryInput buildQueryInput() const
Definition: Builder.cpp:12
armarx::armem::server::ltm::detail::MemoryBase::getRecordingMode
RecordingMode getRecordingMode() const
Definition: MemoryBase.h:90
armarx::core::time::DateTime::Now
static DateTime Now()
Definition: DateTime.cpp:51
armarx::armem::EntityUpdateResult
Result of an EntityUpdate.
Definition: Commit.h:74
armarx::armem::server::ltm::detail::MemoryBase::Properties::coreSegmentsToLoad
std::string coreSegmentsToLoad
Definition: MemoryBase.h:425
armarx::armem::server::MemoryToIceAdapter::longtermMemory
server::ltm::Memory * longtermMemory
Definition: MemoryToIceAdapter.h:90
armarx::armem::EntityUpdateResult::arrivedTime
Time arrivedTime
Definition: Commit.h:79
armarx::armem::base::MemoryBase::getCoreSegment
CoreSegmentT & getCoreSegment(const std::string &name)
Definition: MemoryBase.h:134
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
armarx::armem::server::MemoryToIceAdapter::startRecord
dto::StartRecordResult startRecord(const dto::StartRecordInput &startRecordInput)
Definition: MemoryToIceAdapter.cpp:532
armarx::armem::server::MemoryToIceAdapter::memoryListenerTopic
client::MemoryListenerInterfacePrx memoryListenerTopic
Definition: MemoryToIceAdapter.h:92
armarx::armem::MemoryID::str
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
Definition: MemoryID.cpp:102
armarx::armem::wm::toMemory
void toMemory(Memory &m, const std::vector< CoreSegment > &e)
Definition: memory_conversions.cpp:6
armarx::armem::toIce
void toIce(data::MemoryID &ice, const MemoryID &id)
Definition: ice_conversions.cpp:20
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::armem::server::ltm::detail::MemoryBase::Properties::importOnStartUp
bool importOnStartUp
Definition: MemoryBase.h:423
armarx::armem::query::boolToDataMode
DataMode boolToDataMode(bool withData)
Definition: DataMode.cpp:6
armarx::armem::base::MemoryBase::name
std::string & name()
Definition: MemoryBase.h:94
armarx::armem::server::ltm::detail::MemoryBase::p
struct armarx::armem::server::ltm::detail::MemoryBase::Properties p
ice_conversions.h
ltm.h
armarx::armem::client::QueryResult
Result of a QueryInput.
Definition: Query.h:50
armarx::armem::server::query_proc::wm_server::MemoryQueryProcessor
Definition: wm.h:186
armarx::armem::MemoryID::coreSegmentName
std::string coreSegmentName
Definition: MemoryID.h:51
armarx::armem::server::MemoryToIceAdapter::predict
prediction::data::PredictionResultSeq predict(prediction::data::PredictionRequestSeq requests)
Definition: MemoryToIceAdapter.cpp:623
armarx::armem::server::MemoryToIceAdapter::getServerStructure
armem::structure::data::GetServerStructureResult getServerStructure()
Definition: MemoryToIceAdapter.cpp:389
armarx::armem::server::ltm::Memory
A memory storing data on the hard drive and in mongodb (needs 'armarx memory start' to start the mong...
Definition: Memory.h:20
armarx::toIce
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:15
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:75
armarx::armem::server::MemoryToIceAdapter::reloadFromLTMOnStartup
armem::CommitResult reloadFromLTMOnStartup()
Triggers a reload (.
Definition: MemoryToIceAdapter.cpp:496
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
armarx::armem::server::MemoryToIceAdapter::setMemoryListener
void setMemoryListener(client::MemoryListenerInterfacePrx memoryListenerTopic)
Definition: MemoryToIceAdapter.cpp:36
armarx::armem::server::wm::Memory
Definition: memory_definitions.h:122
armarx::armem::server::ltm::detail::MemoryBase::resolve
void resolve(armem::wm::Memory &memory)
convert the references of the input into a wm::Memory
Definition: MemoryBase.h:231
armarx::armem::server::query_proc::base::MemoryQueryProcessorBase::process
ResultMemoryT process(const armem::query::data::Input &input, const MemoryT &memory) const
Definition: MemoryQueryProcessorBase.h:48
armarx::armem::server::MemoryToIceAdapter::reloadPropertyDefinedCoreSegmentsFromLTM
armem::CommitResult reloadPropertyDefinedCoreSegmentsFromLTM()
Definition: MemoryToIceAdapter.cpp:471
armarx::armem::server::ltm::detail::MemoryBase::Properties::storeOnStop
bool storeOnStop
Definition: MemoryBase.h:419
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::base::detail::PredictiveContainer::getAllPredictionEngines
std::map< MemoryID, std::vector< PredictionEngine > > getAllPredictionEngines() const
Definition: Predictive.h:94
armarx::core::eigen::fromIce
void fromIce(Eigen::Vector2f &e, const Ice::FloatSeq &ice)
Definition: ice_conversions.cpp:10
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:184
armarx::armem::server::ltm::detail::MemoryBase::loadLatestNReferences
armem::wm::Memory loadLatestNReferences(int n)
Definition: MemoryBase.h:185
armarx::armem::client::QueryInput
A query for parts of a memory.
Definition: Query.h:23
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:12
error.h
armarx::armem::wm::Memory
Client-side working memory.
Definition: memory_definitions.h:133
armarx::armem::server::ltm::detail::MemoryBase::Properties::maxAmountOfSnapshotsLoaded
int maxAmountOfSnapshotsLoaded
Definition: MemoryBase.h:424
wm.h
armarx::aron::error::AronNotValidException
The AronNotValidException class.
Definition: Exception.h:71
armarx::armem::EntityUpdate
An update of an entity for a specific point in time.
Definition: Commit.h:25
armarx::armem::CommitResult
Result of a Commit.
Definition: Commit.h:110
ice_conversions.h
armarx::armem::server::ltm::Memory::forEachCoreSegment
bool forEachCoreSegment(std::function< void(CoreSegment &)> func) const final
iterate over all core segments of this ltm
Definition: Memory.cpp:182
armarx::armem::server::MemoryToIceAdapter::getRecordStatus
dto::RecordStatusResult getRecordStatus()
Definition: MemoryToIceAdapter.cpp:588
armarx::armem::server::ltm::detail::mixin::BufferedMemoryMixin::directlyStore
void directlyStore(const armem::wm::Memory &memory, bool simulatedVersion=false)
Definition: BufferedMemoryMixin.h:31
armarx::armem::base::detail::MemoryItem::id
MemoryID & id()
Definition: MemoryItem.h:25
armarx::armem::server::wm::CoreSegment::doLocked
auto doLocked(FunctionT &&function) const
Definition: memory_definitions.h:110
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:68
armarx::armem::EntityUpdateResult::snapshotID
MemoryID snapshotID
Definition: Commit.h:78
armarx::armem::server::ltm::detail::MemoryBase::startRecording
void startRecording()
enable/disable
Definition: MemoryBase.h:303
MemoryToIceAdapter.h
armarx::armem::server::MemoryToIceAdapter::getAvailableEngines
prediction::data::EngineSupportMap getAvailableEngines()
Definition: MemoryToIceAdapter.cpp:631
ice_conversions.h
armarx::armem::server::MemoryToIceAdapter::stopRecord
dto::StopRecordResult stopRecord()
Definition: MemoryToIceAdapter.cpp:546
armarx::fromIce
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:27
armarx::armem::MemoryID::memoryName
std::string memoryName
Definition: MemoryID.h:50
armarx::armem::server
Definition: GraspMemory.cpp:34
armarx::armem::server::MemoryToIceAdapter::directlyStore
dto::DirectlyStoreResult directlyStore(const dto::DirectlyStoreInput &directlStoreInput)
Definition: MemoryToIceAdapter.cpp:517
ExpressionException.h
armarx::armem::server::ltm::RecordingMode::CONSOLIDATE_LATEST
@ CONSOLIDATE_LATEST
armarx::armem::server::wm::CoreSegment
base::CoreSegmentBase
Definition: memory_definitions.h:75
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::server::MemoryToIceAdapter::addSegment
data::AddSegmentResult addSegment(const data::AddSegmentInput &input, bool addCoreSegments=false)
Definition: MemoryToIceAdapter.cpp:43
Exception.h
armarx::armem::server::ltm::detail::MemoryItem::id
MemoryID id() const
Definition: MemoryItem.cpp:37
armarx::viz::data::ElementFlags::names
const simox::meta::IntEnumNames names
Definition: json_elements.cpp:13
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::armem::server::ltm::detail::MemoryBase::loadAllReferences
armem::wm::Memory loadAllReferences()
return the full ltm as a wm::Memory with only references the ltm may be huge, use with caution
Definition: MemoryBase.h:167
armarx::armem::CommitResult::results
std::vector< EntityUpdateResult > results
Definition: Commit.h:112
armarx::armem::server::MemoryToIceAdapter::addSegments
data::AddSegmentsResult addSegments(const data::AddSegmentsInput &input, bool addCoreSegments=false)
Definition: MemoryToIceAdapter.cpp:105
armarx::armem::server::MemoryToIceAdapter::MemoryToIceAdapter
MemoryToIceAdapter(server::wm::Memory *workingMemory=nullptr, server::ltm::Memory *longtermMemory=nullptr)
Construct an MemoryToIceAdapter from an existing Memory.
Definition: MemoryToIceAdapter.cpp:29
armarx::armem::server::MemoryToIceAdapter::reloadCoreSegmentsFromLTM
armem::CommitResult reloadCoreSegmentsFromLTM(std::list< std::string > &coreSegmentname)
Only load specific core segments and their data from the LTM.
Definition: MemoryToIceAdapter.cpp:440
armarx::armem::query::DataMode::NoData
@ NoData
Just get the structure, but no ARON data.
Builder.h
armarx::armem::base::MemoryBase::append
void append(const OtherDerivedT &other)
Merge another memory into this one.
Definition: MemoryBase.h:363
armarx::armem::EntityUpdateResult::errorMessage
std::string errorMessage
Definition: Commit.h:81
armarx::armem::client::query::Builder
The query::Builder class provides a fluent-style specification of hierarchical queries.
Definition: Builder.h:21
ice_conversions_templates.h
armarx::armem::server::wm::detail::PredictionContainer::dispatchPredictions
std::vector< PredictionResult > dispatchPredictions(const std::vector< PredictionRequest > &requests)
Definition: Prediction.h:168
armarx::armem::base::MemoryBase::update
std::vector< UpdateResult > update(const Commit &commit, const bool addMissingCoreSegmentDuringUpdate=false, const bool checkMemoryName=true)
Store all updates in commit.
Definition: MemoryBase.h:310
armarx::armem::error::ContainerEntryAlreadyExists
Indicates that a name in a given ID does not match a container's own name.
Definition: ArMemError.h:57
Logging.h
armarx::armem::client::query::Builder::all
void all()
Get all snapshots from all entities in all segments.
Definition: Builder.cpp:54
armarx::armem::server::query_proc::ltm_server::MemoryQueryProcessor
Definition: ltm.h:56
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::armem::server::MemoryToIceAdapter::reloadAllFromLTM
armem::CommitResult reloadAllFromLTM()
Loads all core segments and their data from the LTM.
Definition: MemoryToIceAdapter.cpp:420
armarx::armem::server::wm::CoreSegment::addProviderSegment
ProviderSegment & addProviderSegment(const std::string &name, Args... args)
Definition: memory_definitions.h:91
armarx::armem::server::wm::Memory::updateLocking
std::vector< Base::UpdateResult > updateLocking(const Commit &commit)
Perform the commit, locking the core segments.
Definition: memory_definitions.cpp:50
armarx::armem::client::QueryResult::fromIce
static QueryResult fromIce(const armem::query::data::Result &ice)
Definition: Query.cpp:26
armarx::armem::server::MemoryToIceAdapter::queryLTM
query::data::Result queryLTM(const armem::query::data::Input &input, bool storeIntoWM)
Query the LTMs of the memory server.
Definition: MemoryToIceAdapter.cpp:345
armarx::armem::server::wm::Memory::addCoreSegment
CoreSegment & addCoreSegment(const std::string &name, Args... args)
Definition: memory_definitions.h:151
armarx::armem::EntityUpdateResult::success
bool success
Definition: Commit.h:76
armarx::armem::server::ltm::RecordingMode::CONSOLIDATE_ALL
@ CONSOLIDATE_ALL
armarx::armem::toCommit
Commit toCommit(const ContainerT &container)
Definition: operations.h:23
armarx::armem::server::MemoryToIceAdapter::commitLocking
data::CommitResult commitLocking(const data::Commit &commitIce, Time timeArrived)
Definition: MemoryToIceAdapter.cpp:170
armarx::armem::server::ltm::RecordingMode::CONSOLIDATE_REMOVED
@ CONSOLIDATE_REMOVED
armarx::armem::server::MemoryToIceAdapter::commit
data::CommitResult commit(const data::Commit &commitIce, Time timeArrived)
Definition: MemoryToIceAdapter.cpp:119
ice_conversions.h
armarx::armem::error::MissingEntry
Indicates that a container did not have an entry under a given name.
Definition: ArMemError.h:74
armarx::armem::server::MemoryToIceAdapter::query
query::data::Result query(const armem::query::data::Input &input)
Definition: MemoryToIceAdapter.cpp:319
armarx::armem::server::ltm::detail::MemoryBase::store
void store(const armem::wm::Memory &memory)
append a wm::Memory instance to the ltm
Definition: MemoryBase.h:240
armarx::armem::server::ltm::detail::MemoryItem::name
std::string name() const
Definition: MemoryItem.cpp:43
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:28