#include <pool_type.hpp>
Public Member Functions | |
FORCEINLINE void * | operator new (size_t size) |
Allocates space for new Titem. | |
FORCEINLINE void | operator delete (void *p) |
Marks Titem as free. | |
FORCEINLINE void * | operator new (size_t size, size_t index) |
Allocates space for new Titem with given index. | |
FORCEINLINE void * | operator new (size_t size, void *ptr) |
Allocates space for new Titem at given memory address. | |
Static Public Member Functions | |
static FORCEINLINE bool | CanAllocateItem (size_t n=1) |
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function(). | |
static FORCEINLINE bool | CleaningPool () |
Returns current state of pool cleaning - yes or no. | |
static FORCEINLINE bool | IsValidID (size_t index) |
Tests whether given index can be used to get valid (non-NULL) Titem. | |
static FORCEINLINE Titem * | Get (size_t index) |
Returs Titem with given index. | |
static FORCEINLINE Titem * | GetIfValid (size_t index) |
Returs Titem with given index. | |
static FORCEINLINE size_t | GetPoolSize () |
Returns first unused index. | |
static FORCEINLINE size_t | GetNumItems () |
Returns number of valid items in the pool. | |
static FORCEINLINE void | PostDestructor (size_t index) |
Dummy function called after destructor of each member. | |
Data Fields | |
Tindex | index |
Index of this pool item. |
Tpool | The pool this item is going to be part of |
Definition at line 82 of file pool_type.hpp.
FORCEINLINE void* Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::operator new | ( | size_t | size | ) | [inline] |
Allocates space for new Titem.
size | size of Titem |
Definition at line 91 of file pool_type.hpp.
FORCEINLINE void Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::operator delete | ( | void * | p | ) | [inline] |
Marks Titem as free.
Its memory is released
p | memory to free |
Definition at line 101 of file pool_type.hpp.
FORCEINLINE void* Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::operator new | ( | size_t | size, | |
size_t | index | |||
) | [inline] |
Allocates space for new Titem with given index.
size | size of Titem | |
index | index of item |
Definition at line 116 of file pool_type.hpp.
FORCEINLINE void* Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::operator new | ( | size_t | size, | |
void * | ptr | |||
) | [inline] |
Allocates space for new Titem at given memory address.
size | size of Titem | |
ptr | where are we allocating the item? |
Definition at line 129 of file pool_type.hpp.
static FORCEINLINE bool Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CanAllocateItem | ( | size_t | n = 1 |
) | [inline, static] |
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 151 of file pool_type.hpp.
Referenced by AddEngineReplacement(), CmdBuildAirport(), CmdBuildDock(), CmdBuildRailStation(), CmdBuildRoadStop(), CmdCloneOrder(), CmdInsertOrder(), and CreateNewIndustryHelper().
static FORCEINLINE bool Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::CleaningPool | ( | ) | [inline, static] |
Returns current state of pool cleaning - yes or no.
Definition at line 160 of file pool_type.hpp.
Referenced by Station::~Station().
static FORCEINLINE bool Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::IsValidID | ( | size_t | index | ) | [inline, static] |
Tests whether given index can be used to get valid (non-NULL) Titem.
index | index to examine |
Reimplemented in SpecializedStation< T, Tis_waypoint >, SpecializedVehicle< T, Type >, SpecializedStation< Station, false >, SpecializedStation< Waypoint, true >, SpecializedVehicle< DisasterVehicle, VEH_DISASTER >, SpecializedVehicle< Ship, VEH_SHIP >, SpecializedVehicle< Train, VEH_TRAIN >, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >, SpecializedVehicle< EffectVehicle, VEH_EFFECT >, and SpecializedVehicle< RoadVehicle, VEH_ROAD >.
Definition at line 170 of file pool_type.hpp.
Referenced by Industry::GetRandom(), IntToReference(), and SpecializedStation< Waypoint, true >::IsValidID().
static FORCEINLINE Titem* Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::Get | ( | size_t | index | ) | [inline, static] |
Returs Titem with given index.
index | of item to get |
Reimplemented in SpecializedStation< T, Tis_waypoint >, SpecializedVehicle< T, Type >, SpecializedStation< Station, false >, SpecializedStation< Waypoint, true >, SpecializedVehicle< DisasterVehicle, VEH_DISASTER >, SpecializedVehicle< Ship, VEH_SHIP >, SpecializedVehicle< Train, VEH_TRAIN >, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >, SpecializedVehicle< EffectVehicle, VEH_EFFECT >, and SpecializedVehicle< RoadVehicle, VEH_ROAD >.
Definition at line 181 of file pool_type.hpp.
Referenced by AICargoList_IndustryAccepting::AICargoList_IndustryAccepting(), AICargoList_IndustryProducing::AICargoList_IndustryProducing(), AITileList_IndustryAccepting::AITileList_IndustryAccepting(), AITileList_IndustryProducing::AITileList_IndustryProducing(), CalcClosestStationTile(), CheckSubsidised(), DisasterTick_Aircraft(), SpecializedStation< Waypoint, true >::Get(), AIIndustry::GetAmountOfStationsAround(), AISubsidy::GetAwardedTo(), Industry::GetByTile(), BaseStation::GetByTile(), AISubsidy::GetDestinationType(), Train::GetDisplayImageWidth(), AIIndustry::GetDockLocation(), AISubsidy::GetExpireDate(), AIIndustry::GetHeliportLocation(), AIIndustry::GetLastMonthProduction(), AIIndustry::GetLastMonthTransported(), AIIndustry::GetLastMonthTransportedPercentage(), Industry::GetRandom(), GetReferenceTile(), AISubsidy::GetSourceType(), AIIndustry::GetStockpiledCargo(), AIIndustry::HasDock(), AIIndustry::HasHeliport(), IntToReference(), AIIndustry::IsBuiltOnWater(), AIIndustry::IsCargoAccepted(), SpecializedStation< Waypoint, true >::IsValidID(), OrderDestinationIsAllowed(), CargoPayment::PayFinalDelivery(), and SetPartOfSubsidyFlag().
static FORCEINLINE Titem* Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::GetIfValid | ( | size_t | index | ) | [inline, static] |
Returs Titem with given index.
index | of item to get |
Reimplemented in SpecializedStation< T, Tis_waypoint >, SpecializedVehicle< T, Type >, SpecializedStation< Station, false >, SpecializedStation< Waypoint, true >, SpecializedVehicle< DisasterVehicle, VEH_DISASTER >, SpecializedVehicle< Ship, VEH_SHIP >, SpecializedVehicle< Train, VEH_TRAIN >, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >, SpecializedVehicle< EffectVehicle, VEH_EFFECT >, and SpecializedVehicle< RoadVehicle, VEH_ROAD >.
Definition at line 192 of file pool_type.hpp.
Referenced by AIBaseStation::IsValidBaseStation().
static FORCEINLINE size_t Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::GetPoolSize | ( | ) | [inline, static] |
Returns first unused index.
Useful when iterating over all pool items.
Definition at line 202 of file pool_type.hpp.
Referenced by Industry::GetRandom().
static FORCEINLINE size_t Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::GetNumItems | ( | ) | [inline, static] |
Returns number of valid items in the pool.
Definition at line 211 of file pool_type.hpp.
Referenced by AIIndustry::GetIndustryCount(), and Industry::GetRandom().
static FORCEINLINE void Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::PostDestructor | ( | size_t | index | ) | [inline, static] |
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 |
it's called only when !CleaningPool()
Reimplemented in BaseStation, and Industry.
Definition at line 223 of file pool_type.hpp.