BigFile/Sasquatch #1
@@ -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;
|
||||
|
||||
|
||||
@@ -102,17 +102,7 @@ class HardReference
|
||||
return;
|
||||
}
|
||||
|
||||
AssetContainerBase* assetContainer = nullptr;
|
||||
if constexpr (std::is_same_v<ASSET, AssetBase>)
|
||||
{
|
||||
assetContainer = g_activeAssetLibrary->FindAssetContainerContainerForUUID(m_uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID<ASSET>());
|
||||
}
|
||||
|
||||
if (assetContainer)
|
||||
if (AssetContainerBase* assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID<ASSET>()))
|
||||
{
|
||||
if (!m_handle)
|
||||
{
|
||||
@@ -220,17 +210,7 @@ class SoftReference
|
||||
return;
|
||||
}
|
||||
|
||||
AssetContainerBase* assetContainer = nullptr;
|
||||
if constexpr (std::is_same_v<ASSET, AssetBase>)
|
||||
{
|
||||
assetContainer = g_activeAssetLibrary->FindAssetContainerContainerForUUID(m_uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID<ASSET>());
|
||||
}
|
||||
|
||||
if (assetContainer)
|
||||
if (AssetContainerBase* assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID<ASSET>()))
|
||||
{
|
||||
if (!m_handle)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user