Unravel Engine C++ Reference
Loading...
Searching...
No Matches
handle_impl.h
Go to the documentation of this file.
1#pragma once
2
3#include "graphics.h"
4#include <memory>
5
6namespace gfx
7{
8
9template<typename Base, typename T>
11{
12public:
13 using ptr = std::shared_ptr<Base>;
14 using uptr = std::unique_ptr<Base>;
15 using weak_ptr = std::weak_ptr<Base>;
16
17 using handle_type_t = T;
18 using base_type = Base;
19
21 {
22 dispose();
23 }
24
25 void dispose()
26 {
27 if(is_valid())
28 {
30 }
31
33 }
34
35 [[nodiscard]] auto is_valid() const -> bool
36 {
37 return bgfx::isValid(handle_);
38 }
39
40 auto native_handle() const -> T
41 {
42 return handle_;
43 }
44
45 static auto invalid_handle() -> T
46 {
47 T invalid = {bgfx::kInvalidHandle};
48 return invalid;
49 }
50
51protected:
53};
54} // namespace gfx
std::unique_ptr< Base > uptr
Definition handle_impl.h:14
auto is_valid() const -> bool
Definition handle_impl.h:35
static auto invalid_handle() -> T
Definition handle_impl.h:45
std::shared_ptr< Base > ptr
Definition handle_impl.h:13
auto native_handle() const -> T
Definition handle_impl.h:40
std::weak_ptr< Base > weak_ptr
Definition handle_impl.h:15
void destroy(index_buffer_handle _handle)
Definition graphics.cpp:341