LkEngine 0.1.2
 
Loading...
Searching...
No Matches
Asset.h
1#pragma once
2
3#include <filesystem>
4
7#include "LkEngine/Core/LObject/ObjectPtr.h"
8
9#include "LkEngine/Asset/AssetTypes.h"
10
11namespace LkEngine {
12
13 using FAssetHandle = LUUID;
14
20 class LAsset : public LObject
21 {
22 public:
23 virtual ~LAsset() = default;
24
25 FORCEINLINE static EAssetType GetStaticType() { return EAssetType::None; }
26 FORCEINLINE virtual EAssetType GetAssetType() const { return EAssetType::None; }
27
28 FORCEINLINE bool HasFlag(const EAssetFlag Flag) const
29 {
30 return (AssetFlags & Flag);
31 }
32
33 FORCEINLINE void SetFlag(const EAssetFlag Flag, bool Value = true)
34 {
35 if (Value)
36 {
37 AssetFlags |= Flag;
38 }
39 else
40 {
41 AssetFlags &= ~Flag;
42 }
43 }
44
45 FORCEINLINE virtual bool IsValid() const
46 {
47 return ((AssetFlags & EAssetFlag::Missing) | (AssetFlags & EAssetFlag::Invalid));
48 }
49
50 virtual bool operator==(const LAsset& Other) const
51 {
52 return (Handle == Other.Handle);
53 }
54
55 virtual bool operator!=(const LAsset& Other) const
56 {
57 return !(*this == Other);
58 }
59
60 public:
61 FAssetHandle Handle = 0;
62
68 std::underlying_type_t<EAssetFlag> AssetFlags = static_cast<std::underlying_type_t<EAssetFlag>>(EAssetFlag::None);
69
70 private:
72 };
73
74#if 0
78 class LAudioAsset : public LAsset
79 {
80 public:
81 LAudioAsset() = default;
82 ~LAudioAsset() = default;
83
84 FORCEINLINE static EAssetType GetStaticType() { return EAssetType::Audio; }
85
86 private:
87 LASSET(LAudioAsset)
88 };
89#endif
90
92 {
93 FAssetHandle Handle = 0;
94 EAssetType Type = EAssetType::None;
95 std::filesystem::path FilePath{};
96 bool bIsDataLoaded = false;
97 bool bIsMemoryAsset = false;
98
99 FORCEINLINE bool IsValid() const
100 {
101 return ((Handle > 0) && !bIsMemoryAsset);
102 }
103
104 FORCEINLINE std::string ToString(const bool CompactFormat = true) const
105 {
106 if (CompactFormat)
107 {
108 return LK_FMT_LIB::format("Asset={:12} Type={} File={} Loaded={} MemoryOnly={}",
109 (LUUID::SizeType)Handle, Enum::ToString(Type),
110 FilePath.string(),
111 (bIsDataLoaded ? "Yes" : "No"),
112 (bIsMemoryAsset ? "Yes" : "No"));
113 }
114
115 return LK_FMT_LIB::format("[Asset: {}]\n * Type: {}\n * Filepath: {}\n * Loaded: {}\n * Memory Asset: {}",
116 (LUUID::SizeType)Handle, Enum::ToString(Type),
117 FilePath.string(),
118 (bIsDataLoaded ? "Yes" : "No"),
119 (bIsMemoryAsset ? "Yes" : "No"));
120 }
121 };
122
123}
Core header.
LObject implementation.
Definition Asset.h:21
std::underlying_type_t< EAssetFlag > AssetFlags
Definition Asset.h:68
Definition Object.h:46
#define LASSET(Class)
Definition CoreMacros.h:316
#define LCLASS(Class)
Definition CoreMacros.h:226
Definition Asset.h:11
EAssetFlag
Definition AssetTypes.h:11
EAssetType
Definition AssetTypes.h:24
Definition Asset.h:92
Definition UUID.h:13