Cogs.Core
ResourceBase.cpp
1#include "ResourceBase.h"
2
4{
5 if (info && other.info) {
6 // Rename resource if no name was set previously.
7 if (getName().empty() && !other.getName().empty()) {
8 info->name = other.info->name;
9 }
10 }
11
12 if (!attachment && other.attachment) {
13 attachment = other.attachment;
14 }
15
16 other.attachment = nullptr;
17
18 other.flags = static_cast<uint32_t>(ResourceFlags::None);
19}
20
22{
23 //TODO: Setup propagation logic.
24 flags |= other.flags & static_cast<uint32_t>(ResourceFlags::Initialized | ResourceFlags::Active);
25
26 if (info && other.info) {
27 if (!info->name && other.info->name) {
28 info->name = other.info->name;
29 }
30 }
31
32 if (!attachment && other.attachment) {
33 attachment = other.attachment;
34 }
35
36 other.attachment = nullptr;
37
38 other.flags = static_cast<uint32_t>(ResourceFlags::None);
39
40 return *this;
41}
constexpr bool empty() const noexcept
Check if the string is empty.
Definition: StringView.h:122
@ Active
The resource is in use.
Base class for engine resources.
Definition: ResourceBase.h:107
struct RenderResource * attachment
Attached GPU resource.
Definition: ResourceBase.h:398
ResourceBase & operator=(const ResourceBase &other)=delete
Disable copy-assignment of resources.
StringView getName() const
Get the name of the resource.
Definition: ResourceBase.h:307
ResourceInfo * info
Additional resource info structure.
Definition: ResourceBase.h:401
Atomic< uint32_t > flags
Resource flags.
Definition: ResourceBase.h:395
ResourceBase()=default
Constructs a new resource base.
StringRef name
User friendly name, used when referring to the resource in log messages etc.
Definition: ResourceBase.h:86