Cogs.Core
|
Typed data pool for storing data in parallel to a component pool. More...
#include <ComponentDataPool.h>
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 | |
![]() | |
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. | |
Typed data pool for storing data in parallel to a component pool.
DataType | Type 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.
|
inline |
Constructs a data pool with default capacity.
Definition at line 88 of file ComponentDataPool.h.
|
inline |
Constructs a data pool with the given capacity.
capacity | Number of elements to allocate storage for initially. |
Definition at line 95 of file ComponentDataPool.h.
|
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[]().
|
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[]().
|
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[]().
|
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[]().