oldpool.h File Reference

Base for the old pool. More...

#include "core/math_func.hpp"

Go to the source code of this file.

Data Structures

struct  OldMemoryPoolBase
 Stuff for dynamic vehicles. More...
struct  OldMemoryPool< T >
struct  PoolItemIndexLess< T >
 Template providing a predicate to allow STL containers of pointers to pool items to be sorted by index. More...
struct  PoolItem< T, Tid, Tpool >
 Generalization for all pool items that are saved in the savegame. More...

Defines

#define OLD_POOL_ENUM(name, type, block_size_bits, max_blocks)
#define OLD_POOL_ACCESSORS(name, type)
#define DECLARE_OLD_POOL(name, type, block_size_bits, max_blocks)
#define DEFINE_OLD_POOL(name, type, new_block_proc, clean_block_proc)
#define DEFINE_OLD_POOL_GENERIC(name, type)
#define STATIC_OLD_POOL(name, type, block_size_bits, max_blocks, new_block_proc, clean_block_proc)

Typedefs

typedef void OldMemoryPoolNewBlock (uint start_item)
typedef void OldMemoryPoolCleanBlock (uint start_item, uint end_item)

Functions

template<typename T, OldMemoryPool< T > * Tpool>
static void PoolNewBlock (uint start_item)
 Generic function to initialize a new block in a pool.
template<typename T, OldMemoryPool< T > * Tpool>
static void PoolCleanBlock (uint start_item, uint end_item)
 Generic function to free a new block in a pool.


Detailed Description

Base for the old pool.

Definition in file oldpool.h.


Define Documentation

#define DECLARE_OLD_POOL ( name,
type,
block_size_bits,
max_blocks   ) 

Value:

OLD_POOL_ENUM(name, type, block_size_bits, max_blocks) \
  extern OldMemoryPool<type> _##name##_pool; \
  OLD_POOL_ACCESSORS(name, type)

Definition at line 333 of file oldpool.h.

#define DEFINE_OLD_POOL ( name,
type,
new_block_proc,
clean_block_proc   ) 

Value:

OldMemoryPool<type> _##name##_pool( \
    #name, name##_POOL_MAX_BLOCKS, name##_POOL_BLOCK_SIZE_BITS, sizeof(type), \
    new_block_proc, clean_block_proc);

Definition at line 339 of file oldpool.h.

#define DEFINE_OLD_POOL_GENERIC ( name,
type   ) 

Value:

OldMemoryPool<type> _##name##_pool( \
    #name, name##_POOL_MAX_BLOCKS, name##_POOL_BLOCK_SIZE_BITS, sizeof(type), \
    PoolNewBlock<type, &_##name##_pool>, PoolCleanBlock<type, &_##name##_pool>); \
    template type *PoolItem<type, type##ID, &_##name##_pool>::AllocateSafeRaw(uint &first); \
    template bool PoolItem<type, type##ID, &_##name##_pool>::CanAllocateItem(uint count);

Definition at line 344 of file oldpool.h.

#define OLD_POOL_ACCESSORS ( name,
type   ) 

Value:

static inline type *Get##name(uint index) { return _##name##_pool.Get(index);  } \
  static inline uint Get##name##PoolSize()  { return _##name##_pool.GetSize(); }

Definition at line 328 of file oldpool.h.

#define OLD_POOL_ENUM ( name,
type,
block_size_bits,
max_blocks   ) 

Value:

enum { \
    name##_POOL_BLOCK_SIZE_BITS = block_size_bits, \
    name##_POOL_MAX_BLOCKS      = max_blocks \
  };

Definition at line 321 of file oldpool.h.

#define STATIC_OLD_POOL ( name,
type,
block_size_bits,
max_blocks,
new_block_proc,
clean_block_proc   ) 

Value:

OLD_POOL_ENUM(name, type, block_size_bits, max_blocks) \
  static DEFINE_OLD_POOL(name, type, new_block_proc, clean_block_proc) \
  OLD_POOL_ACCESSORS(name, type)

Definition at line 352 of file oldpool.h.


Function Documentation

template<typename T, OldMemoryPool< T > * Tpool>
static void PoolCleanBlock ( uint  start_item,
uint  end_item 
) [inline, static]

Generic function to free a new block in a pool.

Parameters:
start_item the first item that needs to be cleaned
end_item the last item that needs to be cleaned

Definition at line 150 of file oldpool.h.

template<typename T, OldMemoryPool< T > * Tpool>
static void PoolNewBlock ( uint  start_item  )  [inline, static]

Generic function to initialize a new block in a pool.

Parameters:
start_item the first item that needs to be initialized

Definition at line 136 of file oldpool.h.


Generated on Mon May 11 15:48:13 2009 for OpenTTD by  doxygen 1.5.6