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 <filesystem>
4#include <map>
5#include <string>
6#include <vector>
7#include <unordered_set>
8
9#include <Common/ResourcePipeline/AssetType.hpp>
10#include <Common/ResourcePipeline/Uuid.hpp>
11
12namespace Grindstone::Editor {
13 class MetaFile;
14
16 public:
17 struct Entry {
18 Uuid uuid;
19 std::string displayName;
20 std::string subassetIdentifier;
21 std::string address;
22 std::filesystem::path path;
23 AssetType assetType;
24 std::filesystem::file_time_type sourceFileWrite;
25 std::filesystem::file_time_type metaFileWrite;
26 uint32_t assetImporterVersion;
27 uint32_t metaFileVersion;
28 uint64_t assetFileSize;
29 uint64_t metaFileSize;
30 };
31
32 public:
33 virtual ~AssetRegistry();
34
35 void Initialize(const std::filesystem::path& projectPath);
36 virtual void Cleanup();
37 virtual void UpdateEntry(
38 const std::filesystem::path& path,
39 const std::string_view subassetIdentifier,
40 const std::string_view displayName,
41 const std::string_view address,
42 Uuid& uuid,
43 AssetType assetType,
44 std::filesystem::file_time_type sourceFileWrite,
45 std::filesystem::file_time_type metaFileWrite,
46 uint32_t assetImporterVersion,
47 uint32_t metaFileVersion,
48 uint64_t assetFileSize,
49 uint64_t metaFileSize
50 );
51 virtual void WriteFile();
52 virtual void ReadFile();
53 virtual Uuid Import(const std::filesystem::path& path);
54 [[nodiscard]] virtual Grindstone::Editor::MetaFile GetMetaFileByPath(const std::filesystem::path& path);
55 [[nodiscard]] virtual const std::filesystem::path& GetCompiledAssetsPath() const;
56
57 virtual bool RemoveEntry(Uuid uuid);
58 virtual bool HasAsset(Uuid uuid) const;
59 virtual bool TryGetPathWithMountPoint(const std::filesystem::path& path, std::filesystem::path& outMountedPath) const;
60 virtual bool TryGetAbsolutePathFromMountedPath(const std::filesystem::path& mountedPath, std::filesystem::path& outAbsolutePath) const;
61 virtual bool TryGetAssetDataFromAbsolutePath(const std::filesystem::path& path, AssetRegistry::Entry& outEntry) const;
62 virtual bool TryGetAssetData(const std::filesystem::path & path, AssetRegistry::Entry & outEntry) const;
63 virtual bool TryGetAssetData(const std::string& address, AssetRegistry::Entry& outEntry) const;
64 virtual bool TryGetAssetData(Uuid uuid, AssetRegistry::Entry& outEntry) const;
65
66 virtual void FindAllFilesOfType(AssetType assetType, std::vector<Entry>& outEntries) const;
67
68 virtual std::unordered_set<Grindstone::Uuid> GetUsedUuids() const;
69 private:
70 std::map<Uuid, Entry> assets;
71 std::filesystem::path assetsPath;
72 std::filesystem::path compiledAssetsPath;
73 std::filesystem::path assetRegistryPath;
74 };
75}
Definition AssetRegistry.hpp:15
Definition MetaFile.hpp:13
Definition Uuid.hpp:7
Definition AssetRegistry.hpp:17