CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Common.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
11
13
14namespace CeresEngine {
15
16 class GPUObject {
19
20 public:
21 GPUObject() = default;
22 virtual ~GPUObject() = default;
23
24 GPUObject(const GPUObject&) = delete;
25 GPUObject& operator=(const GPUObject&) = delete;
26
27 GPUObject(GPUObject&&) = delete;
29
30 public:
33
38 destroy();
39 return true;
40 }
41 return false;
42 }
43
44 protected:
48 virtual void destroy() noexcept;
49 };
50
53 public:
56
57 public:
58 explicit GPUDeviceObject(GPUDevice& device);
59 ~GPUDeviceObject() override;
60 };
61
62 template<typename TDescriptor, typename TParent = GPUDeviceObject> class TDeviceObject : public TParent {
63 public:
65 using Descriptor = TDescriptor;
66
67 public:
70
71 public:
73 explicit TDeviceObject(GPUDevice& device, const Descriptor& descriptor) : TParent(device), descriptor(descriptor) {}
74 ~TDeviceObject() override = default;
75
76 TDeviceObject(const TDeviceObject&) = delete;
78
81 };
82
83} // namespace CeresEngine
84
85
86
Definition GPUDevice.hpp:357
A base interface for RenderAPI objects.
Definition Common.hpp:52
GPUDeviceObject(GPUDevice &device)
GPUDevice & device
The owning device this object was created from.
Definition Common.hpp:55
Definition Common.hpp:16
GPUObject(GPUObject &&)=delete
GPUObject(const GPUObject &)=delete
void retain() noexcept
Retains the object by increment it's reference count by one.
Definition Common.hpp:32
virtual void destroy() noexcept
A internal method called by the system when the object reference count reaches zero.
GPUObject & operator=(const GPUObject &)=delete
virtual ~GPUObject()=default
RefCounter< true > mRefCounter
The object's reference counter.
Definition Common.hpp:18
GPUObject & operator=(GPUObject &&)=delete
bool release() noexcept
Releases the object by decrementing it's reference count by one.
Definition Common.hpp:36
bool decrement() noexcept
Decrements the reference counter by one.
void increment() noexcept
Increments the reference counter by one.
A class that implements a simple interface for reference counting.
Definition SmartPtr.hpp:82
Definition Common.hpp:62
TDeviceObject(const TDeviceObject &)=delete
TDeviceObject(GPUDevice &device, const Descriptor &descriptor)
Initializes a new RenderAPI device object instance.
Definition Common.hpp:73
TDescriptor Descriptor
An type-alias to the descriptor struct type.
Definition Common.hpp:65
const Descriptor & descriptor
A structure that describes the object and it's properties.
Definition Common.hpp:69
TDeviceObject(TDeviceObject &&)=delete
TDeviceObject & operator=(const TDeviceObject &)=delete
TDeviceObject & operator=(TDeviceObject &&)=delete
~TDeviceObject() override=default
Definition Application.hpp:19
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25