Skip to main content

EntityResolver Struct

Callable that resolves an EntityHandle to a GameObject. More...

Declaration

struct helios::engine::ecs::EntityResolver { ... }

Public Operators Index

std::optional< GameObject >operator() (const EntityHandle handle) const noexcept

Resolves an EntityHandle to a GameObject. More...

Public Member Functions Index

std::optional< GameObject >find (const EntityHandle handle) const noexcept

Resolves an EntityHandle to a GameObject. More...

Public Member Attributes Index

helios::engine::ecs::EntityManager *constem

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

Description

Callable that resolves an EntityHandle to a GameObject.

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 GameObject wrapper if the handle is still alive.

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

See Also

EntityHandle

See Also

EntityManager

See Also

GameObject

Definition at line 31 of file EntityResolver.ixx.

Public Operators

operator()()

std::optional< GameObject > helios::engine::ecs::EntityResolver::operator() (const EntityHandle handle)
inline nodiscard noexcept

Resolves an EntityHandle to a GameObject.

Parameters
handle

The entity handle to resolve.

Returns

A GameObject if the handle is valid, std::nullopt otherwise.

Definition at line 45 of file EntityResolver.ixx.

45 [[nodiscard]] std::optional<GameObject> operator()(const EntityHandle handle) const noexcept {
46 if (!em->isValid(handle)) {
47 return std::nullopt;
48 }
49 return GameObject(handle, em);
50 }

Reference em.

Public Member Functions

find()

std::optional< GameObject > helios::engine::ecs::EntityResolver::find (const EntityHandle handle)
inline nodiscard noexcept

Resolves an EntityHandle to a GameObject.

Delegates to `operator()`.

Parameters
handle

The entity handle to resolve.

Returns

A GameObject if the handle is valid, std::nullopt otherwise.

Definition at line 61 of file EntityResolver.ixx.

61 [[nodiscard]] std::optional<GameObject> find(const EntityHandle handle) const noexcept {
62 return (*this)(handle);
63 }

Public Member Attributes

em

helios::engine::ecs::EntityManager* const helios::engine::ecs::EntityResolver::em

Non-owning pointer to the EntityManager used for validation.

Definition at line 36 of file EntityResolver.ixx.

Referenced by operator().


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.