DenseRuntimeHandleRegistry Class Template
Maps strong identifiers to dense, contiguous runtime indices. More...
Declaration
Public Constructors Index
template <typename StrongIdentifier, typename RuntimeId> | |
| DenseRuntimeHandleRegistry (const size_t defaultCapacity=DEFAULT_RUNTIME_HANDLE_REGISTRY_CAPACITY) | |
|
Constructs the registry with a reserved capacity. More... | |
Public Member Functions Index
template <typename StrongIdentifier, typename RuntimeId> | |
| bool | has (StrongIdentifier strongId) const noexcept |
|
Checks whether a strong identifier is registered. More... | |
template <typename StrongIdentifier, typename RuntimeId> | |
| auto | runtimeId (StrongIdentifier strongId) const noexcept -> std::optional< RuntimeId > |
|
Returns the runtime index for a registered identifier. More... | |
template <typename StrongIdentifier, typename RuntimeId> | |
| auto | getOrCreate (std::string strId) -> RuntimeHandle< StrongIdentifier, RuntimeId > |
|
Returns an existing handle or creates a new one from a string key. More... | |
template <typename StrongIdentifier, typename RuntimeId> | |
| auto | getOrCreate (const StrongIdentifier strongId) -> RuntimeHandle< StrongIdentifier, RuntimeId > |
|
Returns an existing handle or registers a new entry. More... | |
Private Member Attributes Index
template <typename StrongIdentifier, typename RuntimeId> | |
| std::vector< StrongId_t > | ids_ |
|
Dense storage of registered strong-ID values. More... | |
Description
Maps strong identifiers to dense, contiguous runtime indices.
`DenseRuntimeHandleRegistry` maintains a compact vector of `StrongId` values. The position of each entry in the vector serves as its `RuntimeId`, enabling O(1) access in downstream pools that are indexed by the same `RuntimeId`.
Registration is idempotent: calling `getOrCreate()` with an already registered identifier returns the existing handle without duplication.
## Complexity
- `has()` / `runtimeId()` — O(n) linear scan.
- `getOrCreate()` — O(n) lookup + amortised O(1) append on miss.
## Usage
```cpp using MeshHandleRegistry = DenseRuntimeHandleRegistry<MeshId, MeshRuntimeId>;
MeshHandleRegistry registry; auto handle = registry.getOrCreate("player_mesh"); auto runtimeId = handle.runtimeId; // dense index into MeshPool bool exists = registry.has(MeshId{"player_mesh"}); ```
- Template Parameters
-
StrongIdentifier A `StrongId<Tag>` type used as the stable key.
RuntimeId An unsigned integer type (typically `uint32_t`) used as the dense index.
- See Also
- See Also
Definition at line 60 of file DenseRuntimeHandleRegistry.ixx.
Public Constructors
DenseRuntimeHandleRegistry()
| inline explicit |
Constructs the registry with a reserved capacity.
- Parameters
-
defaultCapacity Initial capacity hint for the internal vector.
Definition at line 76 of file DenseRuntimeHandleRegistry.ixx.
Public Member Functions
getOrCreate()
| inline |
Returns an existing handle or creates a new one from a string key.
Constructs a `StrongIdentifier` from `strId` and delegates to the `StrongIdentifier` overload.
- Parameters
-
strId String key that is hashed into a `StrongIdentifier`.
- Returns
The existing or newly created handle.
Definition at line 120 of file DenseRuntimeHandleRegistry.ixx.
Reference helios::core::container::DenseRuntimeHandleRegistry< StrongIdentifier, RuntimeId >::getOrCreate.
Referenced by helios::core::container::DenseRuntimeHandleRegistry< StrongIdentifier, RuntimeId >::getOrCreate.
getOrCreate()
| inline |
Returns an existing handle or registers a new entry.
If the identifier is already registered, the existing handle is returned. Otherwise a new entry is appended and a fresh `RuntimeId` is assigned.
- Parameters
-
strongId The identifier to register.
- Returns
The existing or newly created handle.
- Precondition
The registry must not have reached its reserved capacity.
Definition at line 137 of file DenseRuntimeHandleRegistry.ixx.
Reference helios::core::container::DenseRuntimeHandleRegistry< StrongIdentifier, RuntimeId >::runtimeId.
has()
| inline nodiscard noexcept |
Checks whether a strong identifier is registered.
- Parameters
-
strongId The identifier to look up.
- Returns
True if the identifier is present.
Definition at line 87 of file DenseRuntimeHandleRegistry.ixx.
runtimeId()
| inline nodiscard noexcept |
Returns the runtime index for a registered identifier.
- Parameters
-
strongId The identifier to look up.
- Returns
The associated `RuntimeId`, or `std::nullopt` if not registered.
Definition at line 98 of file DenseRuntimeHandleRegistry.ixx.
Referenced by helios::core::container::DenseRuntimeHandleRegistry< StrongIdentifier, RuntimeId >::getOrCreate.
Private Member Attributes
ids_
|
Dense storage of registered strong-ID values.
The index of each entry is its corresponding `RuntimeId`.
Definition at line 67 of file DenseRuntimeHandleRegistry.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.