GameObjectPoolRegistry Class
Central registry for managing multiple named GameObjectPools. More...
Declaration
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... | |
| bool | has (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()
| default |
Default constructor.
Definition at line 58 of file GameObjectPoolRegistry.ixx.
Public Member Functions
addPool()
| 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.
has()
| 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.
pool()
| 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.
Private Member Attributes
pools_
|
Maps pool IDs to their corresponding GameObjectPool instances.
Definition at line 51 of file GameObjectPoolRegistry.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.