@@ -31,16 +31,24 @@ namespace Mahakam
3131 // - A move function is used in the control block for moving another asset (of the same type) into this space
3232 // - A delete function is used in the control block for deleting when no longer used
3333
34- typedef uint64_t AssetID;
34+ using AssetID = uint64_t ;
3535
3636 // TODO: Remove
3737 typedef std::string ExtensionType;
3838
39+ enum class AssetState
40+ {
41+ Loaded = 0 ,
42+ Processing,
43+ Streaming
44+ };
45+
3946 struct ControlBlock
4047 {
4148 // ID 0 is guaranteed to be invalid
4249 size_t UseCount;
4350 AssetID ID;
51+ AssetState State;
4452 void (*MoveData)(void *, void *);
4553 void (*DeleteData)(void *);
4654 };
@@ -51,36 +59,31 @@ namespace Mahakam
5159 struct StreamBlock
5260 {
5361 Reader File;
54- void (*Stream)(void *) = nullptr ;
55- void (*Load)(void *) = nullptr ;
5662 };
5763
5864 struct AssetSerializer
5965 {
6066 bool (*Serialize)(Writer&, const std::filesystem::path& filepath, Asset<void >) = nullptr ;
6167 Asset<void > (*Deserialize)(Reader&, const std::filesystem::path& filepath) = nullptr ;
68+ Asset<void > (*Load)(Reader&) = nullptr ;
6269 };
6370
6471 private:
6572 using AssetMap = UnorderedMap<AssetID, std::filesystem::path>;
66-
67- using ImporterMap = UnorderedMap<ExtensionType, Ref<AssetImporter>>;
6873 using LoadedMap = UnorderedMap<AssetID, ControlBlock*>;
6974
70- // TODO: Use AssetInfo instead of filepath
75+ // TODO: Remove since filepaths are the same as ID
7176 inline static AssetMap s_AssetPaths;
72-
73- inline static ImporterMap s_AssetImporters; // Legacy importers
7477 inline static LoadedMap s_LoadedAssets;
7578
76-
77- // TODO: Move into own class
78- inline static const std::filesystem::path EmptyPath = " " ;
79-
8079 inline static UnorderedMap<std::string, AssetSerializer> s_Serializers;
8180
81+ // Legacy importers
82+ using ImporterMap = UnorderedMap<ExtensionType, Ref<AssetImporter>>;
83+ inline static ImporterMap s_AssetImporters;
8284 template <const char * Extension, const char * LegacyExt>
8385 static void LoadLegacySerializer ();
86+ // Legacy importers
8487
8588 static void LoadDefaultSerializers ();
8689
@@ -100,7 +103,6 @@ namespace Mahakam
100103 MH_DECLARE_FUNC (RefreshAssetPaths, void ); // Refreshes the asset paths, finding new assets and removing unused ones
101104
102105 // Various getters
103- MH_DECLARE_FUNC (GetAssetImportPath, const std::filesystem::path&, AssetID id); // Gets the import path of a given asset
104106 MH_DECLARE_FUNC (GetAssetHandles, const AssetMap&); // Gets a reference to all assets, whether they're currently loaded or not
105107 MH_DECLARE_FUNC (GetAssetReferences, size_t , AssetID id); // Gets the amount of references to this asset, if any
106108
0 commit comments