vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
resource_handle.h
1#pragma once
2
3#include "core/memory/types.h"
4
5namespace Vkm::Engine {
6
15template <typename ResourceType>
16struct Handle {
17 using resource_t = ResourceType;
18 StorageIndex key = {};
19
21 constexpr explicit operator bool() const noexcept { return bool(key); }
22
23 constexpr bool operator==(const Handle& other) const noexcept { return key == other.key; }
24
25 constexpr bool operator!=(const Handle& other) const noexcept { return key != other.key; }
26
30 constexpr uint32_t id() const noexcept { return key.index; }
31};
32
33} // namespace Vkm::Engine
Opaque, type-safe handle for resources, distinguished by ResourceType.
Definition resource_handle.h:16
constexpr uint32_t id() const noexcept
Get the sparse slot index for use as map key, sorting, or logging.
Definition resource_handle.h:30
Opaque handle pairing a sparse-array index with a generation counter.
Definition types.h:14