DiskPersistence Class Reference

Persistence strategy that writes items (e.g. More...

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

+ Inheritance diagram for DiskPersistence:

Public Member Functions

bool containsContainer (const armarx::armem::MemoryID &id, std::string key) override
 Checks if the container is available for the current memory id. More...
 
bool containsItem (const armarx::armem::MemoryID &id, std::string key) override
 Checks if current container contains the item defined by its key. More...
 
void createPropertyDefinitions (PropertyDefinitionsPtr &defs, const std::string &prefix) override
 
 DiskPersistence ()
 
 DiskPersistence (const std::filesystem::path &memoryParentPath)
 
 DiskPersistence (const std::string &identifier, const std::string &exportName, const std::filesystem::path &memoryParentPath)
 
std::vector< std::string > getContainerKeys (const armarx::armem::MemoryID &id) override
 Returns all containers for the current id. More...
 
std::vector< std::string > getItemKeys (const armarx::armem::MemoryID &id) override
 Returns all items for the current id. More...
 
std::vector< unsigned char > retrieveItem (const armarx::armem::MemoryID &id, std::string key) override
 Reads the data of the file with name 'key' at the current location. More...
 
void setMinAvailableDiskSpace (const int minDiskSpace)
 
void storeItem (const armarx::armem::MemoryID &id, std::string key, std::vector< unsigned char > &data) override
 Create a new file with name 'key' and stores the data inside it. More...
 
- Public Member Functions inherited from MemoryPersistenceStrategy
virtual void disable ()
 
virtual void enable ()
 
std::string getExportName ()
 
std::string getIdentifier ()
 
virtual bool isEnabled ()
 
 MemoryPersistenceStrategy ()
 
 MemoryPersistenceStrategy (const std::string &identifier, const std::string &exportName, bool enabled=true)
 
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)
 
void storeItem (const armarx::armem::MemoryID &memoryId, ItemIdentifier itemIdentifer, std::vector< unsigned char > &data)
 
virtual ~MemoryPersistenceStrategy ()=default
 

Public Attributes

int minDiskSpace = 50
 

Additional Inherited Members

- Static Public Attributes inherited from MemoryPersistenceStrategy
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 inherited from MemoryPersistenceStrategy
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

Persistence strategy that writes items (e.g.

json files) to a specific container (a directory) Use it to write the data of a WM to disk.

Where are the items written (=:location)? /memoryParentPath/exportName/path(id)/

How is the file of an item named? -> Just they key (e.g. filename = key = "data.aron.json") If you might want a more sophisticated solution fell free to implement your custom ItemIdentifier today!

Definition at line 47 of file DiskPersistence.h.

Constructor & Destructor Documentation

◆ DiskPersistence() [1/3]

DiskPersistence ( )
inline

Definition at line 50 of file DiskPersistence.h.

◆ DiskPersistence() [2/3]

DiskPersistence ( const std::filesystem::path &  memoryParentPath)
inline

Definition at line 54 of file DiskPersistence.h.

◆ DiskPersistence() [3/3]

DiskPersistence ( const std::string &  identifier,
const std::string &  exportName,
const std::filesystem::path &  memoryParentPath 
)
inline
Parameters
identifierbasically a unique name for the strategy (important if you use different strategies
See also
RedundantPersistenceStrategy)
Parameters
exportNameidentifier for the exported memory. A new directory with name is created beneath the memoryParentPath. Everything is stored inside it.
memoryParentPathpath where the memory should be exported to

Definition at line 64 of file DiskPersistence.h.

Member Function Documentation

◆ containsContainer()

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

Checks if the container is available for the current memory id.

Returns
true if the current location contains the directory with name 'key'

Implements MemoryPersistenceStrategy.

Definition at line 120 of file DiskPersistence.cpp.

+ Here is the call graph for this function:

◆ containsItem()

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

Checks if current container contains the item defined by its key.

Returns
true if the current location contains a file with the name 'key'

Implements MemoryPersistenceStrategy.

Definition at line 145 of file DiskPersistence.cpp.

◆ createPropertyDefinitions()

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

Implements MemoryPersistenceStrategy.

Definition at line 110 of file DiskPersistence.h.

◆ getContainerKeys()

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

Returns all containers for the current id.

Returns
containers <=> directories at current location (=/memoryParentPath/exportName/path(id)/)

Implements MemoryPersistenceStrategy.

Definition at line 9 of file DiskPersistence.cpp.

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

◆ getItemKeys()

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

Returns all items for the current id.

Returns
items <=> files at the current location (=/memoryParentPath/exportName/path(id)/)

Implements MemoryPersistenceStrategy.

Definition at line 95 of file DiskPersistence.cpp.

+ Here is the call graph for this function:

◆ retrieveItem()

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

Reads the data of the file with name 'key' at the current location.

Returns
data if a file was found, an empty vector if the file is empty or was not found

Implements MemoryPersistenceStrategy.

Definition at line 180 of file DiskPersistence.cpp.

◆ setMinAvailableDiskSpace()

void setMinAvailableDiskSpace ( const int  minDiskSpace)
inline

Definition at line 116 of file DiskPersistence.h.

◆ storeItem()

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

Create a new file with name 'key' and stores the data inside it.

Implements MemoryPersistenceStrategy.

Definition at line 157 of file DiskPersistence.cpp.

Member Data Documentation

◆ minDiskSpace

int minDiskSpace = 50

Definition at line 128 of file DiskPersistence.h.


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