Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Toggle main menu visibility
Main Page
Related Pages
Classes
Class List
Class Index
Class Hierarchy
Files
File List
•
All
Classes
Pages
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
Unloaded = 0,
13
Loading,
14
Ready,
15
Reloading
16
};
17
18
struct
Asset
{
19
Asset
() =
default
;
20
Asset
(
Uuid
uuid, std::string_view name) : uuid(uuid), name(name) {}
21
22
Uuid
uuid;
23
std::string name;
24
size_t
referenceCount = 1;
25
AssetLoadStatus assetLoadStatus = AssetLoadStatus::Unloaded;
26
27
static
AssetType GetStaticType() {
return
AssetType::Undefined; }
28
virtual
AssetType GetAssetType()
const
{
return
GetStaticType(); }
29
30
virtual
bool
operator==(
const
Asset
& other)
const
{
31
return
uuid == other.uuid;
32
}
33
34
virtual
bool
operator!=(
const
Asset
& other)
const
{
35
return
!(*
this
== other);
36
}
37
};
18
struct
Asset
{
…
};
38
39
struct
GenericAssetReference
{
40
Uuid
uuid;
41
};
39
struct
GenericAssetReference
{
…
};
42
43
template
<
typename
T>
44
struct
AssetReference
:
public
GenericAssetReference
{
45
static_assert
(std::is_base_of_v<Grindstone::Asset, T>,
"T not derived from Grindstone::Asset"
);
46
47
T* Load(
Uuid
uuid) {
48
this->uuid = uuid;
49
return
EngineCore::GetInstance().assetManager->GetAsset<T>(uuid);
50
}
51
52
T* Get()
const
{
53
return
EngineCore::GetInstance().assetManager->GetAsset<T>(uuid);
54
}
55
};
44
struct
AssetReference
:
public
GenericAssetReference
{
…
};
56
57
#define DEFINE_ASSET_TYPE(name, assetType) \
58
static std::string GetStaticTypeName() { return name; }\
59
virtual std::string GetAssetTypeName() { return name; }\
60
static AssetType GetStaticType() { return assetType; }\
61
virtual AssetType GetAssetType() const override { return assetType; }\
62
static size_t GetStaticAssetTypeHash() { return std::hash<std::string>()(name); }\
63
virtual size_t GetAssetTypeHash() { return GetStaticAssetTypeHash(); }
64
}
Grindstone::Uuid
Definition
Uuid.hpp:6
Grindstone::AssetReference
Definition
Asset.hpp:44
Grindstone::Asset
Definition
Asset.hpp:18
Grindstone::GenericAssetReference
Definition
Asset.hpp:39
sources
code
EngineCore
Assets
Asset.hpp
Generated by
1.12.0