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> | |
| T & | add (AnyT &&wrapper) |
|
Registers a pre-built wrapper instance for concrete 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...) or add<T>(AnyT&&) returning a reference to the underlying concrete instance
The registry is used as the backend for SystemRegistry and ManagerRegistry.
Definition at line 51 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 139 of file ConceptModelRegistry.ixx.
Reference helios::registerComponents.
add()
| inline |
Registers a pre-built wrapper instance for concrete type T.
Stores an already-constructed AnyT at the slot determined by IdProvider::id<T>() and returns the underlying T reference.
This overload is useful when wrapper construction needs custom arguments that are not expressed as T{args...} (for example, pre-wrapped systems with injected dependencies).
- Template Parameters
-
T The concrete type represented by wrapper.
- Parameters
-
wrapper Pre-built type-erased wrapper owning a T instance.
- Returns
Reference to the registered T instance.
- Precondition
wrapper must contain a concrete T instance.
- Precondition
T should not already be registered.
Definition at line 185 of file ConceptModelRegistry.ixx.
Reference helios::registerComponents.
has()
| inline |
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 215 of file ConceptModelRegistry.ixx.
Reference helios::registerComponents.
Referenced by helios::engine::runtime::world::ResourceRegistry::has.
item()
| inline |
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 227 of file ConceptModelRegistry.ixx.
Reference helios::registerComponents.
Referenced by helios::engine::runtime::world::ResourceRegistry::get and helios::engine::runtime::world::ResourceRegistry::tryGet.
items()
| inline noexcept |
Returns a read-only span of registered items in insertion order.
- Returns
Span of const AnyT pointers.
Definition at line 106 of file ConceptModelRegistry.ixx.
Referenced by helios::engine::runtime::world::ResourceRegistry::commandBuffers, helios::engine::runtime::world::ResourceRegistry::commandBuffers, helios::engine::runtime::world::ResourceRegistry::managers and helios::engine::runtime::world::ResourceRegistry::managers.
items()
| inline noexcept |
Private Member Functions
update()
| inline |
Rebuilds the insertion-ordered view if dirty.
Definition at line 81 of file ConceptModelRegistry.ixx.
Private Member Attributes
insertionOrder_
|
Records insertion order for deterministic iteration.
Definition at line 66 of file ConceptModelRegistry.ixx.
items_
| mutable |
Owning storage for wrapped AnyT instances, indexed by type ID.
Definition at line 56 of file ConceptModelRegistry.ixx.
itemView_
| mutable |
Lazily-built view of AnyT pointers in insertion order.
Definition at line 71 of file ConceptModelRegistry.ixx.
needsUpdate_
| mutable |
Dirty flag indicating itemView_ needs rebuilding.
Definition at line 76 of file ConceptModelRegistry.ixx.
underlyingAnyT_
|
Cached raw pointers to the underlying concrete instances.
Definition at line 61 of file ConceptModelRegistry.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.