Cogs.Foundation
|
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.
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.
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.
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.
Referenced by ComponentPoolBase().
void Cogs::ComponentModel::ComponentPoolBase::deallocateComponent | ( | ComponentHandle | handle | ) |
Deallocates a component from the pool, calling the destructor of the derived component type.
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.
Referenced by operator[](), and resolve().
|
inline |
Get the index of the given component in the storage pool.
References Cogs::ComponentModel::Component::getIndex().
|
inline |
Checks if the given flag is set.
Cogs::SizeType Cogs::ComponentModel::ComponentPoolBase::maxSize | ( | ) | const |
Get the maximum size of the pool.
Get the component at the given roster index.
References get().
Referenced by Cogs::ComponentModel::ComponentPool< ComponentType >::operator[]().
void Cogs::ComponentModel::ComponentPoolBase::resize | ( | SizeType | capacity | ) |
Resize the pool.
Referenced by ComponentPoolBase().
|
inline |
Resolve a pointer to the component with the given handle.
References get().
|
inline |
Set the given flag.
|
inline |
Gets the current size of the pool, the number components currently active.
Referenced by Cogs::ComponentModel::ComponentPool< ComponentType >::end().