Cogs.Core
Public Member Functions | List of all members
Cogs::ComponentModel::ComponentDataPool< DataType > Class Template Reference

Typed data pool for storing data in parallel to a component pool. More...

#include <ComponentDataPool.h>

Inheritance diagram for Cogs::ComponentModel::ComponentDataPool< DataType >:
Cogs::ComponentModel::ComponentDataPoolBase

Public Member Functions

 ComponentDataPool ()
 Constructs a data pool with default capacity.
 
 ComponentDataPool (SizeType capacity, MemBlockType memType=MemBlockType::Bucket)
 Constructs a data pool with the given capacity.
 
void create (ComponentHandle handle)
 Create a new instance of DataType.
 
void destroy (ComponentHandle handle)
 Destroy the instance of DataType at the index used by the given handle.
 
DataType & operator[] (SizeType index)
 Retrieve a reference to the element at the given index.
 
const DataType & operator[] (SizeType index) const
 Retrieve a const reference to the element at the given index.
 

Additional Inherited Members

- Private Member Functions inherited from Cogs::ComponentModel::ComponentDataPoolBase
COGSFOUNDATION_API ComponentDataPoolBase (SizeType capacity, size_t elementSize, MemBlockType memType=MemBlockType::Bucket)
 Constructs a data pool with the given capacity and element size.
 
COGSFOUNDATION_API void allocate (ComponentHandle handle)
 Allocate a new data element in the pool at the index used by the given component handle.
 
COGSFOUNDATION_API void deallocate (ComponentHandle handle)
 Deallocate the data element in the pool at the index used by the given component handle.
 
void * operator[] (SizeType index)
 Retrieve a pointer to the data for the element at the given index.
 
const void * operator[] (SizeType index) const
 Retrieve a const pointer to the data for the element at the given index.
 

Detailed Description

template<typename DataType>
class Cogs::ComponentModel::ComponentDataPool< DataType >

Typed data pool for storing data in parallel to a component pool.

See also
ComponentDataPoolBase
Template Parameters
DataTypeType of element to store in the pool. The pool will initially allocate storage for sizeof(DataType) * capacity bytes.

Definition at line 82 of file ComponentDataPool.h.

Constructor & Destructor Documentation

◆ ComponentDataPool() [1/2]

template<typename DataType >
Cogs::ComponentModel::ComponentDataPool< DataType >::ComponentDataPool ( )
inline

Constructs a data pool with default capacity.

Definition at line 88 of file ComponentDataPool.h.

◆ ComponentDataPool() [2/2]

template<typename DataType >
Cogs::ComponentModel::ComponentDataPool< DataType >::ComponentDataPool ( SizeType  capacity,
MemBlockType  memType = MemBlockType::Bucket 
)
inline

Constructs a data pool with the given capacity.

Parameters
capacityNumber of elements to allocate storage for initially.

Definition at line 95 of file ComponentDataPool.h.

Member Function Documentation

◆ create()

template<typename DataType >
void Cogs::ComponentModel::ComponentDataPool< DataType >::create ( ComponentHandle  handle)
inline

Create a new instance of DataType.

The instance will be in-place constructed in the pool storage.

If the index of the given handle is outside the capacity, the pool will grow automatically to contain the given index.

Definition at line 103 of file ComponentDataPool.h.

References Cogs::ComponentModel::ComponentDataPoolBase::allocate(), and Cogs::ComponentModel::ComponentDataPoolBase::operator[]().

◆ destroy()

template<typename DataType >
void Cogs::ComponentModel::ComponentDataPool< DataType >::destroy ( ComponentHandle  handle)
inline

Destroy the instance of DataType at the index used by the given handle.

Note that the destructor is run, but no storage is freed.

Definition at line 117 of file ComponentDataPool.h.

References Cogs::ComponentModel::ComponentDataPoolBase::deallocate(), and Cogs::ComponentModel::ComponentDataPoolBase::operator[]().

◆ operator[]() [1/2]

template<typename DataType >
DataType & Cogs::ComponentModel::ComponentDataPool< DataType >::operator[] ( SizeType  index)
inline

Retrieve a reference to the element at the given index.

It is the callers responsibility that the element at the given index has been constructed using create(), and that the given index is in bounds.

Definition at line 132 of file ComponentDataPool.h.

References Cogs::ComponentModel::ComponentDataPoolBase::operator[]().

◆ operator[]() [2/2]

template<typename DataType >
const DataType & Cogs::ComponentModel::ComponentDataPool< DataType >::operator[] ( SizeType  index) const
inline

Retrieve a const reference to the element at the given index.

It is the callers responsibility that the element at the given index has been constructed using create(), and that the given index is in bounds.

Definition at line 143 of file ComponentDataPool.h.

References Cogs::ComponentModel::ComponentDataPoolBase::operator[]().


The documentation for this class was generated from the following file: