MemoryPersistenceStrategy Class Referenceabstract

Abstract memory persistence strategy (resp. More...

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

+ Inheritance diagram for MemoryPersistenceStrategy:

Public Member Functions

virtual bool containsContainer (const armarx::armem::MemoryID &id, std::string key)=0
 
virtual bool containsItem (const armarx::armem::MemoryID &id, std::string key)=0
 
virtual void createPropertyDefinitions (PropertyDefinitionsPtr &defs, const std::string &prefix)=0
 
virtual void disable ()
 
virtual void enable ()
 
virtual std::vector< std::string > getContainerKeys (const armarx::armem::MemoryID &id)=0
 Returns keys that allow use to move a step further in the hierarchy (e.g. More...
 
std::string getExportName ()
 
std::string getIdentifier ()
 
virtual std::vector< std::string > getItemKeys (const armarx::armem::MemoryID &id)=0
 Keys of the actual items containing data stored for the memory id. More...
 
virtual bool isEnabled ()
 
 MemoryPersistenceStrategy ()
 
 MemoryPersistenceStrategy (const std::string &identifier, const std::string &exportName, bool enabled=true)
 
virtual std::vector< unsigned char > retrieveItem (const armarx::armem::MemoryID &id, std::string key)=0
 Retrieve the actual data of an item stored for the memory id. More...
 
std::vector< unsigned char > retrieveItem (const armarx::armem::MemoryID &memoryId, ItemIdentifier itemIdentifier)
 
virtual ItemResult retrieveItemWithOrigin (const armarx::armem::MemoryID &id, std::string &key)
 Retrieves the actual data but also appends the origin which is in this case the strategy identifier. More...
 
virtual void setExportName (const std::string &exportName)
 
void setIdentifier (const std::string &identifier)
 
virtual void storeItem (const armarx::armem::MemoryID &id, std::string key, std::vector< unsigned char > &data)=0
 Stores an item containing actual data for the current memory id. More...
 
void storeItem (const armarx::armem::MemoryID &memoryId, ItemIdentifier itemIdentifer, std::vector< unsigned char > &data)
 
virtual ~MemoryPersistenceStrategy ()=default
 

Static Public Attributes

static const constexpr char * DATA_FILENAME = "data.aron"
 
static const int DEPTH_TO_DATA_FILES = 7
 
static const constexpr char * MEMORY_EXPORT_SUFFIX = "_"
 
static const constexpr char * METADATA_FILENAME = "metadata.aron"
 
static const constexpr char * TYPE_FILENAME = "type.aron"
 

Protected Attributes

bool enabled_ = true
 If false, the strategy is not writing or reading anything. More...
 
std::string exportName_
 Name of the specific memory export where our items should be stored. More...
 
std::string identifier_
 Name of the strategy. More...
 

Detailed Description

Abstract memory persistence strategy (resp.

LTM sink)

Given a memory id, we can store items for it. A memory id is in terms of the persistence strategy an container that again might contain other containers or items with the actual data. We can also retrieve the current containers, which are a hierarchy below of the current memory id. The export name specifies our specific LTM export. You might want to write different exports with the same strategy. Nonetheless you could also create another strategy (

See also
RedundantPersistenceStrategy)

Why do we basically have to supply the MemoryID everywhere? The first approach had an internal variable to the memory id, as it is kind of bound the memory hierarchy level and thus the id. But even though the MemoryID was stored by pass-by-value there was still somewhere and somehow and sometimes a reference to it, getting you into Teufels-Küche. Because the MemoryID is extended with finer hierarchy details, having the sideeffect, that this memory id would be changed. Also you needed a clone function, now you can just pass the strategy pointer.

How are the containers created? -> Implicitly, whenever a item underneath is stored

Want to create a new fancy ltm sink option? Maybe MongoDB? -> Implement this interface and add it similar to the existing strategy (e.g. DiskPersistence) at all locations. Don´t forget any ice proxies! (a powerful full text search is your friend)

Definition at line 61 of file MemoryPersistenceStrategy.h.

Constructor & Destructor Documentation

◆ MemoryPersistenceStrategy() [1/2]

Definition at line 63 of file MemoryPersistenceStrategy.h.

◆ MemoryPersistenceStrategy() [2/2]

MemoryPersistenceStrategy ( const std::string &  identifier,
const std::string &  exportName,
bool  enabled = true 
)
inline
Parameters
identifierbasically a unique name for the strategy (important if you use different strategies
See also
RedundantPersistenceStrategy)
Parameters
exportNameidentifier for the exported memory where any items are written (e.g. a directory)

Definition at line 69 of file MemoryPersistenceStrategy.h.

◆ ~MemoryPersistenceStrategy()

virtual ~MemoryPersistenceStrategy ( )
virtualdefault

Member Function Documentation

◆ containsContainer()

virtual bool containsContainer ( const armarx::armem::MemoryID id,
std::string  key 
)
pure virtual

◆ containsItem()

virtual bool containsItem ( const armarx::armem::MemoryID id,
std::string  key 
)
pure virtual

◆ createPropertyDefinitions()

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

◆ disable()

virtual void disable ( )
inlinevirtual

Reimplemented in RedundantPersistenceStrategy.

Definition at line 151 of file MemoryPersistenceStrategy.h.

+ Here is the caller graph for this function:

◆ enable()

virtual void enable ( )
inlinevirtual

Reimplemented in RedundantPersistenceStrategy.

Definition at line 156 of file MemoryPersistenceStrategy.h.

◆ getContainerKeys()

virtual std::vector<std::string> getContainerKeys ( const armarx::armem::MemoryID id)
pure virtual

Returns keys that allow use to move a step further in the hierarchy (e.g.

if our memory id ends in a core segment it gives us the provider segment keys).

Implemented in RestPersistence, DiskPersistence, and RedundantPersistenceStrategy.

◆ getExportName()

std::string getExportName ( )
inline

Definition at line 131 of file MemoryPersistenceStrategy.h.

◆ getIdentifier()

std::string getIdentifier ( )
inline

Definition at line 136 of file MemoryPersistenceStrategy.h.

◆ getItemKeys()

virtual std::vector<std::string> getItemKeys ( const armarx::armem::MemoryID id)
pure virtual

Keys of the actual items containing data stored for the memory id.

Implemented in RestPersistence, DiskPersistence, and RedundantPersistenceStrategy.

◆ isEnabled()

virtual bool isEnabled ( )
inlinevirtual

Reimplemented in RedundantPersistenceStrategy.

Definition at line 146 of file MemoryPersistenceStrategy.h.

◆ retrieveItem() [1/2]

virtual std::vector<unsigned char> retrieveItem ( const armarx::armem::MemoryID id,
std::string  key 
)
pure virtual

Retrieve the actual data of an item stored for the memory id.

Returns
stored data

Implemented in RedundantPersistenceStrategy, DiskPersistence, and RestPersistence.

+ Here is the caller graph for this function:

◆ retrieveItem() [2/2]

std::vector<unsigned char> retrieveItem ( const armarx::armem::MemoryID memoryId,
ItemIdentifier  itemIdentifier 
)
inline

Definition at line 121 of file MemoryPersistenceStrategy.h.

+ Here is the call graph for this function:

◆ retrieveItemWithOrigin()

virtual ItemResult retrieveItemWithOrigin ( const armarx::armem::MemoryID id,
std::string &  key 
)
inlinevirtual

Retrieves the actual data but also appends the origin which is in this case the strategy identifier.

Reimplemented in RedundantPersistenceStrategy.

Definition at line 113 of file MemoryPersistenceStrategy.h.

+ Here is the call graph for this function:

◆ setExportName()

virtual void setExportName ( const std::string &  exportName)
inlinevirtual

Reimplemented in RedundantPersistenceStrategy.

Definition at line 126 of file MemoryPersistenceStrategy.h.

◆ setIdentifier()

void setIdentifier ( const std::string &  identifier)
inline

Definition at line 141 of file MemoryPersistenceStrategy.h.

◆ storeItem() [1/2]

virtual void storeItem ( const armarx::armem::MemoryID id,
std::string  key,
std::vector< unsigned char > &  data 
)
pure virtual

Stores an item containing actual data for the current memory id.

How it is stored depends on the implementation of a concrete strategy (e.g. on disk in a specific directory).

Parameters
keyunique identifier of our item for the specific id (e.g. filename). Note the keys can be equal for different id levels. So you might find the same key on the core segment level as well as on the entity level.
dataactual data written to the persistent item

Implemented in DiskPersistence, RestPersistence, and RedundantPersistenceStrategy.

+ Here is the caller graph for this function:

◆ storeItem() [2/2]

void storeItem ( const armarx::armem::MemoryID memoryId,
ItemIdentifier  itemIdentifer,
std::vector< unsigned char > &  data 
)
inline

Definition at line 98 of file MemoryPersistenceStrategy.h.

+ Here is the call graph for this function:

Member Data Documentation

◆ DATA_FILENAME

const constexpr char* DATA_FILENAME = "data.aron"
staticconstexpr

Definition at line 166 of file MemoryPersistenceStrategy.h.

◆ DEPTH_TO_DATA_FILES

const int DEPTH_TO_DATA_FILES = 7
static

Definition at line 163 of file MemoryPersistenceStrategy.h.

◆ enabled_

bool enabled_ = true
protected

If false, the strategy is not writing or reading anything.

Only default values are returned if necessary.

Definition at line 187 of file MemoryPersistenceStrategy.h.

◆ exportName_

std::string exportName_
protected

Name of the specific memory export where our items should be stored.

If you change the export name you will probably write the data to another target (e.g. different directory).

Definition at line 181 of file MemoryPersistenceStrategy.h.

◆ identifier_

std::string identifier_
protected

Name of the strategy.

Should be unique to avoid ambiguities.

Definition at line 175 of file MemoryPersistenceStrategy.h.

◆ MEMORY_EXPORT_SUFFIX

const constexpr char* MEMORY_EXPORT_SUFFIX = "_"
staticconstexpr

Definition at line 169 of file MemoryPersistenceStrategy.h.

◆ METADATA_FILENAME

const constexpr char* METADATA_FILENAME = "metadata.aron"
staticconstexpr

Definition at line 167 of file MemoryPersistenceStrategy.h.

◆ TYPE_FILENAME

const constexpr char* TYPE_FILENAME = "type.aron"
staticconstexpr

Definition at line 165 of file MemoryPersistenceStrategy.h.


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