Skip to main content

EntityHandle Struct Template

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

Declaration

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

Public Member Typedefs Index

template <typename TDomainTag>
usingDomainTag_type = TDomainTag
template <typename TDomainTag>
usingStrongId_type = StrongId< TDomainTag >

Public Operators Index

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

Compares two handles for equality. More...

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

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

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

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

Public Member Functions Index

template <typename TDomainTag>
boolisValid () const noexcept

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

Public Member Attributes Index

template <typename TDomainTag>
EntityIdentityId {0}

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

template <typename TDomainTag>
VersionIdversionId = InvalidVersion

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

template <typename TDomainTag>
StrongId< TDomainTag >strongId {}

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
TDomainTag

Domain tag used to derive StrongId<TDomainTag>.

See Also

EntityRegistry

Definition at line 47 of file EntityHandle.ixx.

Public Member Typedefs

DomainTag_type

template <typename TDomainTag>
using helios::ecs::types::EntityHandle< TDomainTag >::DomainTag_type = TDomainTag

Definition at line 66 of file EntityHandle.ixx.

66 using DomainTag_type = TDomainTag;

StrongId_type

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

Definition at line 68 of file EntityHandle.ixx.

Public Operators

operator<()

template <typename TDomainTag>
constexpr bool helios::ecs::types::EntityHandle< TDomainTag >::operator< (const EntityHandle< TDomainTag > & 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 82 of file EntityHandle.ixx.

82 constexpr bool operator<(const EntityHandle<TDomainTag>& entityHandle) const noexcept {
83 return entityId < entityHandle.entityId;
84 }

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

operator==()

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

Compares two handles for equality.

Definition at line 73 of file EntityHandle.ixx.

operator>()

template <typename TDomainTag>
constexpr bool helios::ecs::types::EntityHandle< TDomainTag >::operator> (const EntityHandle< TDomainTag > & 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 93 of file EntityHandle.ixx.

93 constexpr bool operator>(const EntityHandle<TDomainTag>& entityHandle) const noexcept {
94 return entityId > entityHandle.entityId;
95 }

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

Public Member Functions

isValid()

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

Checks if this handle is potentially valid.

Returns

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

Definition at line 103 of file EntityHandle.ixx.

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

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

Public Member Attributes

entityId

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

strongId

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

The domain-specific strong ID associated with this handle.

Definition at line 64 of file EntityHandle.ixx.

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

versionId

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

The version number for stale handle detection.

Incremented when an entity is removed from the registry.

Definition at line 59 of file EntityHandle.ixx.

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


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.