Objectpool

SDK Object Pool API documentation

Namespace: ObjectPool
Include: #include <dmsdk/dlib/object_pool.h>
STRUCTS
struct dmObjectPool Object pool data-structure with the following prop...
FUNCTIONS
uint32_t Alloc() Allocate a new object
uint32_t Capacity()
void dmObjectPool( capacity) Constructor
void Free(uint32_t index, bool clear) Returns object index to the object pool
bool Full() Checks if the pool is full
T& Get(uint32_t index) Get object from logical index
dmArray& GetRawObjects() Get the array of currently active objects
void Set(uint32_t index, T& object) Set object from logical index
void SetCapacity(uint32_t capacity) Set capacity. New capacity must be >= old_capacity
uint32_t Size() get size

Functions

Alloc

uint32_t Alloc()

Allocate a new object

PARAMETERS

RETURNS

uint32_t logical index

Capacity

uint32_t Capacity()

PARAMETERS

RETURNS

uint32_t maximum number of objects

dmObjectPool

void dmObjectPool( capacity)

Constructor

PARAMETERS

capacity

Free

void Free(uint32_t index, bool clear)

Returns object index to the object pool

PARAMETERS

uint32_t index index of object
bool clear If set, memset's the object memory

Full

bool Full()

Checks if the pool is full

PARAMETERS

RETURNS

bool returns true if the pool is full

Get

T& Get(uint32_t index)

Get object from logical index

PARAMETERS

uint32_t index index of the object

RETURNS

T& a reference to the object

GetRawObjects

dmArray& GetRawObjects()

Get the array of currently active objects

PARAMETERS

RETURNS

dmArray& a reference to the array of objects

Set

void Set(uint32_t index, T& object)

Set object from logical index

PARAMETERS

uint32_t index index of object
T& object reference ot object. THe object stored is copied by value.

SetCapacity

void SetCapacity(uint32_t capacity)

Set capacity. New capacity must be >= old_capacity

PARAMETERS

uint32_t capacity max number of objects to store

Size

uint32_t Size()

Get number of objects currently stored

PARAMETERS

RETURNS

uint32_t returns the number of objects currently stored

Structs

dmObjectPool

TYPE

struct dmObjectPool

Object pool data-structure with the following properties - Mapping from logical index to physical index - Logical index does not changes - Allocated objects are contiguously laid out in memory Loop of m_Objects [0..Size()-1] times to iterate all objects - Internal physical order is not preserved and a direct consequence of the contiguous property