Cogs.Foundation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Cogs::ComponentModel::ComponentPoolBase Class Reference

Untyped Component pool base. More...

#include <ComponentPool.h>

Inheritance diagram for Cogs::ComponentModel::ComponentPoolBase:
Cogs::ComponentModel::ComponentPool< ComponentType >

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.
 
Componentoperator[] (SizeType index)
 Get the component at the given roster index.
 
Componentget (size_t index)
 Retrieve a pointer to the component at the given index. The pointer is valid until any new allocations are made.
 
Componentresolve (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ComponentPoolBase()

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().

Member Function Documentation

◆ allocateComponent()

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().

◆ capacity()

SizeType Cogs::ComponentModel::ComponentPoolBase::capacity ( ) const
inline

Get the capacity of the pool, the number of components that can be allocated without resizing the pool.

Referenced by ComponentPoolBase().

◆ deallocateComponent()

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().

◆ get()

Component * Cogs::ComponentModel::ComponentPoolBase::get ( size_t  index)
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().

◆ getComponentIndex()

SizeType Cogs::ComponentModel::ComponentPoolBase::getComponentIndex ( const Component component) const
inline

Get the index of the given component in the storage pool.

References Cogs::ComponentModel::Component::getIndex().

◆ isSet()

bool Cogs::ComponentModel::ComponentPoolBase::isSet ( const uint32_t  flag) const
inline

Checks if the given flag is set.

◆ maxSize()

Cogs::SizeType Cogs::ComponentModel::ComponentPoolBase::maxSize ( ) const

Get the maximum size of the pool.

◆ operator[]()

Component & Cogs::ComponentModel::ComponentPoolBase::operator[] ( SizeType  index)
inline

Get the component at the given roster index.

References get().

Referenced by Cogs::ComponentModel::ComponentPool< ComponentType >::operator[]().

◆ resize()

void Cogs::ComponentModel::ComponentPoolBase::resize ( SizeType  capacity)

Resize the pool.

Referenced by ComponentPoolBase().

◆ resolve()

Component * Cogs::ComponentModel::ComponentPoolBase::resolve ( const ComponentHandle  handle)
inline

Resolve a pointer to the component with the given handle.

References get().

◆ setFlag()

void Cogs::ComponentModel::ComponentPoolBase::setFlag ( ComponentPoolFlags::EComponentPoolFlags  flag)
inline

Set the given flag.

◆ size()

SizeType Cogs::ComponentModel::ComponentPoolBase::size ( ) const
inline

Gets the current size of the pool, the number components currently active.

Referenced by Cogs::ComponentModel::ComponentPool< ComponentType >::end().


The documentation for this class was generated from the following files: