OpenTTD Source  20241108-master-g80f628063a
PersistentStorage Struct Reference

Class for pooled persistent storage of data. More...

#include <newgrf_storage.h>

Inheritance diagram for PersistentStorage:
PersistentStorageArray< int32_t, 256 > Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_persistent_storage_pool > BasePersistentStorageArray

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. More...
 
int32_t GetValue (uint pos) const
 Gets the value from a given position. More...
 
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. More...
 
void * operator new (size_t size, size_t index)
 Allocates space for new Titem with given index. More...
 
void * operator new (size_t, void *ptr)
 Allocates space for new Titem at given memory address. More...
 
void operator delete (void *p)
 Marks Titem as free. More...
 

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. More...
 
- 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() More...
 
static bool CleaningPool ()
 Returns current state of pool cleaning - yes or no. More...
 
static bool IsValidID (size_t index)
 Tests whether given index can be used to get valid (non-nullptr) Titem. More...
 
static Titem * Get (size_t index)
 Returns Titem with given index. More...
 
static Titem * GetIfValid (size_t index)
 Returns Titem with given index. More...
 
static size_t GetPoolSize ()
 Returns first unused index. More...
 
static size_t GetNumItems ()
 Returns number of valid items in the pool. More...
 
static void PostDestructor ([[maybe_unused]] size_t index)
 Dummy function called after destructor of each member. More...
 
static Pool::IterateWrapper< Titem > Iterate (size_t from=0)
 Returns an iterable ensemble of all valid Titem. More...
 
- 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().
 

Detailed Description

Class for pooled persistent storage of data.

Definition at line 199 of file newgrf_storage.h.


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