Skip to content

EntropyEngine::Core::TypeSystem::TypedHandle

EntropyEngine::Core::TypeSystem::TypedHandle

Section titled “EntropyEngine::Core::TypeSystem::TypedHandle”

Type-safe handle template that derives from GenericHandle. More…

#include <GenericHandle.h>

Inherits from EntropyEngine::Core::TypeSystem::GenericHandle< void >

Name
structHash
Hash support for use in unordered containers.
Name
using TType
Name
TypedHandleinvalid()
Creates an invalid handle of this type.
uint64_tgetDebugId() const
Gets a debug identifier for this handle (for logging/debugging).
constexprTypedHandle()
Default constructor creates an invalid handle.
constexprTypedHandle(OwnerType * owner, uint32_t index, uint32_t generation)
Constructs a typed handle with the specified owner, index and generation.
constexprTypedHandle(OwnerType * owner, uint64_t id)
Constructs a typed handle with the specified owner and raw ID.
constexprTypedHandle(const GenericHandle< OwnerType > & generic)
Constructs from a generic handle (explicit to prevent accidental conversion).

Public Classes inherited from EntropyEngine::Core::TypeSystem::GenericHandle< void >

Name
structHash
Hash support for use in unordered containers.

Public Functions inherited from EntropyEngine::Core::TypeSystem::GenericHandle< void >

Name
booloperator==(const GenericHandle & other) const
Equality comparison.
booloperator<(const GenericHandle & other) const
Less-than comparison for use in sorted containers.
booloperator!=(const GenericHandle & other) const
Inequality comparison.
boolisValid() const
Checks if this handle is potentially valid.
voidinvalidate()
Invalidates this handle.
uint64_tgetRawData() const
Gets the raw packed data.
OwnerType *getOwner() const
Gets the owner of this handle.
uint32_tgetIndex() const
Gets the index component of this handle.
uint64_tgetId() const
Gets the raw data as a 64-bit ID (for non-generation use cases).
uint32_tgetGeneration() const
Gets the generation component of this handle.
constexprGenericHandle()
Default constructor creates an invalid handle.
constexprGenericHandle(OwnerType * owner, uint32_t index, uint32_t generation)
Constructs a handle with the specified owner, index and generation.
constexprGenericHandle(OwnerType * owner, uint64_t id)
Constructs a handle with the specified owner and raw ID (for non-generation use).

Protected Functions inherited from EntropyEngine::Core::TypeSystem::GenericHandle< void >

Name
uint64_tpack(uint32_t index, uint32_t generation)
Packs index and generation into a single 64-bit value.

Protected Attributes inherited from EntropyEngine::Core::TypeSystem::GenericHandle< void >

Name
OwnerType *_owner
uint64_t_data
uint64_tINVALID_HANDLE
uint64_tINDEX_MASK
uint32_tGENERATION_SHIFT
uint64_tGENERATION_MASK
template <typename T ,
typename OwnerType =void>
class EntropyEngine::Core::TypeSystem::TypedHandle;

Type-safe handle template that derives from GenericHandle.

Template Parameters:

  • T The tag type this handle represents (usually an empty struct)
  • OwnerType The type of the owning container (optional)

This template provides type safety on top of GenericHandle, preventing accidental mixing of handles to different types of objects. The template parameter T is typically a tag struct that exists solely for type safety.

The handle is storage-agnostic - it only provides the index/generation validation mechanism. Storage classes implement their own validation logic using the handle’s getIndex() and getGeneration() methods.

Example usage:

struct EntityTag {};
struct ComponentTag {};
using EntityHandle = TypedHandle<EntityTag, EntityManager>;
using ComponentHandle = TypedHandle<ComponentTag, ComponentManager>;
EntityManager entityMgr;
EntityHandle entity(&entityMgr, 5, 1);
ComponentHandle component(&componentMgr, 5, 1);
// entity == component would be a compile error (different types)
// Usage with custom storage:
class EntityManager {
bool isHandleValid(const EntityHandle& handle) const {
return validateWithGeneration(handle.getIndex(), handle.getGeneration());
}
};
using EntropyEngine::Core::TypeSystem::TypedHandle< T, OwnerType >::Type = T;
static inline TypedHandle invalid()

Creates an invalid handle of this type.

inline uint64_t getDebugId() const

Gets a debug identifier for this handle (for logging/debugging).

Return: Unique identifier combining index and generation

inline constexpr TypedHandle()

Default constructor creates an invalid handle.

inline constexpr TypedHandle(
OwnerType * owner,
uint32_t index,
uint32_t generation
)

Constructs a typed handle with the specified owner, index and generation.

inline constexpr TypedHandle(
OwnerType * owner,
uint64_t id
)

Constructs a typed handle with the specified owner and raw ID.

inline explicit constexpr TypedHandle(
const GenericHandle< OwnerType > & generic
)

Constructs from a generic handle (explicit to prevent accidental conversion).


Updated on 2026-01-26 at 16:50:32 -0500