Skip to main content

EntityPoolRegistry Class Template

Central registry for managing multiple named EntityPools. More...

Declaration

template <typename THandle> class helios::engine::runtime::pooling::EntityPoolRegistry<THandle> { ... }

Public Constructors Index

template <typename THandle>
EntityPoolRegistry ()=default

Default constructor. More...

Public Member Functions Index

template <typename THandle>
auto addPool (const helios::engine::runtime::pooling::types::EntityPoolId id, std::unique_ptr< EntityPool< THandle > > entityPool) noexcept -> EntityPool< THandle > *

Adds a new pool to the registry. More...

template <typename THandle>
auto pools () -> std::unordered_map< helios::engine::runtime::pooling::types::EntityPoolId, std::unique_ptr< EntityPool< THandle > > > &

Returns a reference to the internal pool map. More...

template <typename THandle>
auto pool (const helios::engine::runtime::pooling::types::EntityPoolId id) const -> EntityPool< THandle > *

Retrieves a pool by its ID. More...

template <typename THandle>
boolhas (const helios::engine::runtime::pooling::types::EntityPoolId id) const noexcept

Checks if a pool with the given ID is registered. More...

Private Member Attributes Index

template <typename THandle>
std::unordered_map< helios::engine::runtime::pooling::types::EntityPoolId, std::unique_ptr< EntityPool< THandle > > >pools_

Maps pool IDs to their corresponding EntityPool instances. More...

Description

Central registry for managing multiple named EntityPools.

EntityPoolRegistry provides a single point of access to all object pools in the game. Each pool is identified by a strongly-typed EntityPoolId, enabling type-safe lookup without string comparisons.

The registry owns all pools exclusively via unique_ptr, ensuring proper cleanup when the registry is destroyed.

Example usage:

 
 constexpr EntityPoolId BULLET_POOL{1};
 registry.addPool(BULLET_POOL, std::make_unique<EntityPool>(100));
 
 // Later, acquire a bullet from the pool
 auto* pool = registry.pool(BULLET_POOL);
 if (pool && pool->acquire(bulletGuid)) {
  // Use the bullet
 }

Definition at line 46 of file EntityPoolRegistry.ixx.

Public Constructors

EntityPoolRegistry()

template <typename THandle>
helios::engine::runtime::pooling::EntityPoolRegistry< THandle >::EntityPoolRegistry ()
default

Default constructor.

Definition at line 60 of file EntityPoolRegistry.ixx.

Public Member Functions

addPool()

template <typename THandle>
EntityPool< THandle > * helios::engine::runtime::pooling::EntityPoolRegistry< THandle >::addPool (const helios::engine::runtime::pooling::types::EntityPoolId id, std::unique_ptr< EntityPool< THandle > > entityPool)
inline noexcept

Adds a new pool to the registry.

If a pool with the given ID already exists, it will be replaced. Ownership of the pool is transferred to the registry.

Parameters
id

The unique identifier for this pool.

entityPool

The pool to add (ownership is transferred).

Returns

Raw pointer to the added pool for immediate use.

Definition at line 73 of file EntityPoolRegistry.ixx.

75 std::unique_ptr<EntityPool<THandle>> entityPool
76 ) noexcept {
77 pools_[id] = std::move(entityPool);
78 return pools_[id].get();
79 }

Reference helios::engine::runtime::pooling::registerComponents.

Referenced by helios::engine::runtime::pooling::EntityPoolManager< TEntity >::init.

has()

template <typename THandle>
bool helios::engine::runtime::pooling::EntityPoolRegistry< THandle >::has (const helios::engine::runtime::pooling::types::EntityPoolId id)
inline noexcept

Checks if a pool with the given ID is registered.

Parameters
id

The identifier of the pool to check.

Returns

True if the pool exists, false otherwise.

Definition at line 119 of file EntityPoolRegistry.ixx.

120 return pools_.contains(id);
121 }

Referenced by helios::engine::runtime::pooling::EntityPoolManager< TEntity >::pool.

pool()

template <typename THandle>
EntityPool< THandle > * helios::engine::runtime::pooling::EntityPoolRegistry< THandle >::pool (const helios::engine::runtime::pooling::types::EntityPoolId id)
inline

Retrieves a pool by its ID.

Parameters
id

The identifier of the pool to retrieve.

Returns

Pointer to the pool, or nullptr if not found.

Definition at line 101 of file EntityPoolRegistry.ixx.

102
103 const auto& it = pools_.find(id);
104
105 if (it == pools_.end()) {
106 return nullptr;
107 }
108
109 return it->second.get();
110 }

Reference helios::engine::runtime::pooling::registerComponents.

Referenced by helios::engine::runtime::pooling::EntityPoolManager< TEntity >::pool.

pools()

template <typename THandle>
std::unordered_map< helios::engine::runtime::pooling::types::EntityPoolId, std::unique_ptr< EntityPool< THandle > > > & helios::engine::runtime::pooling::EntityPoolRegistry< THandle >::pools ()
inline

Returns a reference to the internal pool map.

Provides direct access to all pools for iteration or bulk operations. The returned map should not be modified directly; use addPool() instead.

Returns

Reference to the pool map.

Definition at line 89 of file EntityPoolRegistry.ixx.

89 [[nodiscard]]std::unordered_map<helios::engine::runtime::pooling::types::EntityPoolId, std::unique_ptr<EntityPool<THandle>>>& pools() {
90 return pools_;
91 }

Referenced by helios::engine::runtime::pooling::EntityPoolManager< TEntity >::reset.

Private Member Attributes

pools_

template <typename THandle>
std::unordered_map<helios::engine::runtime::pooling::types::EntityPoolId, std::unique_ptr<EntityPool<THandle> > > helios::engine::runtime::pooling::EntityPoolRegistry< THandle >::pools_

Maps pool IDs to their corresponding EntityPool instances.

Definition at line 53 of file EntityPoolRegistry.ixx.

53 std::unordered_map<helios::engine::runtime::pooling::types::EntityPoolId, std::unique_ptr<EntityPool<THandle>>> pools_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.