Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b1d71993da | |||
| 1b32cd07f6 | |||
| 6788961ca0 |
@@ -1,34 +0,0 @@
|
|||||||
/*********************************************************************
|
|
||||||
* \file Reference.cpp
|
|
||||||
*
|
|
||||||
* \author Romain BOULLARD
|
|
||||||
* \date July 2026
|
|
||||||
*********************************************************************/
|
|
||||||
#include <Engine/Asset/Reference.hpp>
|
|
||||||
|
|
||||||
#include <Engine/Asset/Reference_generated.hpp>
|
|
||||||
|
|
||||||
namespace flatbuffers
|
|
||||||
{
|
|
||||||
Flat::Bigfoot::AnyHardReference Pack(const ::Bigfoot::AnyHardReference& p_ref)
|
|
||||||
{
|
|
||||||
return {Pack(p_ref.GetUUID())};
|
|
||||||
}
|
|
||||||
|
|
||||||
::Bigfoot::AnyHardReference UnPack(const Flat::Bigfoot::AnyHardReference& p_ref)
|
|
||||||
{
|
|
||||||
return {UnPack(p_ref.uuid())};
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
Flat::Bigfoot::AnySoftReference Pack(const ::Bigfoot::AnySoftReference& p_ref)
|
|
||||||
{
|
|
||||||
return {Pack(p_ref.GetUUID())};
|
|
||||||
}
|
|
||||||
|
|
||||||
::Bigfoot::AnySoftReference UnPack(const Flat::Bigfoot::AnySoftReference& p_ref)
|
|
||||||
{
|
|
||||||
return {UnPack(p_ref.uuid())};
|
|
||||||
}
|
|
||||||
} // namespace flatbuffers
|
|
||||||
@@ -65,7 +65,7 @@ class Asset: public AssetBase
|
|||||||
flatbuffers::GetRoot<FLAT_ASSET>(asset->inner_asset()->data())->UnPackTo(&m_asset, nullptr);
|
flatbuffers::GetRoot<FLAT_ASSET>(asset->inner_asset()->data())->UnPackTo(&m_asset, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Asset(const Asset& p_asset) = delete;
|
Asset(const Asset& p_asset) = default;
|
||||||
Asset(Asset&& p_asset) = default;
|
Asset(Asset&& p_asset) = default;
|
||||||
|
|
||||||
~Asset() = default;
|
~Asset() = default;
|
||||||
@@ -130,7 +130,7 @@ class Asset: public AssetBase
|
|||||||
return FLAT_ASSET::GetFullyQualifiedName();
|
return FLAT_ASSET::GetFullyQualifiedName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Asset& operator=(const Asset& p_asset) = delete;
|
Asset& operator=(const Asset& p_asset) = default;
|
||||||
Asset& operator=(Asset&& p_asset) = default;
|
Asset& operator=(Asset&& p_asset) = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -27,32 +27,69 @@ class ContainerHandle
|
|||||||
|
|
||||||
~ContainerHandle() = default;
|
~ContainerHandle() = default;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increment the HardRef count
|
||||||
|
*
|
||||||
|
*/
|
||||||
void IncrementHardRefCount()
|
void IncrementHardRefCount()
|
||||||
{
|
{
|
||||||
++m_hardRefCount;
|
++m_hardRefCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Decrement the HardRef count
|
||||||
|
*
|
||||||
|
*/
|
||||||
void DecrementHardRefCount()
|
void DecrementHardRefCount()
|
||||||
{
|
{
|
||||||
--m_hardRefCount;
|
--m_hardRefCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increment the SoftRef count
|
||||||
|
*
|
||||||
|
*/
|
||||||
void IncrementSoftRefCount()
|
void IncrementSoftRefCount()
|
||||||
{
|
{
|
||||||
++m_softRefCount;
|
++m_softRefCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Decrement the SoftRef count
|
||||||
|
*
|
||||||
|
*/
|
||||||
void DecrementSoftRefCount()
|
void DecrementSoftRefCount()
|
||||||
{
|
{
|
||||||
--m_softRefCount;
|
--m_softRefCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Asset
|
||||||
|
*
|
||||||
|
* \return The asset, can be nullptr
|
||||||
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
AssetBase* GetAsset() const
|
AssetBase* GetAsset()
|
||||||
{
|
{
|
||||||
return m_asset;
|
return m_asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Asset
|
||||||
|
*
|
||||||
|
* \return The asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const AssetBase* GetAsset() const
|
||||||
|
{
|
||||||
|
return m_asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the asset
|
||||||
|
*
|
||||||
|
* \param p_asset The asset
|
||||||
|
*/
|
||||||
void SetAsset(AssetBase* p_asset)
|
void SetAsset(AssetBase* p_asset)
|
||||||
{
|
{
|
||||||
m_asset = p_asset;
|
m_asset = p_asset;
|
||||||
@@ -62,63 +99,162 @@ class ContainerHandle
|
|||||||
ContainerHandle& operator=(ContainerHandle&& p_handle) = default;
|
ContainerHandle& operator=(ContainerHandle&& p_handle) = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/*
|
||||||
|
* The HardRef count
|
||||||
|
*/
|
||||||
std::uint32_t m_hardRefCount = 0;
|
std::uint32_t m_hardRefCount = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The SoftRef count
|
||||||
|
*/
|
||||||
std::uint32_t m_softRefCount = 0;
|
std::uint32_t m_softRefCount = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The asset
|
||||||
|
*/
|
||||||
AssetBase* m_asset = nullptr;
|
AssetBase* m_asset = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
class AssetContainerBase
|
class AssetContainerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~AssetContainerBase() = default;
|
virtual ~AssetContainerBase() = default;
|
||||||
|
|
||||||
[[nodiscard]]
|
/*
|
||||||
SlotMapKey GetAssetSlotKey(const UUID& p_uuid) const
|
* Check if an Asset is in the AssetContainer or not
|
||||||
{
|
*
|
||||||
if (const auto it = m_uuidToAssetSlotKey.find(p_uuid); it != m_uuidToAssetSlotKey.end())
|
* \param p_uuid The UUID to check
|
||||||
{
|
* \return True if in AssetContainer, false otherwise
|
||||||
return it->second;
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
return SlotMapKey {};
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool Has(const UUID& p_uuid) const
|
bool Has(const UUID& p_uuid) const
|
||||||
{
|
{
|
||||||
return m_uuidToAssetSlotKey.contains(p_uuid);
|
const Entry* entry = FindEntry(p_uuid);
|
||||||
|
return entry != nullptr && entry->m_assetSlotKey.Valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Acquires a ContainerHandle for a given UUID
|
||||||
|
* Will create it if it does not exists
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to get ContainerHandle for
|
||||||
|
* \return A ContainerHandle for the UUID
|
||||||
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ContainerHandle& AcquireHandle(const UUID& p_uuid)
|
ContainerHandle& AcquireContainerHandle(const UUID& p_uuid)
|
||||||
{
|
{
|
||||||
if (const auto it = m_uuidToContainerHandleSlotKey.find(p_uuid); it != m_uuidToContainerHandleSlotKey.end())
|
return *m_handles.Get(GetOrCreateEntry(p_uuid).m_handleSlotKey);
|
||||||
{
|
|
||||||
return *m_handles.Get(it->second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SlotMapKey key = m_handles.Insert();
|
/*
|
||||||
m_uuidToContainerHandleSlotKey.insert({p_uuid, key});
|
* Remove an Asset from the AssetContainer
|
||||||
|
*
|
||||||
return *m_handles.Get(key);
|
* \param p_uuid The UUID to remove
|
||||||
|
*/
|
||||||
|
virtual void Remove(const UUID& p_uuid)
|
||||||
|
{
|
||||||
|
if (Entry* entry = FindEntry(p_uuid); entry != nullptr && entry->m_handleSlotKey.Valid())
|
||||||
|
{
|
||||||
|
m_handles.Remove(entry->m_handleSlotKey);
|
||||||
|
m_uuidToEntry.erase(p_uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetContainerBase& operator=(const AssetContainerBase& p_container) = delete;
|
AssetContainerBase& operator=(const AssetContainerBase& p_container) = delete;
|
||||||
AssetContainerBase& operator=(AssetContainerBase&& p_container) = default;
|
AssetContainerBase& operator=(AssetContainerBase&& p_container) = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
struct Entry
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* SlotMapKey to the handle
|
||||||
|
*/
|
||||||
|
SlotMapKey m_handleSlotKey;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SlotMapKey to the asset
|
||||||
|
*/
|
||||||
|
SlotMapKey m_assetSlotKey;
|
||||||
|
};
|
||||||
|
|
||||||
AssetContainerBase() = default;
|
AssetContainerBase() = default;
|
||||||
|
|
||||||
AssetContainerBase(const AssetContainerBase& p_container) = delete;
|
AssetContainerBase(const AssetContainerBase& p_container) = delete;
|
||||||
AssetContainerBase(AssetContainerBase&& p_container) = default;
|
AssetContainerBase(AssetContainerBase&& p_container) = default;
|
||||||
|
|
||||||
ankerl::unordered_dense::segmented_map<UUID, SlotMapKey> m_uuidToAssetSlotKey;
|
/*
|
||||||
ankerl::unordered_dense::segmented_map<UUID, SlotMapKey> m_uuidToContainerHandleSlotKey;
|
* Finds an entry matching the Asset
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to find
|
||||||
|
* \return Pointer to an Entry, nullptr otherwise
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
Entry* FindEntry(const UUID& p_uuid)
|
||||||
|
{
|
||||||
|
const auto it = m_uuidToEntry.find(p_uuid);
|
||||||
|
return it != m_uuidToEntry.end() ? &it->second : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finds an entry matching the Asset
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to find
|
||||||
|
* \return Pointer to an Entry, nullptr otherwise
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const Entry* FindEntry(const UUID& p_uuid) const
|
||||||
|
{
|
||||||
|
const auto it = m_uuidToEntry.find(p_uuid);
|
||||||
|
return it != m_uuidToEntry.end() ? &it->second : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finds an entry matching the Asset
|
||||||
|
* Creates it if it does not exist
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to find
|
||||||
|
* \return The entry matching the Asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
Entry& GetOrCreateEntry(const UUID& p_uuid)
|
||||||
|
{
|
||||||
|
auto [it, inserted] = m_uuidToEntry.try_emplace(p_uuid);
|
||||||
|
if (inserted)
|
||||||
|
{
|
||||||
|
it->second.m_handleSlotKey = m_handles.Insert();
|
||||||
|
}
|
||||||
|
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a ContainerHandle
|
||||||
|
*
|
||||||
|
* \param p_handleSlotKey The key to the container
|
||||||
|
* \return The container
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
ContainerHandle& FindContainerHandle(const SlotMapKey p_handleSlotKey)
|
||||||
|
{
|
||||||
|
return *m_handles.Get(p_handleSlotKey);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/*
|
||||||
|
* HandleContainers
|
||||||
|
*/
|
||||||
StableSlotMap<ContainerHandle> m_handles;
|
StableSlotMap<ContainerHandle> m_handles;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Every Asset added to the map
|
||||||
|
*/
|
||||||
|
ankerl::unordered_dense::segmented_map<UUID, Entry> m_uuidToEntry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
template<class ASSET>
|
template<class ASSET>
|
||||||
class AssetContainer: public AssetContainerBase
|
class AssetContainer: public AssetContainerBase
|
||||||
{
|
{
|
||||||
@@ -130,45 +266,83 @@ class AssetContainer: public AssetContainerBase
|
|||||||
|
|
||||||
~AssetContainer() = default;
|
~AssetContainer() = default;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inserts an Asset to the AssetContainer
|
||||||
|
*
|
||||||
|
* \tparam ARGS Arguments to construct the asset
|
||||||
|
* \param p_args The arguments
|
||||||
|
* \return The key to the inserted asset.
|
||||||
|
*/
|
||||||
template<class... ARGS>
|
template<class... ARGS>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
SlotMapKey Insert(ARGS&&... p_args)
|
SlotMapKey Insert(ARGS&&... p_args)
|
||||||
{
|
{
|
||||||
const SlotMapKey slotKey = m_assets.Insert(std::forward<ARGS>(p_args)...);
|
SlotMapKey slotKey = m_assets.Insert(std::forward<ARGS>(p_args)...);
|
||||||
ASSET* asset = m_assets.Get(slotKey);
|
ASSET* asset = m_assets.Get(slotKey);
|
||||||
m_uuidToAssetSlotKey.insert({asset->GetHeader().uuid, slotKey});
|
|
||||||
|
|
||||||
AcquireHandle(asset->GetHeader().uuid).SetAsset(asset);
|
Entry& entry = GetOrCreateEntry(asset->GetHeader().uuid);
|
||||||
|
if (entry.m_assetSlotKey.Valid())
|
||||||
|
{
|
||||||
|
m_assets.Remove(slotKey);
|
||||||
|
slotKey = entry.m_assetSlotKey;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entry.m_assetSlotKey = slotKey;
|
||||||
|
FindContainerHandle(entry.m_handleSlotKey).SetAsset(asset);
|
||||||
|
}
|
||||||
|
|
||||||
return slotKey;
|
return slotKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Asset
|
||||||
|
*
|
||||||
|
* \param p_key The key to the asset
|
||||||
|
* \return Pointer to the Asset
|
||||||
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ASSET* Get(const SlotMapKey p_key)
|
ASSET* Get(const SlotMapKey p_key)
|
||||||
{
|
{
|
||||||
return m_assets.Get(p_key);
|
return m_assets.Get(p_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Asset
|
||||||
|
*
|
||||||
|
* \param p_key The key to the asset
|
||||||
|
* \return Pointer to the Asset
|
||||||
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
const ASSET* Get(const SlotMapKey p_key) const
|
const ASSET* Get(const SlotMapKey p_key) const
|
||||||
{
|
{
|
||||||
return m_assets.Get(p_key);
|
return m_assets.Get(p_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Remove(const UUID& p_uuid)
|
/*
|
||||||
|
* Remove an Asset from the AssetContainer
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to remove
|
||||||
|
*/
|
||||||
|
void Remove(const UUID& p_uuid) override
|
||||||
{
|
{
|
||||||
if (const auto it = m_uuidToAssetSlotKey.find(p_uuid); it != m_uuidToAssetSlotKey.end())
|
if (Entry* entry = FindEntry(p_uuid); entry != nullptr && entry->m_assetSlotKey.Valid())
|
||||||
{
|
{
|
||||||
AcquireHandle(p_uuid).SetAsset(nullptr);
|
FindContainerHandle(entry->m_handleSlotKey).SetAsset(nullptr);
|
||||||
m_assets.Remove(it->second);
|
m_assets.Remove(entry->m_assetSlotKey);
|
||||||
m_uuidToAssetSlotKey.erase(it->first);
|
entry->m_assetSlotKey = SlotMapKey {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AssetContainerBase::Remove(p_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetContainer& operator=(const AssetContainer& p_container) = delete;
|
AssetContainer& operator=(const AssetContainer& p_container) = delete;
|
||||||
AssetContainer& operator=(AssetContainer&& p_container) = default;
|
AssetContainer& operator=(AssetContainer&& p_container) = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/*
|
||||||
|
* The assets
|
||||||
|
*/
|
||||||
StableSlotMap<ASSET> m_assets;
|
StableSlotMap<ASSET> m_assets;
|
||||||
};
|
};
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ class AssetLibrary
|
|||||||
|
|
||||||
~AssetLibrary() = default;
|
~AssetLibrary() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert an AssetContainer pointer to the library
|
||||||
|
*
|
||||||
|
* \tparam ASSET The Asset type
|
||||||
|
* \param p_assetContainer The asset container
|
||||||
|
* \return The AssetContainer for the Asset type. Nullptr if not found
|
||||||
|
*/
|
||||||
template<class ASSET>
|
template<class ASSET>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool Insert(AssetContainer<ASSET>* p_assetContainer)
|
bool Insert(AssetContainer<ASSET>* p_assetContainer)
|
||||||
@@ -38,24 +45,42 @@ class AssetLibrary
|
|||||||
return inserted.second;
|
return inserted.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AssetContainer for a given Asset type
|
||||||
|
*
|
||||||
|
* \tparam ASSET The Asset type
|
||||||
|
* \return The AssetContainer for the Asset type. Nullptr if not found
|
||||||
|
*/
|
||||||
template<class ASSET>
|
template<class ASSET>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
AssetContainer<ASSET>* Get()
|
AssetContainer<ASSET>* GetAssetContainer()
|
||||||
{
|
{
|
||||||
static const AssetTypeID typeID = ASSET::GetTypeID();
|
static const AssetTypeID typeID = ASSET::GetTypeID();
|
||||||
return static_cast<AssetContainer<ASSET>*>(GetBase(typeID));
|
return static_cast<AssetContainer<ASSET>*>(GetAssetContainer(typeID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AssetContainer for a given Asset type
|
||||||
|
*
|
||||||
|
* \tparam ASSET The Asset type
|
||||||
|
* \return The AssetContainer for the Asset type. Nullptr if not found
|
||||||
|
*/
|
||||||
template<class ASSET>
|
template<class ASSET>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
const AssetContainer<ASSET>* Get() const
|
const AssetContainer<ASSET>* GetAssetContainer() const
|
||||||
{
|
{
|
||||||
static const AssetTypeID typeID = ASSET::GetTypeID();
|
static const AssetTypeID typeID = ASSET::GetTypeID();
|
||||||
return static_cast<const AssetContainer<ASSET>*>(GetBase(typeID));
|
return static_cast<const AssetContainer<ASSET>*>(GetAssetContainer(typeID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AssetContainer for a given AssetType
|
||||||
|
*
|
||||||
|
* \param p_typeID The asset type ID
|
||||||
|
* \return The AssetContainer for the AssetType. Nullptr if not found
|
||||||
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
AssetContainerBase* GetBase(const AssetTypeID p_typeID)
|
AssetContainerBase* GetAssetContainer(const AssetTypeID p_typeID)
|
||||||
{
|
{
|
||||||
if (const auto container = m_assetContainers.find(p_typeID); container != m_assetContainers.end())
|
if (const auto container = m_assetContainers.find(p_typeID); container != m_assetContainers.end())
|
||||||
{
|
{
|
||||||
@@ -65,8 +90,14 @@ class AssetLibrary
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AssetContainer for a given AssetType
|
||||||
|
*
|
||||||
|
* \param p_typeID The asset type ID
|
||||||
|
* \return The AssetContainer for the AssetType. Nullptr if not found
|
||||||
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
const AssetContainerBase* GetBase(const AssetTypeID p_typeID) const
|
const AssetContainerBase* GetAssetContainer(const AssetTypeID p_typeID) const
|
||||||
{
|
{
|
||||||
if (const auto container = m_assetContainers.find(p_typeID); container != m_assetContainers.end())
|
if (const auto container = m_assetContainers.find(p_typeID); container != m_assetContainers.end())
|
||||||
{
|
{
|
||||||
@@ -76,12 +107,18 @@ class AssetLibrary
|
|||||||
return nullptr;
|
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]]
|
[[nodiscard]]
|
||||||
AssetContainerBase* FindContainer(const UUID& p_uuid)
|
AssetContainerBase* FindAssetContainerContainerForUUID(const UUID& p_uuid)
|
||||||
{
|
{
|
||||||
for (const auto& [typeID, container]: m_assetContainers)
|
for (const auto& [typeID, container]: m_assetContainers)
|
||||||
{
|
{
|
||||||
if (container->GetAssetSlotKey(p_uuid).Valid())
|
if (container->Has(p_uuid))
|
||||||
{
|
{
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
@@ -90,12 +127,18 @@ class AssetLibrary
|
|||||||
return nullptr;
|
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]]
|
[[nodiscard]]
|
||||||
const AssetContainerBase* FindContainer(const UUID& p_uuid) const
|
const AssetContainerBase* FindAssetContainerContainerForUUID(const UUID& p_uuid) const
|
||||||
{
|
{
|
||||||
for (const auto& [typeID, container]: m_assetContainers)
|
for (const auto& [typeID, container]: m_assetContainers)
|
||||||
{
|
{
|
||||||
if (container->GetAssetSlotKey(p_uuid).Valid())
|
if (container->Has(p_uuid))
|
||||||
{
|
{
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
@@ -108,10 +151,44 @@ class AssetLibrary
|
|||||||
AssetLibrary& operator=(AssetLibrary&& p_library) = default;
|
AssetLibrary& operator=(AssetLibrary&& p_library) = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// All the asset containers
|
||||||
ankerl::unordered_dense::segmented_map<AssetTypeID, AssetContainerBase*> m_assetContainers;
|
ankerl::unordered_dense::segmented_map<AssetTypeID, AssetContainerBase*> m_assetContainers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
// The global asset library for Bigfoot
|
||||||
inline AssetLibrary g_assetLibrary;
|
inline AssetLibrary g_assetLibrary;
|
||||||
|
inline AssetLibrary* g_activeAssetLibrary = &g_assetLibrary;
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
class ScopedActiveAssetLibrary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScopedActiveAssetLibrary(AssetLibrary* p_assetLibrary):
|
||||||
|
m_previous(g_activeAssetLibrary)
|
||||||
|
{
|
||||||
|
g_activeAssetLibrary = p_assetLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedActiveAssetLibrary(const ScopedActiveAssetLibrary& p_scopedActiveAssetLibrary) = default;
|
||||||
|
ScopedActiveAssetLibrary(ScopedActiveAssetLibrary&& p_scopedActiveAssetLibrary) = default;
|
||||||
|
|
||||||
|
~ScopedActiveAssetLibrary()
|
||||||
|
{
|
||||||
|
g_activeAssetLibrary = m_previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedActiveAssetLibrary& operator=(const ScopedActiveAssetLibrary& p_scopedActiveAssetLibrary) = default;
|
||||||
|
ScopedActiveAssetLibrary& operator=(ScopedActiveAssetLibrary&& p_scopedActiveAssetLibrary) = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*
|
||||||
|
* The previously active asset library.
|
||||||
|
*/
|
||||||
|
AssetLibrary* m_previous = nullptr;
|
||||||
|
};
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,13 +13,3 @@ struct SoftReference (bigfoot_ref_wrapper: "::Bigfoot::SoftReference")
|
|||||||
{
|
{
|
||||||
uuid: UUID;
|
uuid: UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AnyHardReference (native_type: "::Bigfoot::AnyHardReference")
|
|
||||||
{
|
|
||||||
uuid: UUID;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AnySoftReference (native_type: "::Bigfoot::AnySoftReference")
|
|
||||||
{
|
|
||||||
uuid: UUID;
|
|
||||||
}
|
|
||||||
@@ -49,7 +49,13 @@ class HardReference
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ASSET* Get() const
|
const ASSET* Get() const
|
||||||
|
{
|
||||||
|
return m_handle ? static_cast<const ASSET*>(m_handle->GetAsset()) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
ASSET* Get()
|
||||||
{
|
{
|
||||||
return m_handle ? static_cast<ASSET*>(m_handle->GetAsset()) : nullptr;
|
return m_handle ? static_cast<ASSET*>(m_handle->GetAsset()) : nullptr;
|
||||||
}
|
}
|
||||||
@@ -91,14 +97,28 @@ class HardReference
|
|||||||
private:
|
private:
|
||||||
void Acquire()
|
void Acquire()
|
||||||
{
|
{
|
||||||
if (AssetContainerBase* assetContainer = g_assetLibrary.GetBase(GetAssetTypeID<ASSET>());
|
if (!m_uuid)
|
||||||
assetContainer && m_uuid)
|
{
|
||||||
|
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 (!m_handle)
|
if (!m_handle)
|
||||||
{
|
{
|
||||||
m_handle = &assetContainer->AcquireHandle(m_uuid);
|
m_handle = &assetContainer->AcquireContainerHandle(m_uuid);
|
||||||
}
|
}
|
||||||
m_handle->IncrementHardRefCount();
|
m_handle->IncrementSoftRefCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +167,13 @@ class SoftReference
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ASSET* Get() const
|
const ASSET* Get() const
|
||||||
|
{
|
||||||
|
return m_handle ? static_cast<const ASSET*>(m_handle->GetAsset()) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
ASSET* Get()
|
||||||
{
|
{
|
||||||
return m_handle ? static_cast<ASSET*>(m_handle->GetAsset()) : nullptr;
|
return m_handle ? static_cast<ASSET*>(m_handle->GetAsset()) : nullptr;
|
||||||
}
|
}
|
||||||
@@ -189,192 +215,26 @@ class SoftReference
|
|||||||
private:
|
private:
|
||||||
void Acquire()
|
void Acquire()
|
||||||
{
|
{
|
||||||
if (AssetContainerBase* assetContainer = g_assetLibrary.GetBase(GetAssetTypeID<ASSET>());
|
if (!m_uuid)
|
||||||
assetContainer && m_uuid)
|
{
|
||||||
|
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 (!m_handle)
|
if (!m_handle)
|
||||||
{
|
{
|
||||||
m_handle = &assetContainer->AcquireHandle(m_uuid);
|
m_handle = &assetContainer->AcquireContainerHandle(m_uuid);
|
||||||
}
|
|
||||||
m_handle->IncrementSoftRefCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Release()
|
|
||||||
{
|
|
||||||
if (m_handle)
|
|
||||||
{
|
|
||||||
m_handle->DecrementSoftRefCount();
|
|
||||||
m_handle = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UUID m_uuid = UUID::NULL_UUID;
|
|
||||||
ContainerHandle* m_handle = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AnyHardReference
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AnyHardReference() = default;
|
|
||||||
|
|
||||||
AnyHardReference(const UUID& p_uuid):
|
|
||||||
m_uuid(p_uuid)
|
|
||||||
{
|
|
||||||
Acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
AnyHardReference(const AnyHardReference& p_ref):
|
|
||||||
m_uuid(p_ref.m_uuid),
|
|
||||||
m_handle(p_ref.m_handle)
|
|
||||||
{
|
|
||||||
Acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
AnyHardReference(AnyHardReference&& p_ref) noexcept:
|
|
||||||
m_uuid(std::exchange(p_ref.m_uuid, UUID::NULL_UUID)),
|
|
||||||
m_handle(std::exchange(p_ref.m_handle, nullptr))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
const UUID& GetUUID() const
|
|
||||||
{
|
|
||||||
return m_uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
~AnyHardReference()
|
|
||||||
{
|
|
||||||
Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
AnyHardReference& operator=(const AnyHardReference& p_ref)
|
|
||||||
{
|
|
||||||
if (this != &p_ref)
|
|
||||||
{
|
|
||||||
Release();
|
|
||||||
m_uuid = p_ref.m_uuid;
|
|
||||||
m_handle = p_ref.m_handle;
|
|
||||||
Acquire();
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
AnyHardReference& operator=(AnyHardReference&& p_ref) noexcept
|
|
||||||
{
|
|
||||||
if (this != &p_ref)
|
|
||||||
{
|
|
||||||
Release();
|
|
||||||
m_uuid = std::exchange(p_ref.m_uuid, UUID::NULL_UUID);
|
|
||||||
m_handle = std::exchange(p_ref.m_handle, nullptr);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
bool operator==(const AnyHardReference& p_ref) const
|
|
||||||
{
|
|
||||||
return m_uuid == p_ref.m_uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Acquire()
|
|
||||||
{
|
|
||||||
if (AssetContainerBase* assetContainer = g_assetLibrary.FindContainer(m_uuid); assetContainer && m_uuid)
|
|
||||||
{
|
|
||||||
if (!m_handle)
|
|
||||||
{
|
|
||||||
m_handle = &assetContainer->AcquireHandle(m_uuid);
|
|
||||||
}
|
|
||||||
m_handle->IncrementHardRefCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Release()
|
|
||||||
{
|
|
||||||
if (m_handle)
|
|
||||||
{
|
|
||||||
m_handle->DecrementHardRefCount();
|
|
||||||
m_handle = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UUID m_uuid = UUID::NULL_UUID;
|
|
||||||
ContainerHandle* m_handle = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AnySoftReference
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AnySoftReference() = default;
|
|
||||||
|
|
||||||
AnySoftReference(const UUID& p_uuid):
|
|
||||||
m_uuid(p_uuid)
|
|
||||||
{
|
|
||||||
Acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
AnySoftReference(const AnySoftReference& p_ref):
|
|
||||||
m_uuid(p_ref.m_uuid),
|
|
||||||
m_handle(p_ref.m_handle)
|
|
||||||
{
|
|
||||||
Acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
AnySoftReference(AnySoftReference&& p_ref) noexcept:
|
|
||||||
m_uuid(std::exchange(p_ref.m_uuid, UUID::NULL_UUID)),
|
|
||||||
m_handle(std::exchange(p_ref.m_handle, nullptr))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
const UUID& GetUUID() const
|
|
||||||
{
|
|
||||||
return m_uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
~AnySoftReference()
|
|
||||||
{
|
|
||||||
Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
AnySoftReference& operator=(const AnySoftReference& p_ref)
|
|
||||||
{
|
|
||||||
if (this != &p_ref)
|
|
||||||
{
|
|
||||||
Release();
|
|
||||||
m_uuid = p_ref.m_uuid;
|
|
||||||
m_handle = p_ref.m_handle;
|
|
||||||
Acquire();
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
AnySoftReference& operator=(AnySoftReference&& p_ref) noexcept
|
|
||||||
{
|
|
||||||
if (this != &p_ref)
|
|
||||||
{
|
|
||||||
Release();
|
|
||||||
m_uuid = std::exchange(p_ref.m_uuid, UUID::NULL_UUID);
|
|
||||||
m_handle = std::exchange(p_ref.m_handle, nullptr);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
bool operator==(const AnySoftReference& p_ref) const
|
|
||||||
{
|
|
||||||
return m_uuid == p_ref.m_uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Acquire()
|
|
||||||
{
|
|
||||||
if (AssetContainerBase* assetContainer = g_assetLibrary.FindContainer(m_uuid); assetContainer && m_uuid)
|
|
||||||
{
|
|
||||||
if (!m_handle)
|
|
||||||
{
|
|
||||||
m_handle = &assetContainer->AcquireHandle(m_uuid);
|
|
||||||
}
|
}
|
||||||
m_handle->IncrementSoftRefCount();
|
m_handle->IncrementSoftRefCount();
|
||||||
}
|
}
|
||||||
@@ -393,27 +253,4 @@ class AnySoftReference
|
|||||||
ContainerHandle* m_handle = nullptr;
|
ContainerHandle* m_handle = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
namespace Flat
|
|
||||||
{
|
|
||||||
namespace Bigfoot
|
|
||||||
{
|
|
||||||
struct AnyHardReference;
|
|
||||||
struct AnySoftReference;
|
|
||||||
} // namespace Bigfoot
|
|
||||||
} // namespace Flat
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
namespace flatbuffers
|
|
||||||
{
|
|
||||||
Flat::Bigfoot::AnyHardReference Pack(const ::Bigfoot::AnyHardReference& p_ref);
|
|
||||||
::Bigfoot::AnyHardReference UnPack(const Flat::Bigfoot::AnyHardReference& p_ref);
|
|
||||||
|
|
||||||
Flat::Bigfoot::AnySoftReference Pack(const ::Bigfoot::AnySoftReference& p_ref);
|
|
||||||
::Bigfoot::AnySoftReference UnPack(const Flat::Bigfoot::AnySoftReference& p_ref);
|
|
||||||
} // namespace flatbuffers
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -35,18 +35,10 @@ struct HardReference;
|
|||||||
|
|
||||||
struct SoftReference;
|
struct SoftReference;
|
||||||
|
|
||||||
struct AnyHardReference;
|
|
||||||
|
|
||||||
struct AnySoftReference;
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *HardReferenceTypeTable();
|
inline const ::flatbuffers::TypeTable *HardReferenceTypeTable();
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *SoftReferenceTypeTable();
|
inline const ::flatbuffers::TypeTable *SoftReferenceTypeTable();
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *AnyHardReferenceTypeTable();
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *AnySoftReferenceTypeTable();
|
|
||||||
|
|
||||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) HardReference FLATBUFFERS_FINAL_CLASS {
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) HardReference FLATBUFFERS_FINAL_CLASS {
|
||||||
private:
|
private:
|
||||||
Flat::Bigfoot::UUID uuid_;
|
Flat::Bigfoot::UUID uuid_;
|
||||||
@@ -103,62 +95,6 @@ struct SoftReference::Traits {
|
|||||||
using type = SoftReference;
|
using type = SoftReference;
|
||||||
};
|
};
|
||||||
|
|
||||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) AnyHardReference FLATBUFFERS_FINAL_CLASS {
|
|
||||||
private:
|
|
||||||
Flat::Bigfoot::UUID uuid_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
struct Traits;
|
|
||||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
|
||||||
return AnyHardReferenceTypeTable();
|
|
||||||
}
|
|
||||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
|
||||||
return "Flat.Bigfoot.AnyHardReference";
|
|
||||||
}
|
|
||||||
AnyHardReference()
|
|
||||||
: uuid_() {
|
|
||||||
}
|
|
||||||
AnyHardReference(const Flat::Bigfoot::UUID &_uuid)
|
|
||||||
: uuid_(_uuid) {
|
|
||||||
}
|
|
||||||
const Flat::Bigfoot::UUID &uuid() const {
|
|
||||||
return uuid_;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
FLATBUFFERS_STRUCT_END(AnyHardReference, 16);
|
|
||||||
|
|
||||||
struct AnyHardReference::Traits {
|
|
||||||
using type = AnyHardReference;
|
|
||||||
};
|
|
||||||
|
|
||||||
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) AnySoftReference FLATBUFFERS_FINAL_CLASS {
|
|
||||||
private:
|
|
||||||
Flat::Bigfoot::UUID uuid_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
struct Traits;
|
|
||||||
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
|
||||||
return AnySoftReferenceTypeTable();
|
|
||||||
}
|
|
||||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
|
||||||
return "Flat.Bigfoot.AnySoftReference";
|
|
||||||
}
|
|
||||||
AnySoftReference()
|
|
||||||
: uuid_() {
|
|
||||||
}
|
|
||||||
AnySoftReference(const Flat::Bigfoot::UUID &_uuid)
|
|
||||||
: uuid_(_uuid) {
|
|
||||||
}
|
|
||||||
const Flat::Bigfoot::UUID &uuid() const {
|
|
||||||
return uuid_;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
FLATBUFFERS_STRUCT_END(AnySoftReference, 16);
|
|
||||||
|
|
||||||
struct AnySoftReference::Traits {
|
|
||||||
using type = AnySoftReference;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *HardReferenceTypeTable() {
|
inline const ::flatbuffers::TypeTable *HardReferenceTypeTable() {
|
||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||||
@@ -187,34 +123,6 @@ inline const ::flatbuffers::TypeTable *SoftReferenceTypeTable() {
|
|||||||
return &tt;
|
return &tt;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *AnyHardReferenceTypeTable() {
|
|
||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
|
||||||
Flat::Bigfoot::UUIDTypeTable
|
|
||||||
};
|
|
||||||
static const int64_t values[] = { 0, 16 };
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
|
||||||
::flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, nullptr
|
|
||||||
};
|
|
||||||
return &tt;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *AnySoftReferenceTypeTable() {
|
|
||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
|
||||||
Flat::Bigfoot::UUIDTypeTable
|
|
||||||
};
|
|
||||||
static const int64_t values[] = { 0, 16 };
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
|
||||||
::flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, nullptr
|
|
||||||
};
|
|
||||||
return &tt;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
} // namespace Flat
|
} // namespace Flat
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetContainer.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/Asset/AssetContainer.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetA.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class AssetContainerFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
AssetContainer<AssetA> m_containerA;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Has_ShouldReturnTrueIfTheContainerHasTheAsset)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
std::ignore = m_containerA.Insert(asset1);
|
||||||
|
EXPECT_TRUE(m_containerA.Has(asset1.GetHeader().uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Has_ShouldReturnFalseIfTheContainerDoesNotHaveTheAsset)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
EXPECT_FALSE(m_containerA.Has(asset1.GetHeader().uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, AcquireHandle_ShouldReturnTheAssociatedContainerHandle)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
std::ignore = m_containerA.Insert(asset1);
|
||||||
|
|
||||||
|
const ContainerHandle& handle = m_containerA.AcquireContainerHandle(asset1.GetHeader().uuid);
|
||||||
|
EXPECT_EQ(static_cast<const AssetA*>(handle.GetAsset())->GetHeader().uuid, asset1.GetHeader().uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, AcquireHandle_ShouldCreateTheAssociatedContainerHandleIfItDoesNotExists)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
|
||||||
|
const ContainerHandle& handle = m_containerA.AcquireContainerHandle(asset1.GetHeader().uuid);
|
||||||
|
EXPECT_EQ(handle.GetAsset(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Insert_ShouldReturnValidAndUniqueSlotKeyOnInsert)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
const SlotMapKey slotKey = m_containerA.Insert(asset1);
|
||||||
|
EXPECT_TRUE(slotKey.Valid());
|
||||||
|
EXPECT_NE(slotKey, m_containerA.Insert());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Insert_ShouldReturnTheSameSlotKeyInCaseOfDuplicatedUUID)
|
||||||
|
{
|
||||||
|
AssetA asset;
|
||||||
|
const SlotMapKey slotKey = m_containerA.Insert(asset);
|
||||||
|
EXPECT_EQ(slotKey, m_containerA.Insert(asset));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Get_ShouldReturnTheAssetWithTheSlotKey)
|
||||||
|
{
|
||||||
|
AssetA asset;
|
||||||
|
const SlotMapKey slotKey = m_containerA.Insert(asset);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_containerA.Get(slotKey)->GetHeader().uuid, asset.GetHeader().uuid);
|
||||||
|
EXPECT_EQ(const_cast<const AssetContainer<AssetA>&>(m_containerA).Get(slotKey)->GetHeader().uuid,
|
||||||
|
asset.GetHeader().uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Get_ShouldReturnNullptrIfSlotKeyNotInContainer)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(m_containerA.Get(SlotMapKey {1, 0}), nullptr);
|
||||||
|
EXPECT_EQ(const_cast<const AssetContainer<AssetA>&>(m_containerA).Get(SlotMapKey {1, 0}), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Remove_ShouldRemoveTheAsset)
|
||||||
|
{
|
||||||
|
AssetA asset;
|
||||||
|
const SlotMapKey slotKey = m_containerA.Insert(asset);
|
||||||
|
|
||||||
|
m_containerA.Remove(asset.GetHeader().uuid);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_containerA.Get(slotKey), nullptr);
|
||||||
|
EXPECT_FALSE(m_containerA.Has(asset.GetHeader().uuid));
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetLibrary.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/Asset/AssetLibrary.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetA.hpp>
|
||||||
|
#include <AssetsForTesting/Asset/AssetB.hpp>
|
||||||
|
#include <AssetsForTesting/Asset/AssetC.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class AssetLibraryFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
AssetContainer<AssetA> m_containerA;
|
||||||
|
AssetContainer<AssetB> m_containerB;
|
||||||
|
AssetContainer<AssetC> m_containerC;
|
||||||
|
|
||||||
|
AssetLibrary m_library;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, Insert_ShouldReturnTrueOnSuccess)
|
||||||
|
{
|
||||||
|
EXPECT_TRUE(m_library.Insert(&m_containerA));
|
||||||
|
EXPECT_TRUE(m_library.Insert(&m_containerB));
|
||||||
|
EXPECT_TRUE(m_library.Insert(&m_containerC));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, Insert_ShouldReturnFalseOnDuplicate)
|
||||||
|
{
|
||||||
|
std::ignore = m_library.Insert(&m_containerA);
|
||||||
|
EXPECT_FALSE(m_library.Insert(&m_containerA));
|
||||||
|
|
||||||
|
AssetContainer<AssetA> m_containerAA;
|
||||||
|
EXPECT_FALSE(m_library.Insert(&m_containerAA));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, GetAssetContainer_ShouldReturnTheAssetContainerIfAvailable)
|
||||||
|
{
|
||||||
|
std::ignore = m_library.Insert(&m_containerA);
|
||||||
|
std::ignore = m_library.Insert(&m_containerB);
|
||||||
|
std::ignore = m_library.Insert(&m_containerC);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer<AssetA>(), &m_containerA);
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetA>()), &m_containerA);
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer<AssetB>(), &m_containerB);
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetB>()), &m_containerB);
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer<AssetC>(), &m_containerC);
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetC>()), &m_containerC);
|
||||||
|
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).GetAssetContainer<AssetA>(), &m_containerA);
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).GetAssetContainer(GetAssetTypeID<AssetA>()), &m_containerA);
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).GetAssetContainer<AssetB>(), &m_containerB);
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).GetAssetContainer(GetAssetTypeID<AssetB>()), &m_containerB);
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).GetAssetContainer<AssetC>(), &m_containerC);
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).GetAssetContainer(GetAssetTypeID<AssetC>()), &m_containerC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, GetAssetContainer_ShouldReturnNullptrIfTheContainerDoesNotExist)
|
||||||
|
{
|
||||||
|
std::ignore = m_library.Insert(&m_containerB);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer<AssetA>(), nullptr);
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetA>()), nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).GetAssetContainer<AssetA>(), nullptr);
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).GetAssetContainer(GetAssetTypeID<AssetA>()), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
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(const_cast<const AssetLibrary&>(m_library).FindAssetContainerContainerForUUID(uuidA), &m_containerA);
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(m_library).FindAssetContainerContainerForUUID(uuidB), &m_containerB);
|
||||||
|
EXPECT_EQ(const_cast<const AssetLibrary&>(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(const_cast<const AssetLibrary&>(m_library).FindAssetContainerContainerForUUID(UUID {}), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, ScopedActiveAssetLibrary_ShouldChangeTheActiveAssetLibraryInAScopedWay)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(g_activeAssetLibrary, &g_assetLibrary);
|
||||||
|
{
|
||||||
|
ScopedActiveAssetLibrary activeAssetLibraryScoped {&m_library};
|
||||||
|
EXPECT_EQ(g_activeAssetLibrary, &m_library);
|
||||||
|
}
|
||||||
|
EXPECT_EQ(g_activeAssetLibrary, &g_assetLibrary);
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -27,12 +27,12 @@ class AssetA: public Asset<AssetATraits>
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetA(const AssetA& p_asset) = delete;
|
AssetA(const AssetA& p_asset) = default;
|
||||||
AssetA(AssetA&& p_asset) = default;
|
AssetA(AssetA&& p_asset) = default;
|
||||||
|
|
||||||
~AssetA() = default;
|
~AssetA() = default;
|
||||||
|
|
||||||
AssetA& operator=(const AssetA& p_asset) = delete;
|
AssetA& operator=(const AssetA& p_asset) = default;
|
||||||
AssetA& operator=(AssetA&& p_asset) = default;
|
AssetA& operator=(AssetA&& p_asset) = default;
|
||||||
};
|
};
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ table InnerTable
|
|||||||
asset_a_ref: HardReference (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
asset_a_ref: HardReference (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
||||||
asset_a_refs: [HardReference] (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
asset_a_refs: [HardReference] (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
||||||
|
|
||||||
any_asset: AnyHardReference (native_inline);
|
any_asset: HardReference (native_inline, bigfoot_ref: "::Bigfoot::AssetBase");
|
||||||
any_assets: [AnySoftReference] (native_inline);
|
any_assets: [SoftReference] (native_inline, bigfoot_ref: "::Bigfoot::AssetBase");
|
||||||
}
|
}
|
||||||
|
|
||||||
table AssetC
|
table AssetC
|
||||||
|
|||||||
+36
-19
@@ -46,6 +46,10 @@ namespace Bigfoot {
|
|||||||
class AssetA;
|
class AssetA;
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
namespace Bigfoot {
|
||||||
|
class AssetBase;
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
namespace Bigfoot {
|
namespace Bigfoot {
|
||||||
class AssetB;
|
class AssetB;
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
@@ -53,6 +57,10 @@ class AssetB;
|
|||||||
namespace flatbuffers {
|
namespace flatbuffers {
|
||||||
Flat::Bigfoot::HardReference PackHardReferenceAssetA(const ::Bigfoot::HardReference<::Bigfoot::AssetA>& p_asset);
|
Flat::Bigfoot::HardReference PackHardReferenceAssetA(const ::Bigfoot::HardReference<::Bigfoot::AssetA>& p_asset);
|
||||||
::Bigfoot::HardReference<::Bigfoot::AssetA> UnPackHardReferenceAssetA(const Flat::Bigfoot::HardReference& p_asset);
|
::Bigfoot::HardReference<::Bigfoot::AssetA> UnPackHardReferenceAssetA(const Flat::Bigfoot::HardReference& p_asset);
|
||||||
|
Flat::Bigfoot::HardReference PackHardReferenceAssetBase(const ::Bigfoot::HardReference<::Bigfoot::AssetBase>& p_asset);
|
||||||
|
::Bigfoot::HardReference<::Bigfoot::AssetBase> UnPackHardReferenceAssetBase(const Flat::Bigfoot::HardReference& p_asset);
|
||||||
|
Flat::Bigfoot::SoftReference PackSoftReferenceAssetBase(const ::Bigfoot::SoftReference<::Bigfoot::AssetBase>& p_asset);
|
||||||
|
::Bigfoot::SoftReference<::Bigfoot::AssetBase> UnPackSoftReferenceAssetBase(const Flat::Bigfoot::SoftReference& p_asset);
|
||||||
Flat::Bigfoot::HardReference PackHardReferenceAssetB(const ::Bigfoot::HardReference<::Bigfoot::AssetB>& p_asset);
|
Flat::Bigfoot::HardReference PackHardReferenceAssetB(const ::Bigfoot::HardReference<::Bigfoot::AssetB>& p_asset);
|
||||||
::Bigfoot::HardReference<::Bigfoot::AssetB> UnPackHardReferenceAssetB(const Flat::Bigfoot::HardReference& p_asset);
|
::Bigfoot::HardReference<::Bigfoot::AssetB> UnPackHardReferenceAssetB(const Flat::Bigfoot::HardReference& p_asset);
|
||||||
Flat::Bigfoot::SoftReference PackSoftReferenceAssetB(const ::Bigfoot::SoftReference<::Bigfoot::AssetB>& p_asset);
|
Flat::Bigfoot::SoftReference PackSoftReferenceAssetB(const ::Bigfoot::SoftReference<::Bigfoot::AssetB>& p_asset);
|
||||||
@@ -73,8 +81,8 @@ struct InnerTableT : public ::flatbuffers::NativeTable {
|
|||||||
}
|
}
|
||||||
::Bigfoot::HardReference<::Bigfoot::AssetA> asset_a_ref{};
|
::Bigfoot::HardReference<::Bigfoot::AssetA> asset_a_ref{};
|
||||||
eastl::vector<::Bigfoot::HardReference<::Bigfoot::AssetA>> asset_a_refs{};
|
eastl::vector<::Bigfoot::HardReference<::Bigfoot::AssetA>> asset_a_refs{};
|
||||||
::Bigfoot::AnyHardReference any_asset{};
|
::Bigfoot::HardReference<::Bigfoot::AssetBase> any_asset{};
|
||||||
eastl::vector<::Bigfoot::AnySoftReference> any_assets{};
|
eastl::vector<::Bigfoot::SoftReference<::Bigfoot::AssetBase>> any_assets{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InnerTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
struct InnerTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
@@ -99,11 +107,11 @@ struct InnerTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
const ::flatbuffers::Vector<const Flat::Bigfoot::HardReference *> *asset_a_refs() const {
|
const ::flatbuffers::Vector<const Flat::Bigfoot::HardReference *> *asset_a_refs() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<const Flat::Bigfoot::HardReference *> *>(VT_ASSET_A_REFS);
|
return GetPointer<const ::flatbuffers::Vector<const Flat::Bigfoot::HardReference *> *>(VT_ASSET_A_REFS);
|
||||||
}
|
}
|
||||||
const Flat::Bigfoot::AnyHardReference *any_asset() const {
|
const Flat::Bigfoot::HardReference *any_asset() const {
|
||||||
return GetStruct<const Flat::Bigfoot::AnyHardReference *>(VT_ANY_ASSET);
|
return GetStruct<const Flat::Bigfoot::HardReference *>(VT_ANY_ASSET);
|
||||||
}
|
}
|
||||||
const ::flatbuffers::Vector<const Flat::Bigfoot::AnySoftReference *> *any_assets() const {
|
const ::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *> *any_assets() const {
|
||||||
return GetPointer<const ::flatbuffers::Vector<const Flat::Bigfoot::AnySoftReference *> *>(VT_ANY_ASSETS);
|
return GetPointer<const ::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *> *>(VT_ANY_ASSETS);
|
||||||
}
|
}
|
||||||
template <bool B = false>
|
template <bool B = false>
|
||||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
@@ -111,7 +119,7 @@ struct InnerTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
|||||||
VerifyField<Flat::Bigfoot::HardReference>(verifier, VT_ASSET_A_REF, 1) &&
|
VerifyField<Flat::Bigfoot::HardReference>(verifier, VT_ASSET_A_REF, 1) &&
|
||||||
VerifyOffset(verifier, VT_ASSET_A_REFS) &&
|
VerifyOffset(verifier, VT_ASSET_A_REFS) &&
|
||||||
verifier.VerifyVector(asset_a_refs()) &&
|
verifier.VerifyVector(asset_a_refs()) &&
|
||||||
VerifyField<Flat::Bigfoot::AnyHardReference>(verifier, VT_ANY_ASSET, 1) &&
|
VerifyField<Flat::Bigfoot::HardReference>(verifier, VT_ANY_ASSET, 1) &&
|
||||||
VerifyOffset(verifier, VT_ANY_ASSETS) &&
|
VerifyOffset(verifier, VT_ANY_ASSETS) &&
|
||||||
verifier.VerifyVector(any_assets()) &&
|
verifier.VerifyVector(any_assets()) &&
|
||||||
verifier.EndTable();
|
verifier.EndTable();
|
||||||
@@ -131,10 +139,10 @@ struct InnerTableBuilder {
|
|||||||
void add_asset_a_refs(::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::HardReference *>> asset_a_refs) {
|
void add_asset_a_refs(::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::HardReference *>> asset_a_refs) {
|
||||||
fbb_.AddOffset(InnerTable::VT_ASSET_A_REFS, asset_a_refs);
|
fbb_.AddOffset(InnerTable::VT_ASSET_A_REFS, asset_a_refs);
|
||||||
}
|
}
|
||||||
void add_any_asset(const Flat::Bigfoot::AnyHardReference *any_asset) {
|
void add_any_asset(const Flat::Bigfoot::HardReference *any_asset) {
|
||||||
fbb_.AddStruct(InnerTable::VT_ANY_ASSET, any_asset);
|
fbb_.AddStruct(InnerTable::VT_ANY_ASSET, any_asset);
|
||||||
}
|
}
|
||||||
void add_any_assets(::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::AnySoftReference *>> any_assets) {
|
void add_any_assets(::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *>> any_assets) {
|
||||||
fbb_.AddOffset(InnerTable::VT_ANY_ASSETS, any_assets);
|
fbb_.AddOffset(InnerTable::VT_ANY_ASSETS, any_assets);
|
||||||
}
|
}
|
||||||
explicit InnerTableBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
explicit InnerTableBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
@@ -152,8 +160,8 @@ inline ::flatbuffers::Offset<InnerTable> CreateInnerTable(
|
|||||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
const Flat::Bigfoot::HardReference *asset_a_ref = nullptr,
|
const Flat::Bigfoot::HardReference *asset_a_ref = nullptr,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::HardReference *>> asset_a_refs = 0,
|
::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::HardReference *>> asset_a_refs = 0,
|
||||||
const Flat::Bigfoot::AnyHardReference *any_asset = nullptr,
|
const Flat::Bigfoot::HardReference *any_asset = nullptr,
|
||||||
::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::AnySoftReference *>> any_assets = 0) {
|
::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *>> any_assets = 0) {
|
||||||
InnerTableBuilder builder_(_fbb);
|
InnerTableBuilder builder_(_fbb);
|
||||||
builder_.add_any_assets(any_assets);
|
builder_.add_any_assets(any_assets);
|
||||||
builder_.add_any_asset(any_asset);
|
builder_.add_any_asset(any_asset);
|
||||||
@@ -277,8 +285,8 @@ inline void InnerTable::UnPackTo(InnerTableT *_o, const ::flatbuffers::resolver_
|
|||||||
(void)_resolver;
|
(void)_resolver;
|
||||||
{ auto _e = asset_a_ref(); if (_e) _o->asset_a_ref = ::flatbuffers::UnPackHardReferenceAssetA(*_e); }
|
{ auto _e = asset_a_ref(); if (_e) _o->asset_a_ref = ::flatbuffers::UnPackHardReferenceAssetA(*_e); }
|
||||||
{ auto _e = asset_a_refs(); if (_e) { _o->asset_a_refs.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->asset_a_refs[_i] = ::flatbuffers::UnPackHardReferenceAssetA(*_e->Get(_i)); } } else { _o->asset_a_refs.resize(0); } }
|
{ auto _e = asset_a_refs(); if (_e) { _o->asset_a_refs.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->asset_a_refs[_i] = ::flatbuffers::UnPackHardReferenceAssetA(*_e->Get(_i)); } } else { _o->asset_a_refs.resize(0); } }
|
||||||
{ auto _e = any_asset(); if (_e) _o->any_asset = ::flatbuffers::UnPack(*_e); }
|
{ auto _e = any_asset(); if (_e) _o->any_asset = ::flatbuffers::UnPackHardReferenceAssetBase(*_e); }
|
||||||
{ auto _e = any_assets(); if (_e) { _o->any_assets.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->any_assets[_i] = ::flatbuffers::UnPack(*_e->Get(_i)); } } else { _o->any_assets.resize(0); } }
|
{ auto _e = any_assets(); if (_e) { _o->any_assets.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->any_assets[_i] = ::flatbuffers::UnPackSoftReferenceAssetBase(*_e->Get(_i)); } } else { _o->any_assets.resize(0); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::flatbuffers::Offset<InnerTable> CreateInnerTable(::flatbuffers::FlatBufferBuilder &_fbb, const InnerTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
inline ::flatbuffers::Offset<InnerTable> CreateInnerTable(::flatbuffers::FlatBufferBuilder &_fbb, const InnerTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
@@ -291,8 +299,8 @@ inline ::flatbuffers::Offset<InnerTable> InnerTable::Pack(::flatbuffers::FlatBuf
|
|||||||
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const InnerTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const InnerTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
auto _asset_a_ref = ::flatbuffers::PackHardReferenceAssetA(_o->asset_a_ref);
|
auto _asset_a_ref = ::flatbuffers::PackHardReferenceAssetA(_o->asset_a_ref);
|
||||||
auto _asset_a_refs = _fbb.CreateVectorOfNativeStructs<Flat::Bigfoot::HardReference, ::Bigfoot::HardReference<::Bigfoot::AssetA>>(_o->asset_a_refs.data(), _o->asset_a_refs.size(), ::flatbuffers::PackHardReferenceAssetA);
|
auto _asset_a_refs = _fbb.CreateVectorOfNativeStructs<Flat::Bigfoot::HardReference, ::Bigfoot::HardReference<::Bigfoot::AssetA>>(_o->asset_a_refs.data(), _o->asset_a_refs.size(), ::flatbuffers::PackHardReferenceAssetA);
|
||||||
auto _any_asset = ::flatbuffers::Pack(_o->any_asset);
|
auto _any_asset = ::flatbuffers::PackHardReferenceAssetBase(_o->any_asset);
|
||||||
auto _any_assets = _fbb.CreateVectorOfNativeStructs<Flat::Bigfoot::AnySoftReference, ::Bigfoot::AnySoftReference>(_o->any_assets.data(), _o->any_assets.size());
|
auto _any_assets = _fbb.CreateVectorOfNativeStructs<Flat::Bigfoot::SoftReference, ::Bigfoot::SoftReference<::Bigfoot::AssetBase>>(_o->any_assets.data(), _o->any_assets.size(), ::flatbuffers::PackSoftReferenceAssetBase);
|
||||||
return Flat::Bigfoot::CreateInnerTable(
|
return Flat::Bigfoot::CreateInnerTable(
|
||||||
_fbb,
|
_fbb,
|
||||||
&_asset_a_ref,
|
&_asset_a_ref,
|
||||||
@@ -350,13 +358,12 @@ inline const ::flatbuffers::TypeTable *InnerTableTypeTable() {
|
|||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 1, 0 },
|
{ ::flatbuffers::ET_SEQUENCE, 1, 0 },
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 1 },
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 1, 2 }
|
{ ::flatbuffers::ET_SEQUENCE, 1, 1 }
|
||||||
};
|
};
|
||||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
Flat::Bigfoot::HardReferenceTypeTable,
|
Flat::Bigfoot::HardReferenceTypeTable,
|
||||||
Flat::Bigfoot::AnyHardReferenceTypeTable,
|
Flat::Bigfoot::SoftReferenceTypeTable
|
||||||
Flat::Bigfoot::AnySoftReferenceTypeTable
|
|
||||||
};
|
};
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
::flatbuffers::ST_TABLE, 4, type_codes, type_refs, nullptr, nullptr, nullptr
|
::flatbuffers::ST_TABLE, 4, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
@@ -438,6 +445,16 @@ namespace flatbuffers {
|
|||||||
inline Flat::Bigfoot::HardReference PackHardReferenceAssetA(const ::Bigfoot::HardReference<::Bigfoot::AssetA>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
inline Flat::Bigfoot::HardReference PackHardReferenceAssetA(const ::Bigfoot::HardReference<::Bigfoot::AssetA>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
inline ::Bigfoot::HardReference<::Bigfoot::AssetA> UnPackHardReferenceAssetA(const Flat::Bigfoot::HardReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
inline ::Bigfoot::HardReference<::Bigfoot::AssetA> UnPackHardReferenceAssetA(const Flat::Bigfoot::HardReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
#endif // FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETA
|
#endif // FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETA
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETBASE
|
||||||
|
#define FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETBASE
|
||||||
|
inline Flat::Bigfoot::HardReference PackHardReferenceAssetBase(const ::Bigfoot::HardReference<::Bigfoot::AssetBase>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
inline ::Bigfoot::HardReference<::Bigfoot::AssetBase> UnPackHardReferenceAssetBase(const Flat::Bigfoot::HardReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
|
#endif // FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETBASE
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETBASE
|
||||||
|
#define FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETBASE
|
||||||
|
inline Flat::Bigfoot::SoftReference PackSoftReferenceAssetBase(const ::Bigfoot::SoftReference<::Bigfoot::AssetBase>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
inline ::Bigfoot::SoftReference<::Bigfoot::AssetBase> UnPackSoftReferenceAssetBase(const Flat::Bigfoot::SoftReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
|
#endif // FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETBASE
|
||||||
#ifndef FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETB
|
#ifndef FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETB
|
||||||
#define FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETB
|
#define FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETB
|
||||||
inline Flat::Bigfoot::HardReference PackHardReferenceAssetB(const ::Bigfoot::HardReference<::Bigfoot::AssetB>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
inline Flat::Bigfoot::HardReference PackHardReferenceAssetB(const ::Bigfoot::HardReference<::Bigfoot::AssetB>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
|||||||
Reference in New Issue
Block a user