Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
zone.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <array>
7#include <cstddef>
8#include <cstdint>
9#include <span>
10#include <string_view>
11
12namespace helios::profile {
13
14/// @brief RAII scope zone that delegates to the active profiling backends.
16public:
17 static constexpr size_t kStorage = kZoneStorageBytes;
18
19 /**
20 * @brief Creates a new profiling zone with the given specification.
21 * @param spec Zone specification
22 */
23 explicit ScopedZone(const ZoneSpec& spec) noexcept;
24
25 /**
26 * @brief Creates a profiling zone with a runtime activation flag.
27 * @param spec Zone specification
28 * @param active Whether the zone is active
29 */
30 ScopedZone(const ZoneSpec& spec, bool active) noexcept;
31 ScopedZone(const ScopedZone&) = delete;
33 ~ScopedZone() noexcept;
34
35 ScopedZone& operator=(const ScopedZone&) = delete;
36 ScopedZone& operator=(ScopedZone&&) = delete;
37
38 /**
39 * @brief Updates the zone's text.
40 * @param text The new text to associate with the zone
41 */
42 void SetText(std::string_view text) noexcept;
43
44 /**
45 * @brief Updates the zone's value.
46 * @param value The new value to associate with the zone
47 */
48 void SetValue(uint64_t value) noexcept;
49
50 /**
51 * @brief Updates the zone's name.
52 * @param name The new name to associate with the zone
53 */
54 void SetName(std::string_view name) noexcept;
55
56 /**
57 * @brief Retrieves the current zone storage span.
58 * @return Storage span for the active zone, or empty if none
59 */
60 [[nodiscard]] static auto CurrentZoneStorage() noexcept
61 -> std::span<std::byte>;
62
63private:
64 alignas(std::max_align_t) std::array<std::byte, kStorage> storage_;
65 std::span<std::byte> previous_storage_;
66 bool previous_annotations_suppressed_ = false;
67 bool active_ = true;
68};
69
70} // namespace helios::profile
ScopedZone(ScopedZone &&)=delete
ScopedZone(const ScopedZone &)=delete
static auto CurrentZoneStorage() noexcept -> std::span< std::byte >
Retrieves the current zone storage span.
Definition zone.cpp:73
void SetText(std::string_view text) noexcept
Updates the zone's text.
Definition zone.cpp:52
ScopedZone(const ZoneSpec &spec) noexcept
Creates a new profiling zone with the given specification.
Definition zone.cpp:21
static constexpr size_t kStorage
Definition zone.hpp:17
void SetName(std::string_view name) noexcept
Updates the zone's name.
Definition zone.cpp:66
void SetValue(uint64_t value) noexcept
Updates the zone's value.
Definition zone.cpp:59
constexpr size_t kZoneStorageBytes
Definition config.hpp:12
STL namespace.
Immutable zone description for a single instrumentation site.
Definition common.hpp:22