MIRA
Public Member Functions | Public Attributes | Protected Attributes | List of all members
StripedStorageXML Class Reference

Stores data sequentially into different files (striped) providing a reliable way to retrieve data later from one of the files even if some of the files are corrupted (e.g. More...

#include <database/StripedStorage.h>

Inheritance diagram for StripedStorageXML:
Inheritance graph
[legend]

Public Member Functions

 StripedStorageXML ()
 
 StripedStorageXML (std::string baseName, uint32 maxFiles)
 
 StripedStorageXML (const Path &directory, std::string baseName, uint32 maxFiles)
 
template<typename T >
Path store (const T &data, const Time &at=Time::now())
 Stores the given data in one of the files adding a timestamp and returns the filename of the written file. More...
 
template<typename T >
std::pair< T, Timeretrieve (bool(*validCheckFunc)(const T &)=NULL) const
 Retrieves the data from one of the files. More...
 
void setFilePath (const Path &path)
 Resolves path and assigns to filePath. More...
 
const PathgetFilePath ()
 
Path generateFilename (uint32 fileNr) const
 Returns the filename (including path) of the file with the specified nr. More...
 
std::list< PathgetFiles () const
 Returns a list of filenames (including paths) for all files that are used for persistent storage. More...
 
void deleteAllFiles ()
 Delete all files that were stored by the persistent storage. More...
 

Public Attributes

std::string fileNameBase
 The base filename. More...
 
std::string extension
 The file name extension. More...
 
uint32 maxFiles
 Maximum number of used files. More...
 

Protected Attributes

Path filePath
 The path where the files are stored. More...
 
uint32 mCurrentFileIdx
 

Detailed Description

Stores data sequentially into different files (striped) providing a reliable way to retrieve data later from one of the files even if some of the files are corrupted (e.g.

caused by program termination during write operation).

Constructor & Destructor Documentation

◆ StripedStorageXML() [1/3]

StripedStorageXML ( )
inline

◆ StripedStorageXML() [2/3]

StripedStorageXML ( std::string  baseName,
uint32  maxFiles 
)
inline

◆ StripedStorageXML() [3/3]

StripedStorageXML ( const Path directory,
std::string  baseName,
uint32  maxFiles 
)
inline

Member Function Documentation

◆ store()

Path store ( const T &  data,
const Time at = Time::now() 
)
inline

Stores the given data in one of the files adding a timestamp and returns the filename of the written file.

◆ retrieve()

std::pair<T, Time> retrieve ( bool(*)(const T &)  validCheckFunc = NULL) const
inline

Retrieves the data from one of the files.

If more than one file contain valid data the data with the newest timestamp is returned.

Parameters
validCheckFuncoptional function for checking if restored data is valid
Returns
A pair of data and timestamp

◆ setFilePath()

void setFilePath ( const Path path)
inlineinherited

Resolves path and assigns to filePath.

◆ getFilePath()

const Path& getFilePath ( )
inlineinherited

◆ generateFilename()

Path generateFilename ( uint32  fileNr) const
inlineinherited

Returns the filename (including path) of the file with the specified nr.

◆ getFiles()

std::list<Path> getFiles ( ) const
inlineinherited

Returns a list of filenames (including paths) for all files that are used for persistent storage.

◆ deleteAllFiles()

void deleteAllFiles ( )
inlineinherited

Delete all files that were stored by the persistent storage.

Member Data Documentation

◆ fileNameBase

std::string fileNameBase
inherited

The base filename.

◆ extension

std::string extension
inherited

The file name extension.

◆ maxFiles

uint32 maxFiles
inherited

Maximum number of used files.

◆ filePath

Path filePath
protectedinherited

The path where the files are stored.

◆ mCurrentFileIdx

uint32 mCurrentFileIdx
protectedinherited

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