Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
stage.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <concepts>
6#include <string_view>
7#include <type_traits>
8
9namespace helios::ecs {
10
11/// @brief Type index for stages.
13
14/// @brief Type id for stages.
16
17/**
18 * @brief Concept for stages.
19 * @details A stage must be an object and be empty.
20 */
21template <typename T>
22concept StageTrait = std::is_object_v<std::remove_cvref_t<T>> &&
23 std::is_empty_v<std::remove_cvref_t<T>>;
24
25/**
26 * @brief Concept for stages that provide a name.
27 * @details A stage with name trait must satisfy `StageTrait` and provide:
28 * - `static constexpr std::string_view kName` variable
29 */
30template <typename T>
31concept StageWithNameTrait = StageTrait<T> && requires {
32 { std::remove_cvref_t<T>::kName } -> std::convertible_to<std::string_view>;
33};
34
35/**
36 * @brief Stage name for debugging and serialization.
37 * @tparam T Stage type
38 * @param instance Stage instance
39 * @return Stage name
40 */
41template <StageTrait T>
42[[nodiscard]] constexpr std::string_view StageNameOf(
43 const T& /*instance*/ = {}) noexcept {
44 if constexpr (StageWithNameTrait<T>) {
45 return std::remove_cvref_t<T>::kName;
46 } else {
48 }
49}
50
51} // namespace helios::ecs
Concept for stages.
Definition stage.hpp:22
Concept for stages that provide a name.
Definition stage.hpp:31
constexpr std::string_view StageNameOf(const T &={}) noexcept
Stage name for debugging and serialization.
Definition stage.hpp:42
utils::TypeId StageTypeId
Type id for stages.
Definition stage.hpp:15
utils::TypeIndex StageTypeIndex
Type index for stages.
Definition stage.hpp:12
constexpr std::string_view QualifiedTypeNameOf() noexcept
Retrieves the fully qualified type name of T.