5#include "../Memory/MemoryBuffer.h"
9 namespace ComponentModel
50 debug_assert(index < capacity &&
"Element index out of bounds.");
51 debug_assert(index * elementSize < store.size() &&
"Storage not allocated for specified index.");
53 return store.data() + elementSize * index;
59 debug_assert(index < capacity &&
"Element index out of bounds.");
60 debug_assert(index * elementSize < store.size() &&
"Storage not allocated for specified index.");
62 return store.data() + elementSize * index;
81 template<
typename DataType>
109 new (data) DataType();
Base class for data pools.
const void * operator[](SizeType index) const
Retrieve a const pointer to the data for the element at the given index.
COGSFOUNDATION_API void allocate(ComponentHandle handle)
Allocate a new 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.
COGSFOUNDATION_API void deallocate(ComponentHandle handle)
Deallocate the data element in the pool at the index used by the given component handle.
Typed data pool for storing data in parallel to a component pool.
void create(ComponentHandle handle)
Create a new instance of DataType.
ComponentDataPool(SizeType capacity, MemBlockType memType=MemBlockType::Bucket)
Constructs a data pool with the given capacity.
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.
void destroy(ComponentHandle handle)
Destroy the instance of DataType at the index used by the given handle.
ComponentDataPool()
Constructs a data pool with default capacity.
Contains all Cogs related functionality.
ComponentIndex SizeType
Type used to track the size of pools.
Handle to a Component instance.