Rework AssetContainer; adding references
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
#include <Engine/BigFile/Asset/Asset.hpp>
|
#include <Engine/BigFile/Asset/Asset.hpp>
|
||||||
#include <Engine/EngineAssertHandler.hpp>
|
#include <Engine/EngineAssertHandler.hpp>
|
||||||
|
|
||||||
#include <eastl/vector_map.h>
|
#include <ankerl/unordered_dense.h>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
@@ -29,48 +29,46 @@ class AssetContainer
|
|||||||
AssetContainer(AssetContainer&& p_container) = delete;
|
AssetContainer(AssetContainer&& p_container) = delete;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool Add(const UUID& p_uuid, const eastl::string_view p_name)
|
bool Add(const UUID& p_uuid)
|
||||||
{
|
{
|
||||||
FlatAssetWrapper<typename ASSET::FLAT_ASSET> flatAsset {};
|
return m_assets.emplace(p_uuid, AssetHandle {}).second;
|
||||||
flatAsset.Asset().asset_header->uuid = p_uuid;
|
|
||||||
flatAsset.Asset().asset_header->name = p_name;
|
|
||||||
|
|
||||||
return Add(p_uuid, flatAsset.Pack());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool Add(const UUID& p_uuid, const eastl::span<const std::byte> p_flatBuffer)
|
bool Load(const UUID& p_uuid, const eastl::span<const std::byte> p_flatBuffer)
|
||||||
{
|
{
|
||||||
const auto& added = m_assets.emplace(p_uuid, eastl::make_unique<AssetFlatAssetWrapperPair>(p_flatBuffer));
|
if (!m_assets.contains(p_uuid))
|
||||||
|
{
|
||||||
|
const bool added = Add(p_uuid);
|
||||||
|
ASSERT(EngineAssertHandler, added, "{} not added to AssetContainer! Already in container ?", p_uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetHandle& assetHandle = m_assets.at(p_uuid);
|
||||||
|
if (assetHandle.m_assetPair)
|
||||||
|
{
|
||||||
|
SOFT_ASSERT(EngineAssertHandler, false, "{} already loaded!", p_uuid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assetHandle.m_assetPair = eastl::make_unique<AssetHandle::Data>(p_flatBuffer);
|
||||||
CRITICAL_ASSERT(EngineAssertHandler,
|
CRITICAL_ASSERT(EngineAssertHandler,
|
||||||
!added.second || added.first->second->m_flatAsset.Asset().asset_header->uuid == p_uuid,
|
assetHandle.m_assetPair->m_flatAsset.Asset().asset_header->uuid == p_uuid,
|
||||||
"Added ASSET UUID does not match !");
|
"Mismatch between expected UUID and deserialized UUID ! Got {}; Expected {}",
|
||||||
|
assetHandle.m_assetPair->m_flatAsset.Asset().asset_header->uuid,
|
||||||
|
p_uuid);
|
||||||
|
|
||||||
return added.second;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
void UnloadUnreferenced()
|
||||||
ASSET* Get(const UUID& p_uuid)
|
|
||||||
{
|
{
|
||||||
return m_assets.contains(p_uuid) ? &m_assets.at_key(p_uuid)->m_asset : nullptr;
|
for (auto& keyValue: m_assets)
|
||||||
|
{
|
||||||
|
if (keyValue.second.m_hardRefCount == 0 && keyValue.second.m_assetPair)
|
||||||
|
{
|
||||||
|
keyValue.second.m_assetPair.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
const ASSET* Get(const UUID& p_uuid) const
|
|
||||||
{
|
|
||||||
return m_assets.contains(p_uuid) ? &m_assets.at_key(p_uuid)->m_asset : nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Remove(const UUID& p_uuid)
|
|
||||||
{
|
|
||||||
m_assets.erase(p_uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
eastl::vector<std::byte> Pack(const UUID& p_uuid) const
|
|
||||||
{
|
|
||||||
return m_assets.contains(p_uuid) ? m_assets.at_key(p_uuid)->m_flatAsset.Pack() : eastl::vector<std::byte> {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~AssetContainer() = default;
|
~AssetContainer() = default;
|
||||||
@@ -79,10 +77,12 @@ class AssetContainer
|
|||||||
AssetContainer& operator=(AssetContainer&& p_container) = delete;
|
AssetContainer& operator=(AssetContainer&& p_container) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct AssetFlatAssetWrapperPair
|
struct AssetHandle
|
||||||
{
|
{
|
||||||
AssetFlatAssetWrapperPair(const eastl::span<const std::byte> p_flatbuffer):
|
struct Data
|
||||||
m_flatAsset(p_flatbuffer),
|
{
|
||||||
|
Data(const eastl::span<const std::byte> p_flatBuffer):
|
||||||
|
m_flatAsset(p_flatBuffer),
|
||||||
m_asset(&m_flatAsset)
|
m_asset(&m_flatAsset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,24 @@ class AssetContainer
|
|||||||
ASSET m_asset;
|
ASSET m_asset;
|
||||||
};
|
};
|
||||||
|
|
||||||
eastl::vector_map<UUID, eastl::unique_ptr<AssetFlatAssetWrapperPair>> m_assets;
|
eastl::unique_ptr<Data> m_assetPair = nullptr;
|
||||||
|
|
||||||
|
std::uint32_t m_hardRefCount = 0;
|
||||||
|
std::uint32_t m_softRefCount = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// We use a segmented_map here to keep stable references
|
||||||
|
ankerl::unordered_dense::segmented_map<UUID, AssetHandle> m_assets;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<BigfootAssetConcept ASSET>
|
||||||
|
class HardRef
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template<BigfootAssetConcept ASSET>
|
||||||
|
class SoftRef
|
||||||
|
{
|
||||||
};
|
};
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include <Utils/TargetMacros.h>
|
#include <Utils/TargetMacros.h>
|
||||||
|
|
||||||
#include <EngineTests/BigFile/Asset/AssetA.hpp>
|
#include <EngineTests/BigFile/Asset/AssetA.hpp>
|
||||||
#include <EngineTests/BigFile/Asset/AssetA_generated.hpp>
|
#include <EngineTests/BigFile/Asset/AssetB.hpp>
|
||||||
#include <EngineTests/BigFileInfo_generated.hpp>
|
#include <EngineTests/BigFileInfo_generated.hpp>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -38,6 +38,7 @@ class BigFileFixture: public ::testing::Test
|
|||||||
}
|
}
|
||||||
|
|
||||||
AssetAContainer m_assetAContainer;
|
AssetAContainer m_assetAContainer;
|
||||||
|
AssetBContainer m_assetBContainer;
|
||||||
|
|
||||||
BIGFOOT_NOT_OPTIMIZED_ONLY(Singleton<Log>::Lifetime m_loggerLifetime;)
|
BIGFOOT_NOT_OPTIMIZED_ONLY(Singleton<Log>::Lifetime m_loggerLifetime;)
|
||||||
|
|
||||||
@@ -55,30 +56,42 @@ TEST_F(BigFileFixture, Lol)
|
|||||||
FlatAssetWrapper<Flat::AssetA>::TypeName().size()));
|
FlatAssetWrapper<Flat::AssetA>::TypeName().size()));
|
||||||
|
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
std::ignore = m_assetAContainer.Add(uuid, "Instance");
|
std::ignore = m_assetAContainer.Add(uuid);
|
||||||
|
|
||||||
AssetA* test = m_assetAContainer.Get(uuid);
|
FlatAssetWrapper<Flat::AssetA> test {};
|
||||||
|
test.Asset().asset_header->name = "Instance";
|
||||||
|
test.Asset().asset_header->uuid = uuid;
|
||||||
|
|
||||||
test->Health() = 100;
|
const eastl::vector<std::byte> flatBuffer = test.Pack();
|
||||||
test->Mana() = 42;
|
|
||||||
|
|
||||||
const eastl::vector<std::byte> flatbuffer = m_assetAContainer.Pack(uuid);
|
std::ignore = m_assetAContainer.Load(uuid, flatBuffer);
|
||||||
m_assetAContainer.Remove(uuid);
|
m_assetAContainer.UnloadUnreferenced();
|
||||||
|
|
||||||
std::ignore = m_assetAContainer.Add(uuid, flatbuffer);
|
// UUID uuid;
|
||||||
std::ignore = m_assetAContainer.Add(UUID {}, "Instance2");
|
// std::ignore = m_assetAContainer.Add(uuid, "Instance");
|
||||||
std::ignore = m_assetAContainer.Add(UUID {}, "Instance3");
|
|
||||||
|
|
||||||
AssetA* test2 = m_assetAContainer.Get(uuid);
|
// AssetA* test = m_assetAContainer.Get(uuid);
|
||||||
|
|
||||||
EXPECT_EQ(test2->Health(), 100);
|
// test->Health() = 100;
|
||||||
EXPECT_EQ(test2->Mana(), 42);
|
// test->Mana() = 42;
|
||||||
|
|
||||||
EXPECT_STREQ(test2->AssetHeader()->name.c_str(), "Instance");
|
// const eastl::vector<std::byte> flatbuffer = m_assetAContainer.Pack(uuid);
|
||||||
EXPECT_EQ(test2->AssetHeader()->type_id, FlatAssetWrapper<Flat::AssetA>::TypeID());
|
// m_assetAContainer.Remove(uuid);
|
||||||
EXPECT_STREQ(test2->AssetHeader()->type_name.c_str(), FlatAssetWrapper<Flat::AssetA>::TypeName().data());
|
|
||||||
EXPECT_EQ(test2->AssetHeader()->uuid, uuid);
|
// std::ignore = m_assetAContainer.Add(uuid, flatbuffer);
|
||||||
EXPECT_EQ(test2->AssetHeader()->version, 2);
|
// std::ignore = m_assetAContainer.Add(UUID {}, "Instance2");
|
||||||
|
// std::ignore = m_assetAContainer.Add(UUID {}, "Instance3");
|
||||||
|
|
||||||
|
// AssetA* test2 = m_assetAContainer.Get(uuid);
|
||||||
|
|
||||||
|
// EXPECT_EQ(test2->Health(), 100);
|
||||||
|
// EXPECT_EQ(test2->Mana(), 42);
|
||||||
|
|
||||||
|
// EXPECT_STREQ(test2->AssetHeader()->name.c_str(), "Instance");
|
||||||
|
// EXPECT_EQ(test2->AssetHeader()->type_id, FlatAssetWrapper<Flat::AssetA>::TypeID());
|
||||||
|
// EXPECT_STREQ(test2->AssetHeader()->type_name.c_str(), FlatAssetWrapper<Flat::AssetA>::TypeName().data());
|
||||||
|
// EXPECT_EQ(test2->AssetHeader()->uuid, uuid);
|
||||||
|
// EXPECT_EQ(test2->AssetHeader()->version, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
|
|||||||
@@ -2,6 +2,16 @@ include "Engine/BigFile/Asset/AssetHeader.fbs";
|
|||||||
|
|
||||||
namespace Bigfoot.Flat;
|
namespace Bigfoot.Flat;
|
||||||
|
|
||||||
|
struct AssetAHardRef (native_type: "::Bigfoot::HardRef<::Bigfoot::AssetA>")
|
||||||
|
{
|
||||||
|
uuid: UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetASoftRef (native_type: "::Bigfoot::SoftRef<::Bigfoot::AssetA>")
|
||||||
|
{
|
||||||
|
uuid: UUID;
|
||||||
|
}
|
||||||
|
|
||||||
table AssetA
|
table AssetA
|
||||||
{
|
{
|
||||||
asset_header: AssetHeader;
|
asset_header: AssetHeader;
|
||||||
|
|||||||
@@ -24,12 +24,76 @@ static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
|||||||
namespace Bigfoot {
|
namespace Bigfoot {
|
||||||
namespace Flat {
|
namespace Flat {
|
||||||
|
|
||||||
|
struct AssetAHardRef;
|
||||||
|
|
||||||
|
struct AssetASoftRef;
|
||||||
|
|
||||||
struct AssetA;
|
struct AssetA;
|
||||||
struct AssetABuilder;
|
struct AssetABuilder;
|
||||||
struct AssetAT;
|
struct AssetAT;
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetAHardRefTypeTable();
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetASoftRefTypeTable();
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *AssetATypeTable();
|
inline const ::flatbuffers::TypeTable *AssetATypeTable();
|
||||||
|
|
||||||
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) AssetAHardRef FLATBUFFERS_FINAL_CLASS {
|
||||||
|
private:
|
||||||
|
Bigfoot::Flat::UUID uuid_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetAHardRefTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Bigfoot.Flat.AssetAHardRef";
|
||||||
|
}
|
||||||
|
AssetAHardRef()
|
||||||
|
: uuid_() {
|
||||||
|
}
|
||||||
|
AssetAHardRef(const Bigfoot::Flat::UUID &_uuid)
|
||||||
|
: uuid_(_uuid) {
|
||||||
|
}
|
||||||
|
const Bigfoot::Flat::UUID &uuid() const {
|
||||||
|
return uuid_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FLATBUFFERS_STRUCT_END(AssetAHardRef, 16);
|
||||||
|
|
||||||
|
struct AssetAHardRef::Traits {
|
||||||
|
using type = AssetAHardRef;
|
||||||
|
};
|
||||||
|
|
||||||
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) AssetASoftRef FLATBUFFERS_FINAL_CLASS {
|
||||||
|
private:
|
||||||
|
Bigfoot::Flat::UUID uuid_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetASoftRefTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Bigfoot.Flat.AssetASoftRef";
|
||||||
|
}
|
||||||
|
AssetASoftRef()
|
||||||
|
: uuid_() {
|
||||||
|
}
|
||||||
|
AssetASoftRef(const Bigfoot::Flat::UUID &_uuid)
|
||||||
|
: uuid_(_uuid) {
|
||||||
|
}
|
||||||
|
const Bigfoot::Flat::UUID &uuid() const {
|
||||||
|
return uuid_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FLATBUFFERS_STRUCT_END(AssetASoftRef, 16);
|
||||||
|
|
||||||
|
struct AssetASoftRef::Traits {
|
||||||
|
using type = AssetASoftRef;
|
||||||
|
};
|
||||||
|
|
||||||
struct AssetAT : public ::flatbuffers::NativeTable {
|
struct AssetAT : public ::flatbuffers::NativeTable {
|
||||||
typedef AssetA TableType;
|
typedef AssetA TableType;
|
||||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
@@ -170,6 +234,40 @@ inline ::flatbuffers::Offset<AssetA> AssetA::Pack(::flatbuffers::FlatBufferBuild
|
|||||||
_mana);
|
_mana);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetAHardRefTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Bigfoot::Flat::UUIDTypeTable
|
||||||
|
};
|
||||||
|
static const int64_t values[] = { 0, 16 };
|
||||||
|
static const char * const names[] = {
|
||||||
|
"uuid"
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetASoftRefTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Bigfoot::Flat::UUIDTypeTable
|
||||||
|
};
|
||||||
|
static const int64_t values[] = { 0, 16 };
|
||||||
|
static const char * const names[] = {
|
||||||
|
"uuid"
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
inline const ::flatbuffers::TypeTable *AssetATypeTable() {
|
inline const ::flatbuffers::TypeTable *AssetATypeTable() {
|
||||||
static const ::flatbuffers::TypeCode type_codes[] = {
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
include "EngineTests/BigFile/Asset/AssetA.fbs";
|
||||||
|
|
||||||
|
namespace Bigfoot.Flat;
|
||||||
|
|
||||||
|
struct AssetBHardRef (native_type: "::Bigfoot::HardRef<::Bigfoot::AssetB>")
|
||||||
|
{
|
||||||
|
uuid: UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetBSoftRef (native_type: "::Bigfoot::SoftRef<::Bigfoot::AssetB>")
|
||||||
|
{
|
||||||
|
uuid: UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
table AssetB
|
||||||
|
{
|
||||||
|
asset_header: AssetHeader;
|
||||||
|
|
||||||
|
asset_a_hard_ref: AssetAHardRef (native_inline);
|
||||||
|
}
|
||||||
|
|
||||||
|
root_type AssetB;
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetB.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date February 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINETESTS_ASSETB_HPP
|
||||||
|
#define BIGFOOT_ENGINETESTS_ASSETB_HPP
|
||||||
|
#include <Engine/BigFile/Asset/AssetContainer.hpp>
|
||||||
|
|
||||||
|
#include <EngineTests/BigFile/Asset/AssetA.hpp>
|
||||||
|
#include <EngineTests/BigFile/Asset/AssetB_generated.hpp>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class AssetB
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using FLAT_ASSET = Flat::AssetB;
|
||||||
|
|
||||||
|
AssetB(FlatAssetWrapper<Flat::AssetB>* p_flatAsset):
|
||||||
|
m_flatAsset(p_flatAsset)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetB(const AssetB& p_assetB) = default;
|
||||||
|
AssetB(AssetB&& p_assetB) = default;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
HardRef<AssetA> Health()
|
||||||
|
{
|
||||||
|
return m_flatAsset->Asset().asset_a_hard_ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
Flat::AssetHeaderT* AssetHeader()
|
||||||
|
{
|
||||||
|
return m_flatAsset->Asset().asset_header.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
const Flat::AssetHeaderT* AssetHeader() const
|
||||||
|
{
|
||||||
|
return m_flatAsset->Asset().asset_header.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
~AssetB() = default;
|
||||||
|
|
||||||
|
AssetB& operator=(const AssetB& p_assetB) = default;
|
||||||
|
AssetB& operator=(AssetB&& p_assetB) = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FlatAssetWrapper<Flat::AssetB>* m_flatAsset;
|
||||||
|
};
|
||||||
|
|
||||||
|
using AssetBContainer = AssetContainer<AssetB>;
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,321 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_ASSETB_BIGFOOT_FLAT_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_ASSETB_BIGFOOT_FLAT_H_
|
||||||
|
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
|
||||||
|
#include "Engine/BigFile/Asset/AssetTypeID.hpp"
|
||||||
|
#include "Engine/BigFile/Asset/AssetTypeID.hpp"
|
||||||
|
#include "System/UUID/UUID.hpp"
|
||||||
|
#include "EngineTests/BigFile/Asset/AssetA_generated.hpp"
|
||||||
|
|
||||||
|
#include "EASTL/unique_ptr.h"
|
||||||
|
#include "EASTL/string.h"
|
||||||
|
|
||||||
|
namespace Bigfoot {
|
||||||
|
namespace Flat {
|
||||||
|
|
||||||
|
struct AssetBHardRef;
|
||||||
|
|
||||||
|
struct AssetBSoftRef;
|
||||||
|
|
||||||
|
struct AssetB;
|
||||||
|
struct AssetBBuilder;
|
||||||
|
struct AssetBT;
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetBHardRefTypeTable();
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetBSoftRefTypeTable();
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetBTypeTable();
|
||||||
|
|
||||||
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) AssetBHardRef FLATBUFFERS_FINAL_CLASS {
|
||||||
|
private:
|
||||||
|
Bigfoot::Flat::UUID uuid_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetBHardRefTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Bigfoot.Flat.AssetBHardRef";
|
||||||
|
}
|
||||||
|
AssetBHardRef()
|
||||||
|
: uuid_() {
|
||||||
|
}
|
||||||
|
AssetBHardRef(const Bigfoot::Flat::UUID &_uuid)
|
||||||
|
: uuid_(_uuid) {
|
||||||
|
}
|
||||||
|
const Bigfoot::Flat::UUID &uuid() const {
|
||||||
|
return uuid_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FLATBUFFERS_STRUCT_END(AssetBHardRef, 16);
|
||||||
|
|
||||||
|
struct AssetBHardRef::Traits {
|
||||||
|
using type = AssetBHardRef;
|
||||||
|
};
|
||||||
|
|
||||||
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) AssetBSoftRef FLATBUFFERS_FINAL_CLASS {
|
||||||
|
private:
|
||||||
|
Bigfoot::Flat::UUID uuid_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetBSoftRefTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Bigfoot.Flat.AssetBSoftRef";
|
||||||
|
}
|
||||||
|
AssetBSoftRef()
|
||||||
|
: uuid_() {
|
||||||
|
}
|
||||||
|
AssetBSoftRef(const Bigfoot::Flat::UUID &_uuid)
|
||||||
|
: uuid_(_uuid) {
|
||||||
|
}
|
||||||
|
const Bigfoot::Flat::UUID &uuid() const {
|
||||||
|
return uuid_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FLATBUFFERS_STRUCT_END(AssetBSoftRef, 16);
|
||||||
|
|
||||||
|
struct AssetBSoftRef::Traits {
|
||||||
|
using type = AssetBSoftRef;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetBT : public ::flatbuffers::NativeTable {
|
||||||
|
typedef AssetB TableType;
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Bigfoot.Flat.AssetBT";
|
||||||
|
}
|
||||||
|
eastl::unique_ptr<Bigfoot::Flat::AssetHeaderT> asset_header{};
|
||||||
|
::Bigfoot::HardRef<::Bigfoot::AssetA> asset_a_hard_ref{};
|
||||||
|
AssetBT() = default;
|
||||||
|
AssetBT(const AssetBT &o);
|
||||||
|
AssetBT(AssetBT&&) FLATBUFFERS_NOEXCEPT = default;
|
||||||
|
AssetBT &operator=(AssetBT o) FLATBUFFERS_NOEXCEPT;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetB FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef AssetBT NativeTableType;
|
||||||
|
typedef AssetBBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetBTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Bigfoot.Flat.AssetB";
|
||||||
|
}
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_ASSET_HEADER = 4,
|
||||||
|
VT_ASSET_A_HARD_REF = 6
|
||||||
|
};
|
||||||
|
const Bigfoot::Flat::AssetHeader *asset_header() const {
|
||||||
|
return GetPointer<const Bigfoot::Flat::AssetHeader *>(VT_ASSET_HEADER);
|
||||||
|
}
|
||||||
|
const Bigfoot::Flat::AssetAHardRef *asset_a_hard_ref() const {
|
||||||
|
return GetStruct<const Bigfoot::Flat::AssetAHardRef *>(VT_ASSET_A_HARD_REF);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyOffset(verifier, VT_ASSET_HEADER) &&
|
||||||
|
verifier.VerifyTable(asset_header()) &&
|
||||||
|
VerifyField<Bigfoot::Flat::AssetAHardRef>(verifier, VT_ASSET_A_HARD_REF, 1) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
AssetBT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
void UnPackTo(AssetBT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
static ::flatbuffers::Offset<AssetB> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetBBuilder {
|
||||||
|
typedef AssetB Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_asset_header(::flatbuffers::Offset<Bigfoot::Flat::AssetHeader> asset_header) {
|
||||||
|
fbb_.AddOffset(AssetB::VT_ASSET_HEADER, asset_header);
|
||||||
|
}
|
||||||
|
void add_asset_a_hard_ref(const Bigfoot::Flat::AssetAHardRef *asset_a_hard_ref) {
|
||||||
|
fbb_.AddStruct(AssetB::VT_ASSET_A_HARD_REF, asset_a_hard_ref);
|
||||||
|
}
|
||||||
|
explicit AssetBBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<AssetB> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<AssetB>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetB> CreateAssetB(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
::flatbuffers::Offset<Bigfoot::Flat::AssetHeader> asset_header = 0,
|
||||||
|
const Bigfoot::Flat::AssetAHardRef *asset_a_hard_ref = nullptr) {
|
||||||
|
AssetBBuilder builder_(_fbb);
|
||||||
|
builder_.add_asset_a_hard_ref(asset_a_hard_ref);
|
||||||
|
builder_.add_asset_header(asset_header);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetB::Traits {
|
||||||
|
using type = AssetB;
|
||||||
|
static auto constexpr Create = CreateAssetB;
|
||||||
|
};
|
||||||
|
|
||||||
|
::flatbuffers::Offset<AssetB> CreateAssetB(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
|
||||||
|
inline AssetBT::AssetBT(const AssetBT &o)
|
||||||
|
: asset_header((o.asset_header) ? new Bigfoot::Flat::AssetHeaderT(*o.asset_header) : nullptr),
|
||||||
|
asset_a_hard_ref(o.asset_a_hard_ref) {
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AssetBT &AssetBT::operator=(AssetBT o) FLATBUFFERS_NOEXCEPT {
|
||||||
|
std::swap(asset_header, o.asset_header);
|
||||||
|
std::swap(asset_a_hard_ref, o.asset_a_hard_ref);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AssetBT *AssetB::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
auto _o = std::make_unique<AssetBT>();
|
||||||
|
UnPackTo(_o.get(), _resolver);
|
||||||
|
return _o.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AssetB::UnPackTo(AssetBT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
(void)_o;
|
||||||
|
(void)_resolver;
|
||||||
|
{ auto _e = asset_header(); if (_e) { if(_o->asset_header) { _e->UnPackTo(_o->asset_header.get(), _resolver); } else { _o->asset_header = eastl::unique_ptr<Bigfoot::Flat::AssetHeaderT>(_e->UnPack(_resolver)); } } else if (_o->asset_header) { _o->asset_header.reset(); } }
|
||||||
|
{ auto _e = asset_a_hard_ref(); if (_e) _o->asset_a_hard_ref = ::flatbuffers::UnPack(*_e); }
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetB> CreateAssetB(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
return AssetB::Pack(_fbb, _o, _rehasher);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetB> AssetB::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
(void)_rehasher;
|
||||||
|
(void)_o;
|
||||||
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const AssetBT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
|
auto _asset_header = _o->asset_header ? CreateAssetHeader(_fbb, _o->asset_header.get(), _rehasher) : 0;
|
||||||
|
auto _asset_a_hard_ref = ::flatbuffers::Pack(_o->asset_a_hard_ref);
|
||||||
|
return Bigfoot::Flat::CreateAssetB(
|
||||||
|
_fbb,
|
||||||
|
_asset_header,
|
||||||
|
&_asset_a_hard_ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetBHardRefTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Bigfoot::Flat::UUIDTypeTable
|
||||||
|
};
|
||||||
|
static const int64_t values[] = { 0, 16 };
|
||||||
|
static const char * const names[] = {
|
||||||
|
"uuid"
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetBSoftRefTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Bigfoot::Flat::UUIDTypeTable
|
||||||
|
};
|
||||||
|
static const int64_t values[] = { 0, 16 };
|
||||||
|
static const char * const names[] = {
|
||||||
|
"uuid"
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, names
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetBTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 1 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Bigfoot::Flat::AssetHeaderTypeTable,
|
||||||
|
Bigfoot::Flat::AssetAHardRefTypeTable
|
||||||
|
};
|
||||||
|
static const char * const names[] = {
|
||||||
|
"asset_header",
|
||||||
|
"asset_a_hard_ref"
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_TABLE, 2, type_codes, type_refs, nullptr, nullptr, names
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Bigfoot::Flat::AssetB *GetAssetB(const void *buf) {
|
||||||
|
return ::flatbuffers::GetRoot<Bigfoot::Flat::AssetB>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Bigfoot::Flat::AssetB *GetSizePrefixedAssetB(const void *buf) {
|
||||||
|
return ::flatbuffers::GetSizePrefixedRoot<Bigfoot::Flat::AssetB>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifyAssetBBuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifyBuffer<Bigfoot::Flat::AssetB>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifySizePrefixedAssetBBuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifySizePrefixedBuffer<Bigfoot::Flat::AssetB>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishAssetBBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Bigfoot::Flat::AssetB> root) {
|
||||||
|
fbb.Finish(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishSizePrefixedAssetBBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Bigfoot::Flat::AssetB> root) {
|
||||||
|
fbb.FinishSizePrefixed(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Bigfoot::Flat::AssetBT> UnPackAssetB(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Bigfoot::Flat::AssetBT>(GetAssetB(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Bigfoot::Flat::AssetBT> UnPackSizePrefixedAssetB(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Bigfoot::Flat::AssetBT>(GetSizePrefixedAssetB(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Flat
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_ASSETB_BIGFOOT_FLAT_H_
|
||||||
@@ -41,6 +41,8 @@ function(bigfoot_create_package_tests ParentFolder BigfootDependencies)
|
|||||||
add_executable(${PROJECT_NAME})
|
add_executable(${PROJECT_NAME})
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
|
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Include)
|
||||||
|
|
||||||
bigfoot_compile_flatbuffers("${BigfootDependencies}")
|
bigfoot_compile_flatbuffers("${BigfootDependencies}")
|
||||||
|
|
||||||
file(GLOB_RECURSE _BF_TEST_SOURCES
|
file(GLOB_RECURSE _BF_TEST_SOURCES
|
||||||
@@ -60,8 +62,6 @@ function(bigfoot_create_package_tests ParentFolder BigfootDependencies)
|
|||||||
target_compile_options(${PROJECT_NAME} PRIVATE ${BIGFOOT_CXX_FLAGS})
|
target_compile_options(${PROJECT_NAME} PRIVATE ${BIGFOOT_CXX_FLAGS})
|
||||||
target_link_options(${PROJECT_NAME} PRIVATE ${BIGFOOT_EXE_LINK_FLAGS})
|
target_link_options(${PROJECT_NAME} PRIVATE ${BIGFOOT_EXE_LINK_FLAGS})
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Include)
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE $<LINK_LIBRARY:WHOLE_ARCHIVE,${PackageName}>)
|
target_link_libraries(${PROJECT_NAME} PRIVATE $<LINK_LIBRARY:WHOLE_ARCHIVE,${PackageName}>)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE gtest::gtest)
|
target_link_libraries(${PROJECT_NAME} PRIVATE gtest::gtest)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user