OpenTTD
Public Member Functions | Data Fields
PersistentStorageArray< TYPE, SIZE > Struct Template Reference

Class for persistent storage of data. More...

#include <newgrf_storage.h>

Inheritance diagram for PersistentStorageArray< TYPE, SIZE >:
BasePersistentStorageArray

Public Member Functions

 PersistentStorageArray ()
 Simply construct the array.
 ~PersistentStorageArray ()
 And free all data related to it.
void ResetToZero ()
 Resets all values to zero.
void StoreValue (uint pos, int32 value)
 Stores some value at a given position.
TYPE GetValue (uint pos) const
 Gets the value from a given position.
void ClearChanges ()
 Discard temporary changes.
- Public Member Functions inherited from BasePersistentStorageArray
virtual ~BasePersistentStorageArray ()
 Remove references to use.

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.
- Data Fields inherited from BasePersistentStorageArray
uint32 grfid
 GRFID associated to this persistent storage. A value of zero means "default".
byte feature
 NOSAVE: Used to identify in the owner of the array in debug output.
TileIndex tile
 NOSAVE: Used to identify in the owner of the array in debug output.

Additional Inherited Members

- Static Public Member Functions inherited from BasePersistentStorageArray
static void SwitchMode (PersistentStorageMode mode, bool ignore_prev_mode=false)
 Clear temporary changes made since the last call to SwitchMode, and set whether subsequent changes shall be persistent or temporary.
- Static Protected Member Functions inherited from BasePersistentStorageArray
static bool AreChangesPersistent ()
 Check whether currently changes to the storage shall be persistent or temporary till the next call to ClearChanges().

Detailed Description

template<typename TYPE, uint SIZE>
struct PersistentStorageArray< TYPE, SIZE >

Class for persistent storage of data.

On ClearChanges that data is either reverted or saved.

Template Parameters
TYPEthe type of variable to store.
SIZEthe size of the array.

Definition at line 68 of file newgrf_storage.h.

Member Function Documentation

template<typename TYPE, uint SIZE>
TYPE PersistentStorageArray< TYPE, SIZE >::GetValue ( uint  pos) const
inline

Gets the value from a given position.

Parameters
posthe position to get the data from
Returns
the data from that position

Definition at line 126 of file newgrf_storage.h.

Referenced by AfterLoadGame(), IndustriesScopeResolver::GetVariable(), and AirportScopeResolver::GetVariable().

template<typename TYPE, uint SIZE>
void PersistentStorageArray< TYPE, SIZE >::ResetToZero ( )
inline

Resets all values to zero.

Definition at line 85 of file newgrf_storage.h.

template<typename TYPE, uint SIZE>
void PersistentStorageArray< TYPE, SIZE >::StoreValue ( uint  pos,
int32  value 
)
inline

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.

Parameters
posthe position to write at
valuethe value to write

Definition at line 97 of file newgrf_storage.h.

Referenced by IndustriesScopeResolver::StorePSA(), TownScopeResolver::StorePSA(), and AirportScopeResolver::StorePSA().


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