OpenTTD Source 20260108-master-g8ba1860eaa
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, Tpool_type, Tcache >::PoolItem<&_persistent_storage_pool > BasePersistentStorageArray

Public Member Functions

 PersistentStorage (PersistentStorageID index, const uint32_t new_grfid, GrfSpecFeature feature, TileIndex tile)
 
- 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, Tpool_type, Tcache >::PoolItem<&_persistent_storage_pool >
 PoolItem (Tindex index)
 Construct the item.
 
void * operator new (size_t)=delete
 Do not use new PoolItem, but rather PoolItem::Create.
 
void * operator new (size_t size, Tindex index)=delete
 Do not use new (index) PoolItem(...), but rather PoolItem::CreateAtIndex(index, ...).
 
void * operator new (size_t, void *ptr)=delete
 Do not use new (address) PoolItem(...).
 
void operator delete (void *p, size_t size)
 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, Tpool_type, Tcache >::PoolItem<&_persistent_storage_pool >
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache > 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, Tpool_type, Tcache >::PoolItem<&_persistent_storage_pool >
static T * Create (Targs &&... args)
 Creates a new T-object in the associated pool.
 
static T * CreateAtIndex (Tindex index, Targs &&... args)
 Creates a new T-object in the associated 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 (auto index)
 Tests whether given index can be used to get valid (non-nullptr) Titem.
 
static Titem * Get (auto index)
 Returns Titem with given index.
 
static Titem * GetIfValid (auto 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 = 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.
 
- Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_persistent_storage_pool >
const 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.

Constructor & Destructor Documentation

◆ PersistentStorage()

PersistentStorage::PersistentStorage ( PersistentStorageID  index,
const uint32_t  new_grfid,
GrfSpecFeature  feature,
TileIndex  tile 
)
inline

Definition at line 200 of file newgrf_storage.h.


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