Class for persistent storage of data. More...
#include <newgrf_storage.h>
Public Member Functions | |
PersistentStorageArray () | |
Simply construct the array. | |
~PersistentStorageArray () | |
And free all data related to it. | |
void | ResetToZero () |
Resets all values to zero. | |
void | Store (uint pos, int32 value) |
Stores some value at a given position. | |
TYPE | Get (uint pos) const |
Gets the value from a given position. | |
void | ClearChanges (bool keep_changes) |
Clear the changes, or assign them permanently to the storage. | |
Data Fields | |
TYPE | storage [SIZE] |
Memory to for the storage array. | |
TYPE * | prev_storage |
Memory to store "old" states so we can revert them on the performance of test cases for commands etc. |
Class for persistent storage of data.
On ClearChanges that data is either reverted or saved.
TYPE | the type of variable to store. | |
SIZE | the size of the array. |
Definition at line 49 of file newgrf_storage.h.
void PersistentStorageArray< TYPE, SIZE >::ClearChanges | ( | bool | keep_changes | ) | [inline, virtual] |
Clear the changes, or assign them permanently to the storage.
keep_changes | Whether to assign or ditch the changes. |
Implements BaseStorageArray.
Definition at line 117 of file newgrf_storage.h.
TYPE PersistentStorageArray< TYPE, SIZE >::Get | ( | uint | pos | ) | const [inline] |
Gets the value from a given position.
pos | the position to get the data from |
Definition at line 105 of file newgrf_storage.h.
void PersistentStorageArray< TYPE, SIZE >::ResetToZero | ( | ) | [inline] |
Resets all values to zero.
Definition at line 66 of file newgrf_storage.h.
void PersistentStorageArray< TYPE, SIZE >::Store | ( | uint | pos, | |
int32 | value | |||
) | [inline, virtual] |
Stores some value at a given position.
If there is no backup of the data that backup is made and then we write the data.
pos | the position to write at | |
value | the value to write |
Implements BaseStorageArray.
Definition at line 78 of file newgrf_storage.h.