Memory.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <filesystem>
4 #include <list>
5 
6 // Base Class
7 #include "detail/MemoryBase.h"
12 
13 // Segmnet Type
14 #include "CoreSegment.h"
15 
17 {
18  /// @brief A memory storing data on the hard drive and in mongodb (needs 'armarx memory start' to start the mongod instance)
19  class Memory :
20  public detail::MemoryBase<CoreSegment>,
21  public detail::mixin::BufferedMemoryMixin<CoreSegment>,
22  public detail::mixin::CachedMemoryMixin<CoreSegment>,
25  {
26  public:
32 
33  Memory();
34  Memory(const detail::mixin::Path&, const std::string&, const std::string&);
37  const std::string&,
38  const std::string&);
39 
40  void _setExportName(const std::string& n) final;
41  void _setMemoryID(const MemoryID& id) final;
42  void _enable() final;
43  void _disable() final;
44  void _configure(const nlohmann::json& config) final;
45 
46  bool forEachCoreSegment(std::function<void(CoreSegment&)> func) const final;
47  bool hasCoreSegment(const std::string& name) const final;
48  std::unique_ptr<CoreSegment>
49  findCoreSegment(const std::string& coreSegmentName) const final;
50 
51  void createPropertyDefinitions(PropertyDefinitionsPtr& defs, const std::string& prefix) override;
52 
53  /**
54  * @brief getAndSaveStatistics generates and saves statistics for a LTM recording
55  */
56  void getAndSaveStatistics();
57 
58  protected:
59  void _loadAllReferences(armem::wm::Memory&) final;
60  void _loadLatestNReferences(int n, armem::wm::Memory& m) final;
61  void _loadLatestNReferences(int n, armem::wm::Memory& m, std::list<std::string> coreSegNames) final;
62  void _resolve(armem::wm::Memory&) final;
63  void _store(const armem::wm::Memory&) final;
64  void _directlyStore(const armem::wm::Memory&) final;
65  void _loadOnStartup() final;
66 
67  private:
68  std::time_t current_date;
69  };
70 } // namespace armarx::armem::server::ltm
armarx::armem::server::ltm::Memory::_loadAllReferences
void _loadAllReferences(armem::wm::Memory &) final
Definition: Memory.cpp:178
MongoDBStorageMixin.h
armarx::armem::server::ltm::Memory::_setExportName
void _setExportName(const std::string &n) final
Definition: Memory.cpp:48
BufferedMemoryMixin.h
armarx::armem::server::ltm::Memory::Memory
Memory()
Definition: Memory.cpp:21
armarx::armem::server::ltm::Memory::getAndSaveStatistics
void getAndSaveStatistics()
getAndSaveStatistics generates and saves statistics for a LTM recording
Definition: Memory.cpp:311
armarx::armem::server::ltm::Memory::_directlyStore
void _directlyStore(const armem::wm::Memory &) final
Definition: Memory.cpp:264
MemoryBase.h
list
list(APPEND SOURCES ${QT_RESOURCES}) set(COMPONENT_LIBS ArmarXGui ArmarXCoreObservers ArmarXCoreEigen3Variants PlotterController $
Definition: CMakeLists.txt:49
armarx::armem::server::ltm::Memory::createPropertyDefinitions
void createPropertyDefinitions(PropertyDefinitionsPtr &defs, const std::string &prefix) override
default parameters. Implementation should use the configuration to configure
Definition: Memory.cpp:170
armarx::armem
Definition: LegacyRobotStateMemoryAdapter.cpp:31
armarx::armem::server::ltm::Memory::_disable
void _disable() final
Definition: Memory.cpp:62
CoreSegment.h
armarx::armem::server::ltm::Memory::_configure
void _configure(const nlohmann::json &config) final
configuration
Definition: Memory.cpp:11
armarx::armem::server::ltm::detail::MemoryBase
Interface functions for the longterm memory classes.
Definition: MemoryBase.h:28
armarx::armem::server::ltm::Memory::_loadOnStartup
void _loadOnStartup() final
Definition: Memory.cpp:305
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:19
armarx::armem::server::ltm::Memory::_resolve
void _resolve(armem::wm::Memory &) final
Definition: Memory.cpp:232
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::server::ltm::Memory::_setMemoryID
void _setMemoryID(const MemoryID &id) final
Definition: Memory.cpp:71
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:82
armarx::armem::server::ltm::detail::mixin::MongoDBStorageMixin
Definition: MongoDBStorageMixin.h:45
armarx::armem::server::ltm::detail::mixin::CachedMemoryMixin
Definition: CachedMemoryMixin.h:12
armarx::armem::server::ltm
Definition: forward_declarations.h:20
armarx::armem::server::ltm::Memory::_enable
void _enable() final
Definition: Memory.cpp:55
armarx::armem::server::ltm::CoreSegment
Definition: CoreSegment.h:13
std
Definition: Application.h:66
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::armem::server::ltm::detail::mixin::BufferedMemoryMixin
Definition: BufferedMemoryMixin.h:18
armarx::armem::server::ltm::Memory::_loadLatestNReferences
void _loadLatestNReferences(int n, armem::wm::Memory &m) final
Definition: Memory.cpp:194
armarx::armem::server::ltm::detail::mixin::MongoDBSettings
Definition: MongoDBStorageMixin.h:15
armarx::armem::server::ltm::detail::mixin::Path
std::filesystem::path Path
Definition: DiskStorageMixin.h:17
armarx::armem::server::ltm::Memory::findCoreSegment
std::unique_ptr< CoreSegment > findCoreSegment(const std::string &coreSegmentName) const final
find core segment
Definition: Memory.cpp:153
armarx::armem::server::ltm::Memory::_store
void _store(const armem::wm::Memory &) final
Definition: Memory.cpp:258
armarx::armem::server::ltm::Memory::hasCoreSegment
bool hasCoreSegment(const std::string &name) const final
check if core segment exists
Definition: Memory.cpp:116
CachedMemoryMixin.h
armarx::armem::server::ltm::detail::mixin::DiskMemoryItemMixin
Definition: DiskStorageMixin.h:19
DiskStorageMixin.h
armarx::armem::server::ltm::detail::MemoryItem::name
std::string name() const
Definition: MemoryItem.cpp:43