Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Toggle main menu visibility
Loading...
Searching...
No Matches
Asset.hpp
1
#pragma once
2
3
#include <string>
4
#include <type_traits>
5
6
#include <Common/ResourcePipeline/Uuid.hpp>
7
#include <Common/ResourcePipeline/AssetType.hpp>
8
#include <EngineCore/EngineCore.hpp>
9
10
namespace
Grindstone {
11
enum class
AssetLoadStatus {
12
// This asset has not been loaded yet, or has been unloaded.
13
Unloaded = 0,
14
// This asset is in the process of being loaded.
15
Loading,
16
// This asset is ready for use.
17
Ready,
18
// This asset was previously loaded, and is now being loaded again.
19
Reloading,
20
// This asset failed to load because it was not found.
21
Missing,
22
// This asset failed to load due to an error in the file or the loading process.
23
Failed
24
};
25
26
struct
Asset {
27
Asset() =
default
;
28
Asset(
Uuid
uuid, std::string_view name) : uuid(uuid), name(name) {}
29
30
Uuid
uuid;
31
std::string name;
32
size_t
referenceCount = 1;
33
AssetLoadStatus assetLoadStatus = AssetLoadStatus::Unloaded;
34
35
static
AssetType GetStaticType() {
return
AssetType::Undefined; }
36
virtual
AssetType GetAssetType()
const
{
return
GetStaticType(); }
37
38
virtual
bool
operator==(
const
Asset& other)
const
{
39
return
uuid == other.uuid;
40
}
41
42
virtual
bool
operator!=(
const
Asset& other)
const
{
43
return
!(*
this
== other);
44
}
45
};
46
47
#define DEFINE_ASSET_TYPE(name, assetType) \
48
static std::string GetStaticTypeName() { return name; }\
49
virtual std::string GetAssetTypeName() { return name; }\
50
static AssetType GetStaticType() { return assetType; }\
51
virtual AssetType GetAssetType() const override { return assetType; }\
52
static size_t GetStaticAssetTypeHash() { return std::hash<std::string>()(name); }\
53
virtual size_t GetAssetTypeHash() { return GetStaticAssetTypeHash(); }
54
}
Grindstone::Uuid
Definition
Uuid.hpp:7
sources
code
EngineCore
Assets
Asset.hpp
Generated by
1.17.0