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::core::data::GameObjectPoolId id, std::unique_ptr< GameObjectPool > gameObjectPool) noexcept

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

GameObjectPool *pool (const helios::engine::core::data::GameObjectPoolId id) const

Retrieves a pool by its ID. More...

boolhas (const helios::engine::core::data::GameObjectPoolId id) const noexcept

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

Private Member Attributes Index

std::unordered_map< helios::engine::core::data::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 44 of file GameObjectPoolRegistry.ixx.

Public Constructors

GameObjectPoolRegistry()

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

Default constructor.

Definition at line 58 of file GameObjectPoolRegistry.ixx.

Public Member Functions

addPool()

GameObjectPool * helios::engine::runtime::pooling::GameObjectPoolRegistry::addPool (const helios::engine::core::data::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 71 of file GameObjectPoolRegistry.ixx.

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

has()

bool helios::engine::runtime::pooling::GameObjectPoolRegistry::has (const helios::engine::core::data::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 104 of file GameObjectPoolRegistry.ixx.

104 [[nodiscard]] bool has(const helios::engine::core::data::GameObjectPoolId id) const noexcept {
105 return pools_.find(id) != pools_.end();
106 }

pool()

GameObjectPool * helios::engine::runtime::pooling::GameObjectPoolRegistry::pool (const helios::engine::core::data::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 86 of file GameObjectPoolRegistry.ixx.

87
88 const auto& it = pools_.find(id);
89
90 if (it == pools_.end()) {
91 return nullptr;
92 }
93
94 return it->second.get();
95 }

Private Member Attributes

pools_

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

Maps pool IDs to their corresponding GameObjectPool instances.

Definition at line 51 of file GameObjectPoolRegistry.ixx.

51 std::unordered_map<helios::engine::core::data::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.