Skip to main content

EntityHandle Struct Template

A versioned handle for referencing entities in a registry. More...

Declaration

template <typename TStrongId> struct helios::ecs::types::EntityHandle<TStrongId> { ... }

Public Member Typedefs Index

template <typename TStrongId>
usingStrongId_type = TStrongId

Public Operators Index

template <typename TStrongId>
booloperator== (const EntityHandle &) const =default

Compares two handles for equality. More...

template <typename TStrongId>
constexpr booloperator< (const EntityHandle &entityHandle) const noexcept

Compares two handles by entity ID (less-than). More...

template <typename TStrongId>
constexpr booloperator> (const EntityHandle &entityHandle) const noexcept

Compares two handles by entity ID (greater-than). More...

Public Member Functions Index

template <typename TStrongId>
boolisValid () const noexcept

Checks if this handle is potentially valid. More...

Public Member Attributes Index

template <typename TStrongId>
EntityIdentityId {0}

The unique identifier for the entity within the registry. More...

template <typename TStrongId>
VersionIdversionId = InvalidVersion

The version number for stale handle detection. More...

template <typename TStrongId>
TStrongIdstrongId {}

The domain-specific strong ID associated with this handle. More...

Description

A versioned handle for referencing entities in a registry.

`EntityHandle` combines an entity ID with a version number and a domain-specific strong ID to provide safe, typed references to registered entities. The version ensures that handles to removed entities are detected as stale.

Template Parameters
TStrongId

A strong ID type carrying domain semantics.

See Also

EntityRegistry

Definition at line 47 of file EntityHandle.ixx.

Public Member Typedefs

StrongId_type

template <typename TStrongId>
using helios::ecs::types::EntityHandle< TStrongId >::StrongId_type = TStrongId

Definition at line 49 of file EntityHandle.ixx.

49 using StrongId_type = TStrongId;

Public Operators

operator<()

template <typename TStrongId>
bool helios::ecs::types::EntityHandle< TStrongId >::operator< (const EntityHandle & entityHandle)
inline constexpr noexcept

Compares two handles by entity ID (less-than).

Parameters
entityHandle

The handle to compare against.

Returns

True if this handle's entity ID is less than the other.

Definition at line 80 of file EntityHandle.ixx.

80 constexpr bool operator<(const EntityHandle& entityHandle) const noexcept {
81 return entityId < entityHandle.entityId;
82 }

Reference helios::ecs::types::EntityHandle< TStrongId >::entityId.

operator==()

template <typename TStrongId>
bool helios::ecs::types::EntityHandle< TStrongId >::operator== (const EntityHandle &)
default

Compares two handles for equality.

Definition at line 71 of file EntityHandle.ixx.

operator>()

template <typename TStrongId>
bool helios::ecs::types::EntityHandle< TStrongId >::operator> (const EntityHandle & entityHandle)
inline constexpr noexcept

Compares two handles by entity ID (greater-than).

Parameters
entityHandle

The handle to compare against.

Returns

True if this handle's entity ID is greater than the other.

Definition at line 91 of file EntityHandle.ixx.

91 constexpr bool operator>(const EntityHandle& entityHandle) const noexcept {
92 return entityId > entityHandle.entityId;
93 }

Reference helios::ecs::types::EntityHandle< TStrongId >::entityId.

Public Member Functions

isValid()

template <typename TStrongId>
bool helios::ecs::types::EntityHandle< TStrongId >::isValid ()
inline nodiscard noexcept

Checks if this handle is potentially valid.

Returns

True if the version is at least 1 (initial version).

Definition at line 101 of file EntityHandle.ixx.

101 [[nodiscard]] bool isValid() const noexcept {
102 return versionId >= 1;
103 }

Reference helios::ecs::types::EntityHandle< TStrongId >::versionId.

Public Member Attributes

entityId

template <typename TStrongId>
EntityId helios::ecs::types::EntityHandle< TStrongId >::entityId {0}

strongId

template <typename TStrongId>
TStrongId helios::ecs::types::EntityHandle< TStrongId >::strongId {}

The domain-specific strong ID associated with this handle.

Definition at line 66 of file EntityHandle.ixx.

66 TStrongId strongId{};

Referenced by helios::ecs::EntityRegistry< TStrongId, TLookupStrategy, TAllowRemoval, TCapacity >::destroy.

versionId

template <typename TStrongId>
VersionId helios::ecs::types::EntityHandle< TStrongId >::versionId = InvalidVersion

The version number for stale handle detection.

Incremented when an entity is removed from the registry.

Definition at line 61 of file EntityHandle.ixx.

Referenced by helios::ecs::types::EntityHandle< TStrongId >::isValid.


The documentation for this struct was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.