diff --git a/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetLibrary.hpp b/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetLibrary.hpp index 1a2ed7f..8b07803 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetLibrary.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/Asset/AssetLibrary.hpp @@ -79,46 +79,6 @@ class AssetLibrary return nullptr; } - /** - * Find The associated container for a given UUID identifying an Asset - * - * \param p_uuid The UUID - * \return The AssetContainer containing the asset. Nullptr if not found - */ - [[nodiscard]] - AssetContainerBase* FindAssetContainerContainerForUUID(const UUID& p_uuid) - { - for (const auto& [typeID, container]: m_assetContainers) - { - if (container->Has(p_uuid)) - { - return container; - } - } - - return nullptr; - } - - /** - * Find The associated container for a given UUID identifying an Asset - * - * \param p_uuid The UUID - * \return The AssetContainer containing the asset. Nullptr if not found - */ - [[nodiscard]] - const AssetContainerBase* FindAssetContainerContainerForUUID(const UUID& p_uuid) const - { - for (const auto& [typeID, container]: m_assetContainers) - { - if (container->Has(p_uuid)) - { - return container; - } - } - - return nullptr; - } - AssetLibrary& operator=(const AssetLibrary& p_library) = default; AssetLibrary& operator=(AssetLibrary&& p_library) = default; diff --git a/Bigfoot/Sources/Engine/Include/Engine/Asset/Reference.hpp b/Bigfoot/Sources/Engine/Include/Engine/Asset/Reference.hpp index 5775f7e..ad85d50 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/Asset/Reference.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/Asset/Reference.hpp @@ -102,17 +102,7 @@ class HardReference return; } - AssetContainerBase* assetContainer = nullptr; - if constexpr (std::is_same_v) - { - assetContainer = g_activeAssetLibrary->FindAssetContainerContainerForUUID(m_uuid); - } - else - { - assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID()); - } - - if (assetContainer) + if (AssetContainerBase* assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID())) { if (!m_handle) { @@ -220,17 +210,7 @@ class SoftReference return; } - AssetContainerBase* assetContainer = nullptr; - if constexpr (std::is_same_v) - { - assetContainer = g_activeAssetLibrary->FindAssetContainerContainerForUUID(m_uuid); - } - else - { - assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID()); - } - - if (assetContainer) + if (AssetContainerBase* assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID())) { if (!m_handle) { diff --git a/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp b/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp index b90bea6..cd53593 100644 --- a/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp +++ b/Bigfoot/Tests/Engine/Asset/AssetContainer.cpp @@ -154,8 +154,7 @@ TEST_F(AssetContainerFixture, Get_ShouldReturnTheAssetWithTheSlotKey) const SlotMapKey slotKey = m_containerA.Insert(asset); EXPECT_EQ(m_containerA.Get(slotKey)->GetHeader().uuid, asset.GetHeader().uuid); - EXPECT_EQ(std::as_const(m_containerA).Get(slotKey)->GetHeader().uuid, - asset.GetHeader().uuid); + EXPECT_EQ(std::as_const(m_containerA).Get(slotKey)->GetHeader().uuid, asset.GetHeader().uuid); } /****************************************************************************************/ diff --git a/Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp b/Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp index 46f5d31..fd5a9ea 100644 --- a/Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp +++ b/Bigfoot/Tests/Engine/Asset/AssetLibrary.cpp @@ -72,48 +72,6 @@ TEST_F(AssetLibraryFixture, GetAssetContainer_ShouldReturnNullptrIfTheContainerD /****************************************************************************************/ -TEST_F(AssetLibraryFixture, FindAssetContainerContainerForUUID_ShouldReturnTheAssetContainerIfAvailable) -{ - std::ignore = m_library.Insert(&m_containerA); - std::ignore = m_library.Insert(&m_containerB); - std::ignore = m_library.Insert(&m_containerC); - - const SlotMapKey keyA = m_containerA.Insert(); - const SlotMapKey keyB = m_containerB.Insert(); - const SlotMapKey keyC = m_containerC.Insert(); - - const UUID uuidA = m_containerA.Get(keyA)->GetHeader().uuid; - const UUID uuidB = m_containerB.Get(keyB)->GetHeader().uuid; - const UUID uuidC = m_containerC.Get(keyC)->GetHeader().uuid; - - EXPECT_EQ(m_library.FindAssetContainerContainerForUUID(uuidA), &m_containerA); - EXPECT_EQ(m_library.FindAssetContainerContainerForUUID(uuidB), &m_containerB); - EXPECT_EQ(m_library.FindAssetContainerContainerForUUID(uuidC), &m_containerC); - - EXPECT_EQ(std::as_const(m_library).FindAssetContainerContainerForUUID(uuidA), &m_containerA); - EXPECT_EQ(std::as_const(m_library).FindAssetContainerContainerForUUID(uuidB), &m_containerB); - EXPECT_EQ(std::as_const(m_library).FindAssetContainerContainerForUUID(uuidC), &m_containerC); -} - -/****************************************************************************************/ - -TEST_F(AssetLibraryFixture, FindAssetContainerContainerForUUID_ShouldReturnNullptrIfTheContainerDoesNotExist) -{ - std::ignore = m_library.Insert(&m_containerA); - std::ignore = m_library.Insert(&m_containerB); - std::ignore = m_library.Insert(&m_containerC); - - std::ignore = m_containerA.Insert(); - std::ignore = m_containerB.Insert(); - std::ignore = m_containerC.Insert(); - - EXPECT_EQ(m_library.FindAssetContainerContainerForUUID(UUID {}), nullptr); - - EXPECT_EQ(std::as_const(m_library).FindAssetContainerContainerForUUID(UUID {}), nullptr); -} - -/****************************************************************************************/ - TEST_F(AssetLibraryFixture, SetActiveAssetLibrary_ShouldSetTheActiveAssetLibraryToTheGivenLibrary) { SetActiveAssetLibrary(&m_library);