|
Abstract memory persistence strategy (resp. More...
#include <RobotAPI/libraries/armem/server/ltm/persistence/MemoryPersistenceStrategy.h>
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... | |
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 (
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.
|
inline |
Definition at line 63 of file MemoryPersistenceStrategy.h.
|
inline |
identifier | basically a unique name for the strategy (important if you use different strategies |
exportName | identifier for the exported memory where any items are written (e.g. a directory) |
Definition at line 69 of file MemoryPersistenceStrategy.h.
|
virtualdefault |
|
pure virtual |
Implemented in DiskPersistence, RestPersistence, and RedundantPersistenceStrategy.
|
pure virtual |
Implemented in DiskPersistence, RestPersistence, and RedundantPersistenceStrategy.
|
pure virtual |
Implemented in RedundantPersistenceStrategy, DiskPersistence, and RestPersistence.
|
inlinevirtual |
Reimplemented in RedundantPersistenceStrategy.
Definition at line 151 of file MemoryPersistenceStrategy.h.
|
inlinevirtual |
Reimplemented in RedundantPersistenceStrategy.
Definition at line 156 of file MemoryPersistenceStrategy.h.
|
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.
|
inline |
Definition at line 131 of file MemoryPersistenceStrategy.h.
|
inline |
Definition at line 136 of file MemoryPersistenceStrategy.h.
|
pure virtual |
Keys of the actual items containing data stored for the memory id.
Implemented in RestPersistence, DiskPersistence, and RedundantPersistenceStrategy.
|
inlinevirtual |
Reimplemented in RedundantPersistenceStrategy.
Definition at line 146 of file MemoryPersistenceStrategy.h.
|
pure virtual |
Retrieve the actual data of an item stored for the memory id.
Implemented in RedundantPersistenceStrategy, DiskPersistence, and RestPersistence.
|
inline |
Definition at line 121 of file MemoryPersistenceStrategy.h.
|
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.
|
inlinevirtual |
Reimplemented in RedundantPersistenceStrategy.
Definition at line 126 of file MemoryPersistenceStrategy.h.
|
inline |
Definition at line 141 of file MemoryPersistenceStrategy.h.
|
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).
key | unique 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. |
data | actual data written to the persistent item |
Implemented in DiskPersistence, RestPersistence, and RedundantPersistenceStrategy.
|
inline |
Definition at line 98 of file MemoryPersistenceStrategy.h.
|
staticconstexpr |
Definition at line 166 of file MemoryPersistenceStrategy.h.
|
static |
Definition at line 163 of file MemoryPersistenceStrategy.h.
|
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.
|
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.
|
protected |
Name of the strategy.
Should be unique to avoid ambiguities.
Definition at line 175 of file MemoryPersistenceStrategy.h.
|
staticconstexpr |
Definition at line 169 of file MemoryPersistenceStrategy.h.
|
staticconstexpr |
Definition at line 167 of file MemoryPersistenceStrategy.h.
|
staticconstexpr |
Definition at line 165 of file MemoryPersistenceStrategy.h.