Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
AssetRegistry.hpp
1#pragma once
2
3#include <cstdint>
4#include <filesystem>
5#include <map>
6#include <string>
7#include <unordered_set>
8#include <vector>
9
10#include <Common/ResourcePipeline/AssetType.hpp>
11#include <Common/ResourcePipeline/Uuid.hpp>
12
14 class MetaFile;
15
16 enum class AssetEntryStatus {
17 Undiscovered,
18 DiscoveredNeedsReimport,
19 Imported
20 };
21
23 public:
24 struct Entry {
25 AssetEntryStatus status;
26 Uuid uuid;
27 std::string displayName;
28 std::string subassetIdentifier;
29 std::string address;
30 std::filesystem::path path;
31 AssetType assetType;
32 std::filesystem::file_time_type sourceFileWrite;
33 std::filesystem::file_time_type metaFileWrite;
34 uint32_t assetImporterVersion;
35 uint32_t metaFileVersion;
36 uint64_t assetFileSize;
37 uint64_t metaFileSize;
38 };
39
40 public:
41 virtual ~AssetRegistry();
42
43 void Initialize(const std::filesystem::path& projectPath);
44 virtual void Cleanup();
45 virtual void UpdateEntry(
46 AssetEntryStatus status,
47 const std::filesystem::path& path,
48 const std::string_view subassetIdentifier,
49 const std::string_view displayName,
50 const std::string_view address,
51 Uuid& uuid,
52 AssetType assetType,
53 std::filesystem::file_time_type sourceFileWrite,
54 std::filesystem::file_time_type metaFileWrite,
55 uint32_t assetImporterVersion,
56 uint32_t metaFileVersion,
57 uint64_t assetFileSize,
58 uint64_t metaFileSize
59 );
60 virtual void WriteFile();
61 virtual void ReadFile();
62 virtual Uuid Import(const std::filesystem::path& path);
63 [[nodiscard]] virtual Grindstone::Editor::MetaFile GetMetaFileByPath(const std::filesystem::path& path);
64 [[nodiscard]] virtual const std::filesystem::path& GetCompiledAssetsPath() const;
65
66 virtual bool RemoveEntry(Uuid uuid);
67 virtual bool HasAsset(Uuid uuid) const;
68 virtual bool TryGetPathWithMountPoint(const std::filesystem::path& path, std::filesystem::path& outMountedPath) const;
69 virtual bool TryGetAbsolutePathFromMountedPath(const std::filesystem::path& mountedPath, std::filesystem::path& outAbsolutePath) const;
70 virtual bool TryGetAssetDataFromAbsolutePath(const std::filesystem::path& path, AssetRegistry::Entry& outEntry) const;
71 virtual bool TryGetAssetData(const std::filesystem::path & path, AssetRegistry::Entry & outEntry) const;
72 virtual bool TryGetAssetData(const std::string& address, AssetRegistry::Entry& outEntry) const;
73 virtual bool TryGetAssetData(Uuid uuid, AssetRegistry::Entry& outEntry) const;
74
75 virtual void FindAllFilesOfType(AssetType assetType, std::vector<Entry>& outEntries) const;
76
77 virtual std::unordered_set<Grindstone::Uuid> GetUsedUuids() const;
78 private:
79 std::map<Uuid, Entry> assets;
80 std::filesystem::path assetsPath;
81 std::filesystem::path compiledAssetsPath;
82 std::filesystem::path assetRegistryPath;
83 };
84}
Definition AssetRegistry.hpp:22
Definition MetaFile.hpp:15
Definition Uuid.hpp:7
Definition AssetRegistry.hpp:13
Definition AssetRegistry.hpp:24