Cogs.Core
|
Untyped Component pool base. More...
#include <ComponentPool.h>
Public Member Functions | |
COGSFOUNDATION_API | ComponentPoolBase (const Reflection::TypeId typeId, SizeType capacity, Memory::Allocator *allocator, MemBlockType memType) |
Constructs a new pool base for components with the given type. | |
COGSFOUNDATION_API ComponentHandle | allocateComponent () |
Allocates and initializes a new component using placement new into the backing store. | |
COGSFOUNDATION_API void | deallocateComponent (ComponentHandle handle) |
Deallocates a component from the pool, calling the destructor of the derived component type. | |
Component & | operator[] (SizeType index) |
Get the component at the given roster index. | |
Component * | get (size_t index) |
Retrieve a pointer to the component at the given index. The pointer is valid until any new allocations are made. | |
Component * | resolve (const ComponentHandle handle) |
Resolve a pointer to the component with the given handle. | |
COGSFOUNDATION_API void | resize (SizeType capacity) |
Resize the pool. | |
SizeType | size () const |
Gets the current size of the pool, the number components currently active. | |
SizeType | capacity () const |
Get the capacity of the pool, the number of components that can be allocated without resizing the pool. | |
COGSFOUNDATION_API SizeType | maxSize () const |
Get the maximum size of the pool. | |
SizeType | getComponentIndex (const Component *component) const |
Get the index of the given component in the storage pool. | |
void | setFlag (ComponentPoolFlags::EComponentPoolFlags flag) |
Set the given flag. | |
bool | isSet (const uint32_t flag) const |
Checks if the given flag is set. | |
Untyped Component pool base.
Holds raw backing storage for capacity components. Uses the given Reflection::Type to determine the size and layout of the backing store.
Components are placement constructed into the raw backing store when allocated, and their destructors are run when deallocated.
Definition at line 36 of file ComponentPool.h.
Cogs::ComponentModel::ComponentPoolBase::ComponentPoolBase | ( | const Reflection::TypeId | typeId, |
SizeType | capacity, | ||
Memory::Allocator * | allocator, | ||
MemBlockType | memType | ||
) |
Constructs a new pool base for components with the given type.
The initial capacity is set to capacity number of components.
Definition at line 13 of file ComponentPool.cpp.
References capacity(), Cogs::Reflection::TypeDatabase::getType(), and resize().
Cogs::ComponentModel::ComponentHandle Cogs::ComponentModel::ComponentPoolBase::allocateComponent | ( | ) |
Allocates and initializes a new component using placement new into the backing store.
Definition at line 28 of file ComponentPool.cpp.
References Cogs::ComponentModel::ComponentPoolFlags::AllowGrow, Cogs::Reflection::TypeDatabase::constructInstance(), and Cogs::Reflection::TypeDatabase::getType().
|
inline |
Get the capacity of the pool, the number of components that can be allocated without resizing the pool.
Definition at line 80 of file ComponentPool.h.
Referenced by ComponentPoolBase().
void Cogs::ComponentModel::ComponentPoolBase::deallocateComponent | ( | ComponentHandle | handle | ) |
Deallocates a component from the pool, calling the destructor of the derived component type.
Definition at line 59 of file ComponentPool.cpp.
References Cogs::Reflection::TypeDatabase::destructInstance(), Cogs::Reflection::TypeDatabase::getType(), and Cogs::ComponentModel::ComponentHandle::resolve().
|
inline |
Retrieve a pointer to the component at the given index. The pointer is valid until any new allocations are made.
Definition at line 62 of file ComponentPool.h.
Referenced by operator[](), and resolve().
|
inline |
Get the index of the given component in the storage pool.
Definition at line 86 of file ComponentPool.h.
References Cogs::ComponentModel::Component::getIndex().
|
inline |
Checks if the given flag is set.
Definition at line 92 of file ComponentPool.h.
Cogs::SizeType Cogs::ComponentModel::ComponentPoolBase::maxSize | ( | ) | const |
Get the maximum size of the pool.
Definition at line 103 of file ComponentPool.cpp.
Get the component at the given roster index.
Definition at line 56 of file ComponentPool.h.
References get().
Referenced by Cogs::ComponentModel::ComponentPool< ComponentType >::operator[]().
void Cogs::ComponentModel::ComponentPoolBase::resize | ( | SizeType | capacity | ) |
Resize the pool.
Definition at line 93 of file ComponentPool.cpp.
Referenced by ComponentPoolBase().
|
inline |
Resolve a pointer to the component with the given handle.
Definition at line 68 of file ComponentPool.h.
References get().
|
inline |
Set the given flag.
Definition at line 89 of file ComponentPool.h.
|
inline |
Gets the current size of the pool, the number components currently active.
Definition at line 77 of file ComponentPool.h.
Referenced by Cogs::ComponentModel::ComponentPool< ComponentType >::end().