Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Adapter.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "utils/webgpu.hpp"
4
6class Adapter {
7 public:
8 explicit Adapter(wgpu::Adapter wgpuAdapter_) : wgpuAdapter(wgpuAdapter_) {}
10 {
11 if (wgpuAdapter)
12 {
13 wgpuAdapter.release();
14 wgpuAdapter = nullptr;
15 }
16 }
17
18 Adapter(Adapter &other) = delete;
19 Adapter &operator=(Adapter &other) = delete;
20
21 // @note While using && ctor, you're destroying the previous adapter and will be invalid
22 Adapter(Adapter &&other) noexcept : wgpuAdapter(other.wgpuAdapter) { other.wgpuAdapter = nullptr; }
23
24 // @note While using && assignement, you're destroying the previous adapter and will be invalid
25 Adapter &operator=(Adapter &&other) noexcept
26 {
27 if (this != &other)
28 {
29 if (wgpuAdapter)
30 {
31 wgpuAdapter.release();
32 }
33 wgpuAdapter = std::move(other.wgpuAdapter);
34 other.wgpuAdapter = nullptr;
35 }
36 return *this;
37 }
38
39 wgpu::Adapter &operator*(void) { return wgpuAdapter; };
40 wgpu::Adapter *operator->(void) { return &wgpuAdapter; };
41
42 private:
43 // @note We will assume that adapter is not null all the time
44 wgpu::Adapter wgpuAdapter = nullptr;
45};
46} // namespace Graphic::Resource
wgpu::Adapter * operator->(void)
Definition Adapter.hpp:40
Adapter & operator=(Adapter &other)=delete
wgpu::Adapter wgpuAdapter
Definition Adapter.hpp:44
Adapter(wgpu::Adapter wgpuAdapter_)
Definition Adapter.hpp:8
Adapter(Adapter &&other) noexcept
Definition Adapter.hpp:22
~Adapter()
Definition Adapter.hpp:9
Adapter & operator=(Adapter &&other) noexcept
Definition Adapter.hpp:25
Adapter(Adapter &other)=delete
wgpu::Adapter & operator*(void)
Definition Adapter.hpp:39
Definition Adapter.hpp:5