OpenTTD Source 20241224-master-gf74b0cf984
|
Class for pooled persistent storage of data. More...
#include <newgrf_storage.h>
Public Member Functions | |
PersistentStorage (const uint32_t new_grfid, uint8_t feature, TileIndex tile) | |
We don't want GCC to zero our struct! It already is zeroed and has an index! | |
Public Member Functions inherited from PersistentStorageArray< int32_t, 256 > | |
void | StoreValue (uint pos, int32_t value) |
Stores some value at a given position. | |
int32_t | 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. | |
Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_persistent_storage_pool > | |
void * | operator new (size_t size) |
Allocates space for new Titem. | |
void * | operator new (size_t size, size_t index) |
Allocates space for new Titem with given index. | |
void * | operator new (size_t, void *ptr) |
Allocates space for new Titem at given memory address. | |
void | operator delete (void *p) |
Marks Titem as free. | |
Additional Inherited Members | |
Public Types inherited from PersistentStorageArray< int32_t, 256 > | |
using | StorageType = std::array< int32_t, SIZE > |
Public Types inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_persistent_storage_pool > | |
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero > | Pool |
Type of the pool this item is going to be part of. | |
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 Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_persistent_storage_pool > | |
static bool | CanAllocateItem (size_t n=1) |
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() | |
static bool | CleaningPool () |
Returns current state of pool cleaning - yes or no. | |
static bool | IsValidID (size_t index) |
Tests whether given index can be used to get valid (non-nullptr) Titem. | |
static Titem * | Get (size_t index) |
Returns Titem with given index. | |
static Titem * | GetIfValid (size_t index) |
Returns Titem with given index. | |
static size_t | GetPoolSize () |
Returns first unused index. | |
static size_t | GetNumItems () |
Returns number of valid items in the pool. | |
static void | PostDestructor (size_t index) |
Dummy function called after destructor of each member. | |
static Pool::IterateWrapper< Titem > | Iterate (size_t from=0) |
Returns an iterable ensemble of all valid Titem. | |
Data Fields inherited from PersistentStorageArray< int32_t, 256 > | |
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 |
GRFID associated to this persistent storage. A value of zero means "default". | |
uint8_t | 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. | |
Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_persistent_storage_pool > | |
Tindex | index |
Index of this pool item. | |
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 pooled persistent storage of data.
Definition at line 199 of file newgrf_storage.h.
|
inline |
We don't want GCC to zero our struct! It already is zeroed and has an index!
Definition at line 201 of file newgrf_storage.h.
References BasePersistentStorageArray::feature, BasePersistentStorageArray::grfid, and BasePersistentStorageArray::tile.