Memory Class Reference

A memory storing data on the hard drive and in mongodb (needs 'armarx memory start' to start the mongod instance) More...

#include <RobotAPI/libraries/armem/server/ltm/Memory.h>

+ Inheritance diagram for Memory:

Public Types

using BufferedBase = detail::mixin::BufferedMemoryMixin< CoreSegment >
 
using CachedBase = detail::mixin::CachedMemoryMixin< CoreSegment >
 
using DiskMemoryBase = detail::mixin::DiskMemoryItemMixin
 
using MemoryBase = detail::MemoryBase< CoreSegment >
 
using MongoDBStorageMixin = detail::mixin::MongoDBStorageMixin
 
- Public Types inherited from MemoryBase< CoreSegment >
using CoreSegmentT = CoreSegment
 

Public Member Functions

void _configure (const nlohmann::json &config) final
 configuration More...
 
void _disable () final
 
void _enable () final
 
void _setExportName (const std::string &n) final
 
void _setMemoryID (const MemoryID &id) final
 
void createPropertyDefinitions (PropertyDefinitionsPtr &defs, const std::string &prefix) override
 default parameters. Implementation should use the configuration to configure More...
 
std::unique_ptr< CoreSegmentfindCoreSegment (const std::string &coreSegmentName) const final
 find core segment More...
 
bool forEachCoreSegment (std::function< void(CoreSegment &)> func) const final
 iterate over all core segments of this ltm More...
 
void getAndSaveStatistics ()
 getAndSaveStatistics generates and saves statistics for a LTM recording More...
 
bool hasCoreSegment (const std::string &name) const final
 check if core segment exists More...
 
 Memory ()
 
 Memory (const detail::mixin::Path &, const detail::mixin::MongoDBSettings &, const std::string &, const std::string &)
 
 Memory (const detail::mixin::Path &, const std::string &, const std::string &)
 
- Public Member Functions inherited from MemoryBase< CoreSegment >
void configure ()
 initialize config More...
 
void disable ()
 disable this LTM More...
 
void enable ()
 enable this LTM More...
 
std::map< std::string, processor::SnapshotFilter::FilterStatisticsgetFilterStatistics ()
 
Statistics getStatistics () const
 
bool isRecording () const
 
armem::wm::Memory loadAllAndResolve ()
 return the full ltm as a wm::Memory and resolves the references the ltm may be huge, use with caution More...
 
void loadAllAndResolve (armem::wm::Memory &memory)
 
armem::wm::Memory loadAllReferences ()
 return the full ltm as a wm::Memory with only references the ltm may be huge, use with caution More...
 
void loadAllReferences (armem::wm::Memory &memory)
 
 MemoryBase (const std::string &exportName, const MemoryID &id)
 
virtual void resetStatistics ()
 statistics More...
 
void resolve (armem::wm::Memory &memory)
 convert the references of the input into a wm::Memory More...
 
void startRecording ()
 enable/disable More...
 
void stopRecording ()
 
void store (const armem::server::wm::Memory &serverMemory)
 append a wm::Memory instance to the ltm More...
 
void store (const armem::wm::Memory &memory)
 append a wm::Memory instance to the ltm More...
 
- Public Member Functions inherited from MemoryItem
virtual std::string getExportName () const
 
MemoryID getMemoryID () const
 
MemoryID id () const
 
 MemoryItem (const std::string &exportName, const MemoryID &)
 
 MemoryItem (const std::string &exportName, const MemoryID &, const std::shared_ptr< Processors > &)
 
std::string name () const
 
void setExportName (const std::string &n)
 
void setMemoryID (const MemoryID &)
 
void setMemoryName (const std::string &memoryName)
 
virtual ~MemoryItem ()=default
 
- Public Member Functions inherited from BufferedMemoryMixin< CoreSegment >
 BufferedMemoryMixin (const MemoryID &id)
 
void bufferFinished ()
 
void directlyStore (const armem::wm::Memory &memory)
 
virtual ~BufferedMemoryMixin ()=default
 
- Public Member Functions inherited from CachedMemoryMixin< CoreSegment >
 CachedMemoryMixin (const MemoryID &id)
 
- Public Member Functions inherited from DiskMemoryItemMixin
void createPropertyDefinitions (PropertyDefinitionsPtr &defs, const std::string &prefix)
 
 DiskMemoryItemMixin ()=default
 
 DiskMemoryItemMixin (const Path &memoryParentPath, const std::string &exportName, const armem::MemoryID &id)
 
void ensureFileExists (const std::string &filename, bool createIfNotExistent=false) const
 
void ensureFullPathExists (bool createIfNotExistent=false) const
 
void ensureMemoryBasePathExists (bool createIfNotExistent=false) const
 
bool fileExists (const std::string &filename) const
 
bool fullPathExists () const
 
std::vector< PathgetAllDirectories () const
 
std::vector< PathgetAllFiles () const
 
Path getFullPath () const
 
Path getMemoryBasePath () const
 
bool memoryBasePathExists () const
 
std::vector< unsigned char > readDataFromFile (const std::string &filename) const
 
void writeDataToFile (const std::string &filename, const std::vector< unsigned char > &data) const
 
virtual ~DiskMemoryItemMixin ()=default
 
- Public Member Functions inherited from MongoDBStorageMixin
std::optional< mongocxx::collection > collectionExists () const
 
std::optional< mongocxx::database > databaseExists () const
 
std::optional< nlohmann::json > documentExists () const
 
std::optional< nlohmann::json > documentExists (const std::string &id) const
 
mongocxx::collection ensureCollectionExists (bool createIfNotExistent=false)
 
mongocxx::database ensureDatabaseExists (bool createIfNotExistent=false)
 
nlohmann::json ensureDocumentExists (bool createIfNotExistent=false)
 
nlohmann::json ensureDocumentExists (const std::string &id, bool createIfNotExistent=false)
 
mongocxx::collection ensurePreviousCollectionExists (bool createIfNotExistent=false)
 
std::vector< nlohmann::json > getAllDocuments () const
 
std::string getCollectionName () const
 
std::string getDatabaseName () const
 
std::string getDocumentName () const
 
std::string getPreviousCollectionName () const
 
MongoDBSettings getSettings () const
 
 MongoDBStorageMixin ()=default
 
 MongoDBStorageMixin (const MongoDBSettings &settings, const std::string &exportName, const armem::MemoryID &id)
 
std::optional< mongocxx::collection > previousCollectionExists () const
 
nlohmann::json readDataFromDocument () const
 
nlohmann::json readDataFromDocument (const std::string &id) const
 
void writeDataToDocument (const nlohmann::json &data)
 
void writeDataToDocument (const std::string &id, const nlohmann::json &data)
 
void writeForeignKeyToPreviousDocument ()
 
void writeForeignKeyToPreviousDocument (const nlohmann::json &type)
 

Protected Member Functions

void _directlyStore (const armem::wm::Memory &) final
 
void _loadAllReferences (armem::wm::Memory &) final
 
void _resolve (armem::wm::Memory &) final
 
void _store (const armem::wm::Memory &) final
 
- Protected Member Functions inherited from BufferedMemoryMixin< CoreSegment >
void addToBuffer (const armem::wm::Memory &memory)
 
void configureMixin (const nlohmann::json &json)
 configuration More...
 
void createPropertyDefinitions (PropertyDefinitionsPtr &defs, const std::string &prefix)
 
armem::wm::Memory getBuffer () const
 
void setMixinMemoryID (const MemoryID &id)
 
void start ()
 
void stop ()
 
void storeBuffer ()
 
- Protected Member Functions inherited from CachedMemoryMixin< CoreSegment >
void addToCache (const armem::wm::Memory &memory)
 
bool cacheHasCoreSegment (const MemoryID &n) const
 
bool cacheHasCoreSegment (const std::string &n) const
 
bool cacheHasEntity (const MemoryID &n) const
 
bool cacheHasEntityInstance (const MemoryID &n) const
 
bool cacheHasEntitySnapshot (const MemoryID &n) const
 
bool cacheHasProviderSegment (const MemoryID &n) const
 
void configureMixin (const nlohmann::json &json)
 configuration More...
 
armem::wm::Memory getCache () const
 
void setMixinMemoryID (const MemoryID &id)
 
- Protected Member Functions inherited from DiskMemoryItemMixin
Path addDateToMemoryBasePath (const std::filesystem::path &n) const
 
void configureMixin (const nlohmann::json &json)
 
void setMixinExportName (const std::string &n)
 
void setMixinMemoryID (const MemoryID &n)
 
- Protected Member Functions inherited from MongoDBStorageMixin
void configureMixin (const nlohmann::json &json)
 configuration More...
 
void connect () const
 
bool connected () const
 
void setHost (const std::string &)
 
void setMixinExportName (const std::string &n)
 
void setMixinMemoryID (const armem::MemoryID &)
 setter More...
 
void setPassword (const std::string &)
 
void setPort (const unsigned int)
 
void setUser (const std::string &)
 
void start ()
 start More...
 
void stop ()
 

Additional Inherited Members

- Static Public Member Functions inherited from MemoryBase< CoreSegment >
static std::string getLevelName ()
 get level name1 More...
 
- Public Attributes inherited from MemoryBase< CoreSegment >
struct armarx::armem::server::ltm::detail::MemoryBase::Properties p
 
- Static Public Attributes inherited from DiskMemoryItemMixin
static const int DEPTH_TO_DATA_FILES
 
- Protected Attributes inherited from MemoryBase< CoreSegment >
std::atomic_bool enabled
 
std::recursive_mutex ltm_mutex
 
Statistics statistics
 
- Protected Attributes inherited from MemoryItem
std::shared_ptr< Processorsprocessors
 
- Protected Attributes inherited from BufferedMemoryMixin< CoreSegment >
std::unique_ptr< armem::wm::Memorybuffer
 Internal memory for data consolidated from wm to ltm (double-buffer) The to-put-to-ltm buffer (contains data in plain text) This buffer may still be filtered (e.g. More...
 
std::atomic_flag storeFlag
 
float storeFrequency
 The frequency (Hz) to store data to the ltm. More...
 
std::unique_ptr< armem::wm::Memoryto_store
 
- Protected Attributes inherited from CachedMemoryMixin< CoreSegment >
std::unique_ptr< armem::wm::Memorycache
 
- Static Protected Attributes inherited from DiskMemoryItemMixin
static const constexpr char * DATA_FILENAME = "data.aron"
 
static const constexpr char * MEMORY_EXPORT_SUFFIX = "_"
 
static const constexpr char * METADATA_FILENAME = "metadata.aron"
 
static const constexpr char * TYPE_FILENAME = "type.aron"
 
- Static Protected Attributes inherited from MongoDBStorageMixin
static const constexpr char * DATA = "_data"
 
static const constexpr char * FOREIGN_KEY = "_foreign_key"
 
static const constexpr char * ID = "_id"
 
static const constexpr char * METADATA = "_metadata"
 
static const constexpr char * TYPE = "_type"
 

Detailed Description

A memory storing data on the hard drive and in mongodb (needs 'armarx memory start' to start the mongod instance)

Definition at line 18 of file Memory.h.

Member Typedef Documentation

◆ BufferedBase

◆ CachedBase

Definition at line 28 of file Memory.h.

◆ DiskMemoryBase

Definition at line 29 of file Memory.h.

◆ MemoryBase

Definition at line 26 of file Memory.h.

◆ MongoDBStorageMixin

Constructor & Destructor Documentation

◆ Memory() [1/3]

Memory ( )

Definition at line 21 of file Memory.cpp.

◆ Memory() [2/3]

Memory ( const detail::mixin::Path p,
const std::string &  exportName,
const std::string &  memoryName 
)

Definition at line 25 of file Memory.cpp.

◆ Memory() [3/3]

Memory ( const detail::mixin::Path p,
const detail::mixin::MongoDBSettings s,
const std::string &  exportName,
const std::string &  memoryName 
)

Definition at line 33 of file Memory.cpp.

Member Function Documentation

◆ _configure()

void _configure ( const nlohmann::json &  )
finalvirtual

configuration

Reimplemented from MemoryBase< CoreSegment >.

Definition at line 11 of file Memory.cpp.

+ Here is the call graph for this function:

◆ _directlyStore()

void _directlyStore ( const armem::wm::Memory memory)
finalprotectedvirtual

Implements MemoryBase< CoreSegment >.

Definition at line 216 of file Memory.cpp.

+ Here is the call graph for this function:

◆ _disable()

void _disable ( )
finalvirtual

Reimplemented from MemoryBase< CoreSegment >.

Definition at line 62 of file Memory.cpp.

+ Here is the call graph for this function:

◆ _enable()

void _enable ( )
finalvirtual

Reimplemented from MemoryBase< CoreSegment >.

Definition at line 55 of file Memory.cpp.

+ Here is the call graph for this function:

◆ _loadAllReferences()

void _loadAllReferences ( armem::wm::Memory m)
finalprotectedvirtual

Implements MemoryBase< CoreSegment >.

Definition at line 171 of file Memory.cpp.

+ Here is the call graph for this function:

◆ _resolve()

void _resolve ( armem::wm::Memory m)
finalprotectedvirtual

Implements MemoryBase< CoreSegment >.

Definition at line 189 of file Memory.cpp.

+ Here is the call graph for this function:

◆ _setExportName()

void _setExportName ( const std::string &  n)
finalvirtual

Reimplemented from MemoryBase< CoreSegment >.

Definition at line 48 of file Memory.cpp.

+ Here is the call graph for this function:

◆ _setMemoryID()

void _setMemoryID ( const MemoryID id)
finalvirtual

Reimplemented from MemoryItem.

Definition at line 71 of file Memory.cpp.

+ Here is the call graph for this function:

◆ _store()

void _store ( const armem::wm::Memory m)
finalprotectedvirtual

Implements MemoryBase< CoreSegment >.

Definition at line 210 of file Memory.cpp.

+ Here is the call graph for this function:

◆ createPropertyDefinitions()

void createPropertyDefinitions ( PropertyDefinitionsPtr defs,
const std::string &  prefix 
)
overridevirtual

default parameters. Implementation should use the configuration to configure

Reimplemented from MemoryBase< CoreSegment >.

Definition at line 163 of file Memory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findCoreSegment()

std::unique_ptr< CoreSegment > findCoreSegment ( const std::string &  ) const
finalvirtual

find core segment

Implements MemoryBase< CoreSegment >.

Definition at line 146 of file Memory.cpp.

+ Here is the call graph for this function:

◆ forEachCoreSegment()

bool forEachCoreSegment ( std::function< void(CoreSegment &)>  func) const
finalvirtual

iterate over all core segments of this ltm

Implements MemoryBase< CoreSegment >.

Definition at line 82 of file Memory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAndSaveStatistics()

void getAndSaveStatistics ( )

getAndSaveStatistics generates and saves statistics for a LTM recording

Definition at line 256 of file Memory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasCoreSegment()

bool hasCoreSegment ( const std::string &  ) const
finalvirtual

check if core segment exists

Implements MemoryBase< CoreSegment >.

Definition at line 109 of file Memory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: