![]() |
GemaCoreLib
The GeMA Core library
|
Class responsible for storing the needed data to rollback an "append only" file to a previous state. More...
#include <gmStateDumpItem.h>
Public Member Functions | |
GmStateDumpFileItem (int id, FILE *fhandle, QString fileName, QString tempName, const GmLogCategory &logger, QString itemNamePrefix="") | |
Constructor. See class description for the fileName and tempName difference. | |
virtual int | itemType () const |
Returns the item type. | |
![]() | |
GmStateDumpVariantMapDataItem (int id, QVariantMap *data, bool fixedHint, const GmLogCategory &logger, QString itemNamePrefix="") | |
![]() | |
GmStateDumpMapDataItem (int id, QMap< QString, QVariant > *data, bool fixedHint, const GmLogCategory &logger, QString itemNamePrefix="") | |
Constructor. | |
virtual bool | canCompress () const |
Should this item be compressed if the MemoryDump object is configured with compression? | |
virtual bool | partialOp () const |
Does this item supports partial load / save operations? | |
virtual bool | fixedSize () const |
Is this dump item a fixed size item that probably won't grow in the future? If so, extra space will NOT be reserved on file for growing even if growing is configured on the memory dump object. | |
virtual bool | opStart (int op) |
Function called by GmMemoryDump::load(), GmMemoryDump::save(), GmMemoryDump::loadItem() and GmMemoryDump::saveItem() to indicate that a load (op == 1) or save (op == 0) operation on this item will begin. More... | |
virtual bool | opEnd (int op) |
Function called by GmMemoryDump::load(), GmMemoryDump::save(), GmMemoryDump::loadItem() and GmMemoryDump::saveItem() to indicate that a load (op == 1) or save (op == 0) operation was completed succesfully (it won't be called if the operation failed). More... | |
virtual qint64 | size () const |
Returns the current item size (in bytes) | |
virtual bool | fillDataHeader (char *header) |
Function called together with getDataBuffer() to provide a "header information" with fixed size (equal to GM_MEMORY_DUMP_ITEM_DATA_SIZE) that is also saved for the dump item. This information is then made available when setDataBuffer() is called. More... | |
virtual void | getDataBuffer (GmMemoryBufferList &bufferList, qint64 size=0, qint64 offset=0) |
Fills the provided bufferList object with the set of buffers that together define the dump item data. More... | |
virtual bool | setDataBuffer (GmMemoryBufferList &bufferList, const char *header, qint64 size, qint64 offset=0) |
Fills the provided bufferList object with the set of buffers that should be used to update the dump item data. More... | |
virtual void | bufferReleased (int op, bool ok) |
Function called once after a call to getDataBuffer() / setDataBuffer() to inform the item data that the returned buffer will not be used anymore by the memory dump object. More... | |
![]() | |
GmStateDumpBaseDataItem (int id, QString prefix, const GmLogCategory &logger) | |
Constructor. | |
int | id () |
Returns the internal dump item id. | |
virtual int | itemSize () const |
The item size needed for calculating sizes and offsets in bytes for partial updates. Includes the dimension. | |
virtual QString | itemName () const |
Returns the default item name composed of the object prefix + '_' + the object id, optionally followed by '_' + the name suffix (if nameSuffix returns a string different from "") | |
![]() | |
virtual | ~GmMemoryDumpItem () |
Virtual destructor. | |
Protected Member Functions | |
virtual bool | fillMapData (QVariantMap *map) |
virtual bool | mapDataLoaded (QVariantMap *map) |
![]() | |
virtual bool | fillMapData (QMap< QString, QVariant > *map) |
A virtual function called just before a save operation that can be used by derived classes to fill the map that will be saved. If it returns false, the save operation will be aborted. | |
virtual bool | mapDataLoaded (QMap< QString, QVariant > *map) |
A virtual function called just after a load operation that can be used by derived classes to validate the loaded data and fill its own structures. If it returns false, the load operation will be aborted. | |
![]() | |
virtual QString | nameSuffix () const |
Virtual method returning the extra part of the item name, added to its standard prefix. | |
Private Attributes | |
FILE * | _fileh |
The file handle. | |
QString | _baseName |
The base file name. Should be equal to the same data when restored. | |
QString | _fileName |
The actual file name for fileh. Might be different from _baseName when working with temp files. | |
QVariantMap | _dataMap |
The stored variant map. | |
Additional Inherited Members | |
![]() | |
int | _id |
The object id. | |
QString | _prefix |
The object name prefix. | |
const GmLogCategory & | _logger |
Basic logger object for dump messages. | |
Class responsible for storing the needed data to rollback an "append only" file to a previous state.
There are two modes of operation.
1) The object is created with a file handle and a single file name. When the state is saved, the current file size is saved. When loaded, the current file is truncated to the saved size. For this to work, the file must NOT be overwritten (cleared) on the restore operation (must not be opened with a "w" flag). It is also NOT compatible with multiple restore operations where the second one is a "later" state than the previous.
2) The object is created with a file handle and two file names. On this scenario, the first file name is the ultimate file desired by the user. It is used by this class as a verification option. The second file name is a temporary file where the data is really saved during the simulation and corresponds to the given file handle. When the simulation is done, this file is copied (not by this class) to the desired name and the temp file kept for dump restoration in a manner simmilar to what is done with the neutral file generation. When the state is saved, the current file size is saved. When loaded, first we verify if the desired file saved on the dump is the same as the one received on the constructor. If ok, the saved size is used to copy that many bytes from the temp file used on the dump creation to the current temp file (they should be different), overwritting its contents.