From f50367f7d5c36366853a892a40687b346f27f421 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 3 Jan 2025 00:26:10 -0600 Subject: [PATCH 1/3] [ox/std] Add hash.hpp to install --- deps/ox/src/ox/std/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index ae2b9410..67de0f90 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -109,6 +109,7 @@ install( error.hpp fmt.hpp hardware.hpp + hash.hpp hashmap.hpp heapmgr.hpp ignore.hpp From ede2c8ca37d97f64bbf83b9d23b6d999bad69478 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 4 Jan 2025 01:05:04 -0600 Subject: [PATCH 2/3] [keel] Make AssetTypeManager(Loader) move loader --- src/olympic/keel/include/keel/assetmanager.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/olympic/keel/include/keel/assetmanager.hpp b/src/olympic/keel/include/keel/assetmanager.hpp index a857879d..44b2acef 100644 --- a/src/olympic/keel/include/keel/assetmanager.hpp +++ b/src/olympic/keel/include/keel/assetmanager.hpp @@ -202,7 +202,7 @@ class AssetManager { ox::HashMap>> m_cache; public: - AssetTypeManager(Loader loader) noexcept: m_loader(loader) {} + AssetTypeManager(Loader &&loader) noexcept: m_loader(std::move(loader)) {} ox::Result> getAsset(ox::StringView const assetId) const noexcept { OX_REQUIRE(out, m_cache.at(assetId)); From 6837a0556d179a1ae0d7ef64b990b73b1ce821b1 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 4 Jan 2025 01:11:05 -0600 Subject: [PATCH 3/3] [keel] Make AssetManager take StringViewCR for assetId --- src/olympic/keel/include/keel/assetmanager.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/olympic/keel/include/keel/assetmanager.hpp b/src/olympic/keel/include/keel/assetmanager.hpp index 44b2acef..5c22a702 100644 --- a/src/olympic/keel/include/keel/assetmanager.hpp +++ b/src/olympic/keel/include/keel/assetmanager.hpp @@ -196,7 +196,7 @@ class AssetManager { template class AssetTypeManager: public AssetTypeManagerBase { public: - using Loader = std::function(ox::StringView assetId)>; + using Loader = std::function(ox::StringViewCR assetId)>; private: Loader m_loader{}; ox::HashMap>> m_cache; @@ -204,7 +204,7 @@ class AssetManager { public: AssetTypeManager(Loader &&loader) noexcept: m_loader(std::move(loader)) {} - ox::Result> getAsset(ox::StringView const assetId) const noexcept { + ox::Result> getAsset(ox::StringViewCR assetId) const noexcept { OX_REQUIRE(out, m_cache.at(assetId)); if (!out || !*out) { return ox::Error(1, "asset is null"); @@ -212,7 +212,7 @@ class AssetManager { return AssetRef(out->get()); } - ox::Result> loadAsset(ox::StringView const assetId) noexcept { + ox::Result> loadAsset(ox::StringViewCR assetId) noexcept { auto &p = m_cache[assetId]; OX_REQUIRE_M(obj, m_loader(assetId)); if (!p) { @@ -224,7 +224,7 @@ class AssetManager { return AssetRef(p.get()); } - ox::Error reloadAsset(ox::StringView const assetId) noexcept { + ox::Error reloadAsset(ox::StringViewCR assetId) noexcept { auto &p = m_cache[assetId]; OX_REQUIRE_M(obj, m_loader(assetId)); if (!p) { @@ -247,7 +247,7 @@ class AssetManager { }; ox::HashMap> m_assetTypeManagers; - ox::HashMap> m_fileUpdated; + ox::HashMap> m_fileUpdated; template ox::Result*> getTypeManager() noexcept { @@ -273,18 +273,18 @@ class AssetManager { } template - ox::Result> getAsset(ox::StringView assetId) noexcept { + ox::Result> getAsset(ox::StringViewCR assetId) noexcept { OX_REQUIRE(m, getTypeManager()); return m->getAsset(assetId); } - ox::Error reloadAsset(ox::StringView assetId) noexcept { + ox::Error reloadAsset(ox::StringViewCR assetId) noexcept { m_fileUpdated[assetId].emit(assetId); return {}; } template - ox::Result> loadAsset(ox::StringView assetId) noexcept { + ox::Result> loadAsset(ox::StringViewCR assetId) noexcept { OX_REQUIRE(m, getTypeManager()); OX_REQUIRE(out, m->loadAsset(assetId)); m_fileUpdated[assetId].connect(m, &AssetTypeManager::reloadAsset);