TypeIndexer Class Template
Utility class to generate unique type indices at runtime. More...
Declaration
Public Static Functions Index
template <typename T> | |
| static size_t | typeIndex () |
|
Generates and returns a unique type index for a specific type. More... | |
Private Static Attributes Index
template <typename Group> | |
| static std::atomic< size_t > | counter_ {0} |
|
A static atomic counter used for generating unique type indices. More... | |
Description
Utility class to generate unique type indices at runtime.
This class provides a mechanism to generate and retrieve unique indices for different types. It ensures that each type gets a distinct index which remains constant throughout the program's execution.
The indices are generated in a thread-safe manner using atomic operations.
- Template Parameters
-
Group A tag type used to create separate index spaces. Different Group types maintain independent counters, allowing the same type T to have different indices in different contexts.
Example usage: ```cpp class EventBus {
struct EventTypeGroup {};
using EventTypeIndexer = helios::core::TypeIndexer<EventTypeGroup>;
public:
template<typename T> EventBuffer<T>& getOrAddBuffer() { const size_t index = EventTypeIndexer::typeIndex<T>(); auto& buffer = lookupBufferAt(index); // ... } }; ```
Definition at line 47 of file TypeIndexer.ixx.
Public Static Functions
typeIndex()
| inline static |
Generates and returns a unique type index for a specific type.
This method assigns a unique index to each type within the scope of the associated TypeIndexer.
- Template Parameters
-
T The type for which to retrieve the unique index.
- Returns
A unique index representing the specific type T within this Group.
Definition at line 67 of file TypeIndexer.ixx.
Reference helios::core::data::TypeIndexer< Group >::typeIndex.
Referenced by helios::engine::ecs::types::ComponentTypeId::id, helios::engine::mechanics::scoring::types::ScoreTypeId::id, helios::engine::runtime::messaging::command::types::CommandBufferTypeId::id, helios::engine::runtime::messaging::command::types::CommandTypeId::id, helios::engine::runtime::world::types::ManagerTypeId::id, helios::engine::runtime::world::types::ResourceTypeId::id, helios::engine::runtime::world::types::SystemTypeId::id, helios::engine::state::types::StateTypeId::id and helios::core::data::TypeIndexer< Group >::typeIndex.
Private Static Attributes
counter_
| static |
A static atomic counter used for generating unique type indices.
Definition at line 52 of file TypeIndexer.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.