NoJobEngine 2.0.7
Loading...
Searching...
No Matches
AssetRegistry.h
Go to the documentation of this file.
1
6#pragma once
8#include <filesystem>
9#include <unordered_map>
10#include <vector>
11
12namespace NoJob
13{
15 {
16 public:
17 explicit AssetRegistry(std::filesystem::path root = "Assets");
18 void Scan();
19 bool Save() const;
20 bool Load();
21
22 AssetHandle Register(const std::filesystem::path& path, AssetType type = AssetType::Unknown);
23 AssetHandle FindHandle(const std::filesystem::path& path) const;
24 const AssetMetadata* Find(AssetHandle handle) const;
25 const AssetMetadata* Find(const std::filesystem::path& path) const;
26 std::vector<AssetMetadata> GetAll() const;
27
28 const std::filesystem::path& GetRoot() const { return m_Root; }
29 static AssetType TypeFromExtension(const std::filesystem::path& path);
30 private:
31 static AssetHandle StableHandle(const std::filesystem::path& normalized);
32 static std::string Normalize(const std::filesystem::path& path);
33 std::filesystem::path m_Root;
34 std::unordered_map<AssetHandle,AssetMetadata> m_ByHandle;
35 std::unordered_map<std::string,AssetHandle> m_ByPath;
36 };
37}
Asset declarations for the Asset Management subsystem.
AssetHandle Register(const std::filesystem::path &path, AssetType type=AssetType::Unknown)
AssetRegistry(std::filesystem::path root="Assets")
static AssetType TypeFromExtension(const std::filesystem::path &path)
const AssetMetadata * Find(AssetHandle handle) const
const std::filesystem::path & GetRoot() const
AssetHandle FindHandle(const std::filesystem::path &path) const
std::vector< AssetMetadata > GetAll() const
std::uint64_t AssetHandle
Definition Asset.h:13
AssetType
Definition Asset.h:17