Cogs.Core
Classes | Public Member Functions | Friends | List of all members
Cogs::ComponentModel::ComponentPool< ComponentType > Struct Template Reference

Typed component pool. More...

#include <ComponentPool.h>

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

Classes

struct  ComponentIterator
 Custom iterator providing iteration support for component pools. More...
 

Public Member Functions

 ComponentPool (Memory::Allocator *allocator, SizeType poolSize, MemBlockType memType=MemBlockType::Bucket)
 Construct a component pool instance.
 
 ComponentPool (SizeType poolSize=16384)
 Construct a component pool instance.
 
ComponentIterator begin ()
 Returns an iterator to the beginning of the pool.
 
ComponentIterator end ()
 Returns an iterator to the end of the pool.
 
ComponentType & operator[] (SizeType index)
 Access the component at the given index.
 
- Public Member Functions inherited from Cogs::ComponentModel::ComponentPoolBase
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.
 

Friends

struct ComponentIterator
 

Detailed Description

template<typename ComponentType>
struct Cogs::ComponentModel::ComponentPool< ComponentType >

Typed component pool.

Provides typed access to components.

Definition at line 123 of file ComponentPool.h.

Constructor & Destructor Documentation

◆ ComponentPool() [1/2]

template<typename ComponentType >
Cogs::ComponentModel::ComponentPool< ComponentType >::ComponentPool ( Memory::Allocator allocator,
SizeType  poolSize,
MemBlockType  memType = MemBlockType::Bucket 
)
inline

Construct a component pool instance.

Definition at line 186 of file ComponentPool.h.

◆ ComponentPool() [2/2]

template<typename ComponentType >
Cogs::ComponentModel::ComponentPool< ComponentType >::ComponentPool ( SizeType  poolSize = 16384)
inline

Construct a component pool instance.

Definition at line 194 of file ComponentPool.h.

Member Function Documentation

◆ begin()

template<typename ComponentType >
ComponentIterator Cogs::ComponentModel::ComponentPool< ComponentType >::begin ( )
inline

Returns an iterator to the beginning of the pool.

Definition at line 200 of file ComponentPool.h.

◆ end()

template<typename ComponentType >
ComponentIterator Cogs::ComponentModel::ComponentPool< ComponentType >::end ( )
inline

Returns an iterator to the end of the pool.

Definition at line 203 of file ComponentPool.h.

References Cogs::ComponentModel::ComponentPoolBase::size().

◆ operator[]()

template<typename ComponentType >
ComponentType & Cogs::ComponentModel::ComponentPool< ComponentType >::operator[] ( SizeType  index)
inline

Access the component at the given index.

Definition at line 206 of file ComponentPool.h.

References Cogs::ComponentModel::ComponentPoolBase::operator[]().

Friends And Related Function Documentation

◆ ComponentIterator

template<typename ComponentType >
friend struct ComponentIterator
friend

Definition at line 212 of file ComponentPool.h.


The documentation for this struct was generated from the following file: