OpenTTD Source 20260208-master-g43af8e94d0
pool_func.hpp File Reference

Some methods of Pool are placed here in order to reduce compilation time and binary size. More...

#include "bitmath_func.hpp"
#include "math_func.hpp"
#include "pool_type.hpp"
#include "../error_func.h"
#include "../saveload/saveload_error.hpp"

Go to the source code of this file.

Macros

#define DEFINE_POOL_METHOD(type)
 Helper for defining the method's signature.
#define INSTANTIATE_POOL_METHODS(name)
 Force instantiation of pool methods so we don't get linker errors.

Detailed Description

Some methods of Pool are placed here in order to reduce compilation time and binary size.

Definition in file pool_func.hpp.

Macro Definition Documentation

◆ DEFINE_POOL_METHOD

#define DEFINE_POOL_METHOD ( type)
Value:
template <class Titem, typename Tindex, size_t Tgrowth_step, PoolType Tpool_type, bool Tcache> \
requires std::is_base_of_v<PoolIDBase, Tindex> \
Base class for all pools.

Helper for defining the method's signature.

Parameters
typeThe return type of the method.

Definition at line 24 of file pool_func.hpp.

◆ INSTANTIATE_POOL_METHODS

#define INSTANTIATE_POOL_METHODS ( name)
Value:
template AllocationResult<name ## Pool::IndexType> name ## Pool::GetNew(size_t size); \
template AllocationResult<name ## Pool::IndexType> name ## Pool::GetNew(size_t size, size_t index); \
template void name ## Pool::FreeItem(size_t size, size_t index); \
template void name ## Pool::CleanPool();
void CleanPool() override
Destroys all items in the pool and resets all member variables.
AllocationResult< Tindex > GetNew(size_t size)
Allocates new item.
void FreeItem(size_t size, size_t index)
Deallocates memory used by this index and marks item as free.

Force instantiation of pool methods so we don't get linker errors.

Only methods accessed from methods defined in pool.hpp need to be forcefully instantiated.

Definition at line 210 of file pool_func.hpp.