ConceptModelRegistry Class Template
Generic type-indexed registry for type-erased wrapper instances. More...
Declaration
Public Member Functions Index
template <typename AnyT, typename IdProvider> | |
| auto | items () const noexcept -> std::span< AnyT *const > |
|
Returns a read-only span of registered items in insertion order. More... | |
template <typename AnyT, typename IdProvider> | |
| auto | items () noexcept -> std::span< AnyT * > |
|
Returns a mutable span of registered items in insertion order. More... | |
template <typename T, typename... Args> | |
| T & | add (Args &&... args) |
|
Registers and wraps a concrete instance of type T. More... | |
template <typename T> | |
| bool | has () const |
|
Checks whether a concrete type T is registered. More... | |
template <typename T> | |
| T * | item () const |
|
Returns a pointer to the registered instance of type T. More... | |
Private Member Functions Index
template <typename AnyT, typename IdProvider> | |
| void | update () const |
|
Rebuilds the insertion-ordered view if dirty. More... | |
Private Member Attributes Index
template <typename AnyT, typename IdProvider> | |
| std::vector< AnyT > | items_ |
|
Owning storage for wrapped AnyT instances, indexed by type ID. More... | |
template <typename AnyT, typename IdProvider> | |
| std::vector< void * > | underlyingAnyT_ |
|
Cached raw pointers to the underlying concrete instances. More... | |
template <typename AnyT, typename IdProvider> | |
| std::vector< size_t > | insertionOrder_ |
|
Records insertion order for deterministic iteration. More... | |
template <typename AnyT, typename IdProvider> | |
| std::vector< AnyT * > | itemView_ |
|
Lazily-built view of AnyT pointers in insertion order. More... | |
template <typename AnyT, typename IdProvider> | |
| bool | needsUpdate_ = false |
|
Dirty flag indicating itemView_ needs rebuilding. More... | |
Description
Generic type-indexed registry for type-erased wrapper instances.
ConceptModelRegistry stores instances of a type-erased wrapper `AnyT` (e.g. System, Manager) and indexes them by a compile-time `IdProvider` (e.g. SystemTypeId, ResourceTypeId). This provides:
- **O(1) lookup** by concrete type via `item<T>()`
- **Insertion-order iteration** via `items()` for deterministic processing
- **Type-safe registration** via `add<T>(args...)` returning a reference to the underlying concrete instance
The registry is used as the backend for `SystemRegistry` and `ManagerRegistry`.
## Instantiations
| Alias | AnyT | IdProvider | |-------|------|------------| | `SystemRegistry` | `System` | `SystemTypeId` | | `ManagerRegistry` | `Manager` | `ResourceTypeId` |
- Template Parameters
-
AnyT The type-erased wrapper type (must support `underlying()`).
IdProvider Compile-time ID generator (must provide `id<T>().value()`).
- See Also
SystemRegistry
- See Also
ManagerRegistry
- Todo
-
this impl needs to make sure that memory allocations / moves do not invalidate the fastAccess in ResourceRegistry
Definition at line 53 of file ConceptModelRegistry.ixx.
Public Member Functions
add()
| inline |
Registers and wraps a concrete instance of type T.
Constructs T in-place from the forwarded arguments, wraps it in an AnyT, and stores it at the index determined by `IdProvider::id<T>()`. Returns a reference to the underlying concrete T instance.
- Template Parameters
-
T The concrete type to register.
Args Constructor argument types for T.
- Parameters
-
args Arguments forwarded to the T constructor.
- Returns
Reference to the registered T instance.
- Precondition
T must not already be registered.
Definition at line 141 of file ConceptModelRegistry.ixx.
has()
| inline nodiscard |
Checks whether a concrete type T is registered.
- Template Parameters
-
T The type to check.
- Returns
True if T has been added.
Definition at line 176 of file ConceptModelRegistry.ixx.
item()
| inline nodiscard |
Returns a pointer to the registered instance of type T.
- Template Parameters
-
T The concrete type to look up.
- Returns
Pointer to T, or nullptr if not registered.
Definition at line 188 of file ConceptModelRegistry.ixx.
Referenced by helios::core::container::ConceptModelRegistry< CommandBuffer, CommandBufferTypeId >::has.
items()
| inline nodiscard noexcept |
Returns a read-only span of registered items in insertion order.
- Returns
Span of const AnyT pointers.
Definition at line 108 of file ConceptModelRegistry.ixx.
items()
| inline nodiscard noexcept |
Returns a mutable span of registered items in insertion order.
- Returns
Span of AnyT pointers.
Definition at line 118 of file ConceptModelRegistry.ixx.
Private Member Functions
update()
| inline |
Rebuilds the insertion-ordered view if dirty.
Definition at line 83 of file ConceptModelRegistry.ixx.
Private Member Attributes
insertionOrder_
|
Records insertion order for deterministic iteration.
Definition at line 68 of file ConceptModelRegistry.ixx.
items_
| mutable |
Owning storage for wrapped AnyT instances, indexed by type ID.
Definition at line 58 of file ConceptModelRegistry.ixx.
itemView_
| mutable |
Lazily-built view of AnyT pointers in insertion order.
Definition at line 73 of file ConceptModelRegistry.ixx.
needsUpdate_
| mutable |
Dirty flag indicating itemView_ needs rebuilding.
Definition at line 78 of file ConceptModelRegistry.ixx.
underlyingAnyT_
|
Cached raw pointers to the underlying concrete instances.
Definition at line 63 of file ConceptModelRegistry.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.