Skip to main content

EntityResolver Struct Template

Callable that resolves an EntityHandle to an Entity facade. More...

Declaration

template <typename TEntityManager> struct helios::ecs::EntityResolver<TEntityManager> { ... }

Public Member Typedefs Index

template <typename TEntityManager>
usingHandle_type = TEntityManager::Handle_type
template <typename TEntityManager>
usingEntity_type = Entity< TEntityManager >

Public Operators Index

template <typename TEntityManager>
auto operator() (const Handle_type handle) const noexcept -> std::optional< Entity_type >

Resolves an EntityHandle to an Entity. More...

Public Member Functions Index

template <typename TEntityManager>
auto find (const Handle_type handle) const noexcept -> std::optional< Entity_type >

Resolves an EntityHandle to an Entity. More...

Public Member Attributes Index

template <typename TEntityManager>
TEntityManager *constem

Non-owning pointer to the EntityManager used for validation. More...

Description

Callable that resolves an EntityHandle to an Entity facade.

EntityResolver wraps an EntityManager pointer and provides a validation-and-wrap operation: given an EntityHandle, it checks validity via the EntityManager's versioned registry and returns a lightweight Entity wrapper if the handle is still alive.

Supports both function-call syntax and a named `find()` method.

Template Parameters
TEntityManager

The concrete `EntityManager` specialisation used for handle validation and Entity construction.

See Also

EntityHandle

See Also

EntityManager

See Also

Entity

Definition at line 37 of file EntityResolver.ixx.

Public Member Typedefs

Entity_type

template <typename TEntityManager>
using helios::ecs::EntityResolver< TEntityManager >::Entity_type = Entity<TEntityManager>

Definition at line 40 of file EntityResolver.ixx.

Handle_type

template <typename TEntityManager>
using helios::ecs::EntityResolver< TEntityManager >::Handle_type = TEntityManager::Handle_type

Definition at line 39 of file EntityResolver.ixx.

39 using Handle_type = TEntityManager::Handle_type;

Public Operators

operator()()

template <typename TEntityManager>
std::optional< Entity_type > helios::ecs::EntityResolver< TEntityManager >::operator() (const Handle_type handle)
inline nodiscard noexcept

Resolves an EntityHandle to an Entity.

Parameters
handle

The entity handle to resolve.

Returns

An Entity if the handle is valid, std::nullopt otherwise.

Definition at line 54 of file EntityResolver.ixx.

54 [[nodiscard]] std::optional<Entity_type> operator()(const Handle_type handle) const noexcept {
55 if (!em->isValid(handle)) {
56 return std::nullopt;
57 }
58 return Entity_type(handle, em);
59 }

Reference helios::ecs::EntityResolver< TEntityManager >::em.

Public Member Functions

find()

template <typename TEntityManager>
std::optional< Entity_type > helios::ecs::EntityResolver< TEntityManager >::find (const Handle_type handle)
inline nodiscard noexcept

Resolves an EntityHandle to an Entity.

Delegates to `operator()`.

Parameters
handle

The entity handle to resolve.

Returns

An Entity if the handle is valid, std::nullopt otherwise.

Definition at line 70 of file EntityResolver.ixx.

70 [[nodiscard]] std::optional<Entity_type> find(const Handle_type handle) const noexcept {
71 return (*this)(handle);
72 }

Public Member Attributes

em

template <typename TEntityManager>
TEntityManager* const helios::ecs::EntityResolver< TEntityManager >::em

Non-owning pointer to the EntityManager used for validation.

Definition at line 45 of file EntityResolver.ixx.

45 TEntityManager* const em;

Referenced by helios::ecs::EntityResolver< TEntityManager >::operator().


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.