Skip to main content

GameObjectPoolRegistry Class

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

Declaration

class helios::engine::runtime::pooling::GameObjectPoolRegistry { ... }

Public Constructors Index

GameObjectPoolRegistry ()=default

Default constructor. More...

Public Member Functions Index

GameObjectPool *addPool (const helios::engine::runtime::pooling::types::GameObjectPoolId id, std::unique_ptr< GameObjectPool > gameObjectPool) noexcept

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

std::unordered_map< helios::engine::runtime::pooling::types::GameObjectPoolId, std::unique_ptr< GameObjectPool > > &pools ()

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

GameObjectPool *pool (const helios::engine::runtime::pooling::types::GameObjectPoolId id) const

Retrieves a pool by its ID. More...

boolhas (const helios::engine::runtime::pooling::types::GameObjectPoolId id) const noexcept

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

Private Member Attributes Index

std::unordered_map< helios::engine::runtime::pooling::types::GameObjectPoolId, std::unique_ptr< GameObjectPool > >pools_

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

Description

Central registry for managing multiple named GameObjectPools.

GameObjectPoolRegistry provides a single point of access to all object pools in the game. Each pool is identified by a strongly-typed GameObjectPoolId, 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: ```cpp GameObjectPoolRegistry registry;

constexpr GameObjectPoolId BULLET_POOL{1}; registry.addPool(BULLET_POOL, std::make_unique<GameObjectPool>(100));

// Later, acquire a bullet from the pool auto* pool = registry.pool(BULLET_POOL); helios::util::Guid bulletGuid; if (pool && pool->acquire(bulletGuid)) { // Use the bullet } ```

Definition at line 45 of file GameObjectPoolRegistry.ixx.

Public Constructors

GameObjectPoolRegistry()

helios::engine::runtime::pooling::GameObjectPoolRegistry::GameObjectPoolRegistry ()
default

Default constructor.

Definition at line 59 of file GameObjectPoolRegistry.ixx.

Public Member Functions

addPool()

GameObjectPool * helios::engine::runtime::pooling::GameObjectPoolRegistry::addPool (const helios::engine::runtime::pooling::types::GameObjectPoolId id, std::unique_ptr< GameObjectPool > gameObjectPool)
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.

gameObjectPool

The pool to add (ownership is transferred).

Returns

Raw pointer to the added pool for immediate use.

Definition at line 72 of file GameObjectPoolRegistry.ixx.

74 std::unique_ptr<GameObjectPool> gameObjectPool
75 ) noexcept {
76 pools_[id] = std::move(gameObjectPool);
77 return pools_[id].get();
78 }

has()

bool helios::engine::runtime::pooling::GameObjectPoolRegistry::has (const helios::engine::runtime::pooling::types::GameObjectPoolId id)
inline nodiscard 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 118 of file GameObjectPoolRegistry.ixx.

118 [[nodiscard]] bool has(const helios::engine::runtime::pooling::types::GameObjectPoolId id) const noexcept {
119 return pools_.contains(id);
120 }

pool()

GameObjectPool * helios::engine::runtime::pooling::GameObjectPoolRegistry::pool (const helios::engine::runtime::pooling::types::GameObjectPoolId id)
inline nodiscard

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 100 of file GameObjectPoolRegistry.ixx.

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

pools()

std::unordered_map< helios::engine::runtime::pooling::types::GameObjectPoolId, std::unique_ptr< GameObjectPool > > & helios::engine::runtime::pooling::GameObjectPoolRegistry::pools ()
inline nodiscard

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 88 of file GameObjectPoolRegistry.ixx.

88 [[nodiscard]]std::unordered_map<helios::engine::runtime::pooling::types::GameObjectPoolId, std::unique_ptr<GameObjectPool>>& pools() {
89 return pools_;
90 }

Private Member Attributes

pools_

std::unordered_map<helios::engine::runtime::pooling::types::GameObjectPoolId, std::unique_ptr<GameObjectPool> > helios::engine::runtime::pooling::GameObjectPoolRegistry::pools_

Maps pool IDs to their corresponding GameObjectPool instances.

Definition at line 52 of file GameObjectPoolRegistry.ixx.

52 std::unordered_map<helios::engine::runtime::pooling::types::GameObjectPoolId, std::unique_ptr<GameObjectPool>> pools_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.