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:
19  struct Statistics
20  {
21  long recordedEntities = 0;
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
33  {
34  _loadAllReferences(provSeg);
35  }
36 
37  /// convert the references of the input into a wm::Memory
38  void
40  {
41  _resolve(provSeg);
42  }
43 
44  /// encode the content of a wm::Memory and store
45  void
47  {
48  _store(provSeg);
49  }
50 
51  /// statistics
52  void
54  {
56  }
57 
58  Statistics
59  getStatistics() const
60  {
61  return statistics;
62  }
63 
64  /// iterate over all core segments of this ltm
65  virtual bool forEachEntity(std::function<void(EntityT&)> func) const = 0;
66 
67  /// check if entity segment exists
68  virtual bool hasEntity(const std::string&) const = 0;
69 
70  /// find entity segment
71  virtual std::shared_ptr<EntityT> findEntity(const std::string&) const = 0;
72 
73  ///get aron type
75  {
76  return nullptr;
77  }
78 
79  static std::string
81  {
82  return "LT-ProviderSegment";
83  }
84 
85  protected:
87  virtual void _resolve(armem::wm::ProviderSegment&) = 0;
88  virtual void _store(const armem::wm::ProviderSegment&) = 0;
89 
90  protected:
91  mutable std::recursive_mutex ltm_mutex;
92 
93  Statistics statistics;
94  };
95 } // namespace armarx::armem::server::ltm::detail
EntityBase.h
armarx::armem::server::ltm::detail
Definition: CoreSegmentBase.cpp:3
armarx::armem::server::ltm::detail::ProviderSegmentBase::resetStatistics
void resetStatistics()
statistics
Definition: ProviderSegmentBase.h:53
armarx::armem::server::ltm::detail::ProviderSegmentBase::hasEntity
virtual bool hasEntity(const std::string &) const =0
check if entity segment exists
armarx::armem::wm::ProviderSegment
Client-side working memory provider segment.
Definition: memory_definitions.h:105
armarx::armem::server::ltm::detail::ProviderSegmentBase::aronType
aron::type::ObjectPtr aronType() const
get aron type
Definition: ProviderSegmentBase.h:74
MemoryID.h
armarx::armem::server::ltm::Entity
A memory storing data in mongodb (needs 'armarx memory start' to start the mongod instance)
Definition: Entity.h:14
armarx::armem::server::ltm::detail::ProviderSegmentBase::ltm_mutex
std::recursive_mutex ltm_mutex
Definition: ProviderSegmentBase.h:91
armarx::armem::server::ltm::detail::ProviderSegmentBase::getStatistics
Statistics getStatistics() const
Definition: ProviderSegmentBase.h:59
armarx::armem::server::ltm::detail::ProviderSegmentBase::_loadAllReferences
virtual void _loadAllReferences(armem::wm::ProviderSegment &)=0
armarx::armem::server::ltm::detail::MemoryItem::MemoryItem
MemoryItem(const std::string &exportName, const MemoryID &)
Definition: MemoryItem.cpp:10
aron_conversions.h
armarx::armem::server::ltm::detail::ProviderSegmentBase::findEntity
virtual std::shared_ptr< EntityT > findEntity(const std::string &) const =0
find entity segment
armarx::armem::server::ltm::detail::ProviderSegmentBase::loadAllReferences
void loadAllReferences(armem::wm::ProviderSegment &provSeg)
return the full sub-ltm as a wm::ProviderSegment with only references the ltm may be huge,...
Definition: ProviderSegmentBase.h:32
armarx::armem::server::ltm::detail::ProviderSegmentBase::forEachEntity
virtual bool forEachEntity(std::function< void(EntityT &)> func) const =0
iterate over all core segments of this ltm
armarx::armem::server::ltm::detail::ProviderSegmentBase::Statistics::recordedEntities
long recordedEntities
Definition: ProviderSegmentBase.h:21
armarx::armem::server::ltm::detail::ProviderSegmentBase::EntityT
_EntityT EntityT
Definition: ProviderSegmentBase.h:25
armarx::armem::server::ltm::detail::ProviderSegmentBase::_resolve
virtual void _resolve(armem::wm::ProviderSegment &)=0
armarx::armem::server::ltm::detail::ProviderSegmentBase::statistics
Statistics statistics
Definition: ProviderSegmentBase.h:93
armarx::armem::server::ltm::detail::ProviderSegmentBase::getLevelName
static std::string getLevelName()
Definition: ProviderSegmentBase.h:80
armarx::armem::server::ltm::detail::ProviderSegmentBase::Statistics
Definition: ProviderSegmentBase.h:19
memory_definitions.h
armarx::armem::server::ltm::detail::ProviderSegmentBase::resolve
void resolve(armem::wm::ProviderSegment &provSeg)
convert the references of the input into a wm::Memory
Definition: ProviderSegmentBase.h:39
armarx::armem::server::ltm::detail::ProviderSegmentBase
Interface functions for the longterm memory classes.
Definition: ProviderSegmentBase.h:16
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
armarx::armem::server::ltm::detail::ProviderSegmentBase::store
void store(const armem::wm::ProviderSegment &provSeg)
encode the content of a wm::Memory and store
Definition: ProviderSegmentBase.h:46
armarx::armem::server::ltm::detail::ProviderSegmentBase::_store
virtual void _store(const armem::wm::ProviderSegment &)=0
armarx::armem::server::ltm::detail::MemoryItem
Interface functions for the longterm memory classes.
Definition: MemoryItem.h:13
MemoryItem.h