Skip to main content

engine/ecs/EntityResolver.ixx File

Lightweight callable for resolving EntityHandles to GameObjects. More...

Included Headers

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespaceecs

Core Entity-Component-System architecture. More...

Classes Index

structEntityResolver

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

Description

Lightweight callable for resolving EntityHandles to GameObjects.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file EntityResolver.ixx
3 * @brief Lightweight callable for resolving EntityHandles to GameObjects.
4 */
5module;
6
7#include <optional>
8
9export module helios.engine.ecs.EntityResolver;
10
11import helios.engine.ecs.EntityHandle;
12import helios.engine.ecs.EntityManager;
13import helios.engine.ecs.GameObject;
14
15export namespace helios::engine::ecs {
16
17 /**
18 * @brief Callable that resolves an EntityHandle to a GameObject.
19 *
20 * @details EntityResolver wraps an EntityManager pointer and provides
21 * a validation-and-wrap operation: given an EntityHandle, it checks
22 * validity via the EntityManager's versioned registry and returns a
23 * lightweight GameObject wrapper if the handle is still alive.
24 *
25 * Supports both function-call syntax and a named `find()` method.
26 *
27 * @see EntityHandle
28 * @see EntityManager
29 * @see GameObject
30 */
32
33 /**
34 * @brief Non-owning pointer to the EntityManager used for validation.
35 */
37
38 /**
39 * @brief Resolves an EntityHandle to a GameObject.
40 *
41 * @param handle The entity handle to resolve.
42 *
43 * @return A GameObject if the handle is valid, std::nullopt otherwise.
44 */
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 }
51
52 /**
53 * @brief Resolves an EntityHandle to a GameObject.
54 *
55 * @details Delegates to `operator()`.
56 *
57 * @param handle The entity handle to resolve.
58 *
59 * @return A GameObject if the handle is valid, std::nullopt otherwise.
60 */
61 [[nodiscard]] std::optional<GameObject> find(const EntityHandle handle) const noexcept {
62 return (*this)(handle);
63 }
64 };
65}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.