|
OpenTTD Source 20260208-master-g43af8e94d0
|
Base class for all PoolItems. More...
#include <pool_type.hpp>
Public Types | |
| typedef struct Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache > | Pool |
| Type of the pool this item is going to be part of. | |
Public Member Functions | |
| PoolItem (Tindex index) | |
| Construct the item. | |
| void * | operator new (size_t)=delete |
| Do not use new PoolItem, but rather PoolItem::Create. | |
| void | operator delete (void *p, size_t size) |
| Marks Titem as free. | |
| 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(...). | |
Static Public Member Functions | |
| template<typename T = Titem, typename... Targs> | |
| static T * | Create (Targs &&... args) |
| Creates a new T-object in the associated pool. | |
| template<typename T = Titem, typename... Targs> | |
| 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 | |
| const Tindex | index |
| Index of this pool item. | |
Base class for all PoolItems.
| Tpool | The pool this item is going to be part of |
Definition at line 290 of file pool_type.hpp.
| typedef struct Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache > Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::Pool |
Type of the pool this item is going to be part of.
Definition at line 300 of file pool_type.hpp.
|
inline |
|
inlinestatic |
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function().
Tests whether we can allocate 'n' items
| n | number of items we want to allocate |
Definition at line 360 of file pool_type.hpp.
|
inlinestatic |
Returns current state of pool cleaning - yes or no.
Definition at line 369 of file pool_type.hpp.
|
inlinestatic |
Creates a new T-object in the associated pool.
| args | The arguments to the constructor. |
Definition at line 333 of file pool_type.hpp.
References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::data, and index.
|
inlinestatic |
Creates a new T-object in the associated pool.
| index | The to allocate the object at. |
| args | The arguments to the constructor. |
Definition at line 347 of file pool_type.hpp.
References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::data, and index.
|
inlinestatic |
Returns Titem with given index.
| index | of item to get |
Definition at line 390 of file pool_type.hpp.
References index.
|
inlinestatic |
Returns Titem with given index.
| index | of item to get |
Definition at line 401 of file pool_type.hpp.
References index.
|
inlinestatic |
Returns number of valid items in the pool.
Definition at line 420 of file pool_type.hpp.
|
inlinestatic |
Returns first unused index.
Useful when iterating over all pool items.
Definition at line 411 of file pool_type.hpp.
|
inlinestatic |
Tests whether given index can be used to get valid (non-nullptr) Titem.
| index | index to examine |
Definition at line 379 of file pool_type.hpp.
References index.
|
inlinestatic |
Returns an iterable ensemble of all valid Titem.
| from | index of the first Titem to consider |
Definition at line 439 of file pool_type.hpp.
|
inline |
Marks Titem as free.
Its memory is released
| p | memory to free |
| size | The size that was allocated during allocation. |
Definition at line 311 of file pool_type.hpp.
|
inlinestatic |
Dummy function called after destructor of each member.
If you want to use it, override it in PoolItem's subclass.
| index | index of deleted item |
Definition at line 432 of file pool_type.hpp.
References index.
| const Tindex Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index |
Index of this pool item.
Definition at line 291 of file pool_type.hpp.
Referenced by Create(), CreateAtIndex(), Get(), GetIfValid(), IsValidID(), operator new(), PoolItem(), and PostDestructor().