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();
#define COGSFOUNDATION_API
Definition: FoundationBase.h:31
#define debug_assert(x)
Definition: FoundationBase.h:51
Base class for data pools.
Definition: ComponentDataPool.h:24
const void * operator[](SizeType index) const
Retrieve a const pointer to the data for the element at the given index.
Definition: ComponentDataPool.h:57
COGSFOUNDATION_API void allocate(ComponentHandle handle)
Allocate a new data element in the pool at the index used by the given component handle.
Definition: ComponentDataPool.cpp:13
void * operator[](SizeType index)
Retrieve a pointer to the data for the element at the given index.
Definition: ComponentDataPool.h:48
COGSFOUNDATION_API void deallocate(ComponentHandle handle)
Deallocate the data element in the pool at the index used by the given component handle.
Definition: ComponentDataPool.cpp:29
Typed data pool for storing data in parallel to a component pool.
Definition: ComponentDataPool.h:83
void create(ComponentHandle handle)
Create a new instance of DataType.
Definition: ComponentDataPool.h:103
ComponentDataPool(SizeType capacity, MemBlockType memType=MemBlockType::Bucket)
Constructs a data pool with the given capacity.
Definition: ComponentDataPool.h:95
DataType & operator[](SizeType index)
Retrieve a reference to the element at the given index.
Definition: ComponentDataPool.h:132
const DataType & operator[](SizeType index) const
Retrieve a const reference to the element at the given index.
Definition: ComponentDataPool.h:143
void destroy(ComponentHandle handle)
Destroy the instance of DataType at the index used by the given handle.
Definition: ComponentDataPool.h:117
ComponentDataPool()
Constructs a data pool with default capacity.
Definition: ComponentDataPool.h:88
Definition: MemoryBuffer.h:197
Main Cogs namespace.
Definition: MortonCode.h:5
ComponentIndex SizeType
Type used to track the size of pools.
Definition: Component.h:19
Handle to a Component instance.
Definition: Component.h:67