|
OpenTTD Source 20251104-master-g3befbdd52f
|
Class for persistent storage of data. More...
#include <newgrf_storage.h>
Public Types | |
| using | StorageType = std::array< TYPE, SIZE > |
Public Member Functions | |
| void | StoreValue (uint pos, int32_t value) |
| Stores some value at a given position. | |
| TYPE | GetValue (uint pos) const |
| Gets the value from a given position. | |
| void | ClearChanges () override |
| Discard temporary changes. | |
Public Member Functions inherited from BasePersistentStorageArray | |
| virtual | ~BasePersistentStorageArray () |
| Remove references to use. | |
Data Fields | |
| StorageType | storage {} |
| Memory for the storage array. | |
| std::unique_ptr< StorageType > | prev_storage {} |
| Temporary memory to store previous state so it can be reverted, e.g. for command tests. | |
Data Fields inherited from BasePersistentStorageArray | |
| uint32_t | grfid = 0 |
| GRFID associated to this persistent storage. A value of zero means "default". | |
| GrfSpecFeature | feature = GSF_INVALID |
| NOSAVE: Used to identify in the owner of the array in debug output. | |
| TileIndex | tile = INVALID_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(). | |
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 67 of file newgrf_storage.h.
| using PersistentStorageArray< TYPE, SIZE >::StorageType = std::array<TYPE, SIZE> |
Definition at line 68 of file newgrf_storage.h.
|
inlineoverridevirtual |
Discard temporary changes.
Implements BasePersistentStorageArray.
Definition at line 116 of file newgrf_storage.h.
References PersistentStorageArray< TYPE, SIZE >::prev_storage, and PersistentStorageArray< TYPE, SIZE >::storage.
|
inline |
Gets the value from a given position.
| pos | the position to get the data from |
Definition at line 108 of file newgrf_storage.h.
References PersistentStorageArray< TYPE, SIZE >::storage.
Referenced by AirportScopeResolver::GetVariable(), and IndustriesScopeResolver::GetVariable().
|
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.
| pos | the position to write at |
| value | the value to write |
Definition at line 80 of file newgrf_storage.h.
References AddChangedPersistentStorage(), BasePersistentStorageArray::AreChangesPersistent(), PersistentStorageArray< TYPE, SIZE >::prev_storage, and PersistentStorageArray< TYPE, SIZE >::storage.
Referenced by AirportScopeResolver::StorePSA(), IndustriesScopeResolver::StorePSA(), and TownScopeResolver::StorePSA().
| std::unique_ptr<StorageType> PersistentStorageArray< TYPE, SIZE >::prev_storage {} |
Temporary memory to store previous state so it can be reverted, e.g. for command tests.
Definition at line 71 of file newgrf_storage.h.
Referenced by PersistentStorageArray< TYPE, SIZE >::ClearChanges(), and PersistentStorageArray< TYPE, SIZE >::StoreValue().
| StorageType PersistentStorageArray< TYPE, SIZE >::storage {} |
Memory for the storage array.
Definition at line 70 of file newgrf_storage.h.
Referenced by PersistentStorageArray< TYPE, SIZE >::ClearChanges(), NIHIndustry::GetPSA(), NIHAirport::GetPSA(), PersistentStorageArray< TYPE, SIZE >::GetValue(), INDYChunkHandler::Load(), and PersistentStorageArray< TYPE, SIZE >::StoreValue().