diff --git a/Bigfoot/Sources/Engine/Include/Engine/BigFile/Asset/AssetContainer.hpp b/Bigfoot/Sources/Engine/Include/Engine/BigFile/Asset/AssetContainer.hpp index 667aa22..89e03bd 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/BigFile/Asset/AssetContainer.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/BigFile/Asset/AssetContainer.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Bigfoot { @@ -29,48 +29,46 @@ class AssetContainer AssetContainer(AssetContainer&& p_container) = delete; [[nodiscard]] - bool Add(const UUID& p_uuid, const eastl::string_view p_name) + bool Add(const UUID& p_uuid) { - FlatAssetWrapper flatAsset {}; - flatAsset.Asset().asset_header->uuid = p_uuid; - flatAsset.Asset().asset_header->name = p_name; - - return Add(p_uuid, flatAsset.Pack()); + return m_assets.emplace(p_uuid, AssetHandle {}).second; } [[nodiscard]] - bool Add(const UUID& p_uuid, const eastl::span p_flatBuffer) + bool Load(const UUID& p_uuid, const eastl::span p_flatBuffer) { - const auto& added = m_assets.emplace(p_uuid, eastl::make_unique(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(p_flatBuffer); CRITICAL_ASSERT(EngineAssertHandler, - !added.second || added.first->second->m_flatAsset.Asset().asset_header->uuid == p_uuid, - "Added ASSET UUID does not match !"); + assetHandle.m_assetPair->m_flatAsset.Asset().asset_header->uuid == p_uuid, + "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]] - ASSET* Get(const UUID& p_uuid) + void UnloadUnreferenced() { - return m_assets.contains(p_uuid) ? &m_assets.at_key(p_uuid)->m_asset : nullptr; - } - - [[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 Pack(const UUID& p_uuid) const - { - return m_assets.contains(p_uuid) ? m_assets.at_key(p_uuid)->m_flatAsset.Pack() : eastl::vector {}; + for (auto& keyValue: m_assets) + { + if (keyValue.second.m_hardRefCount == 0 && keyValue.second.m_assetPair) + { + keyValue.second.m_assetPair.reset(); + } + } } ~AssetContainer() = default; @@ -79,19 +77,38 @@ class AssetContainer AssetContainer& operator=(AssetContainer&& p_container) = delete; private: - struct AssetFlatAssetWrapperPair + struct AssetHandle { - AssetFlatAssetWrapperPair(const eastl::span p_flatbuffer): - m_flatAsset(p_flatbuffer), - m_asset(&m_flatAsset) + struct Data { - } + Data(const eastl::span p_flatBuffer): + m_flatAsset(p_flatBuffer), + m_asset(&m_flatAsset) + { + } - FlatAssetWrapper m_flatAsset; - ASSET m_asset; + FlatAssetWrapper m_flatAsset; + ASSET m_asset; + }; + + eastl::unique_ptr m_assetPair = nullptr; + + std::uint32_t m_hardRefCount = 0; + std::uint32_t m_softRefCount = 0; }; - eastl::vector_map> m_assets; + // We use a segmented_map here to keep stable references + ankerl::unordered_dense::segmented_map m_assets; +}; + +template +class HardRef +{ +}; + +template +class SoftRef +{ }; } // namespace Bigfoot diff --git a/Bigfoot/Tests/Engine/BigFile/BigFile.cpp b/Bigfoot/Tests/Engine/BigFile/BigFile.cpp index 0604aae..0284633 100644 --- a/Bigfoot/Tests/Engine/BigFile/BigFile.cpp +++ b/Bigfoot/Tests/Engine/BigFile/BigFile.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -38,6 +38,7 @@ class BigFileFixture: public ::testing::Test } AssetAContainer m_assetAContainer; + AssetBContainer m_assetBContainer; BIGFOOT_NOT_OPTIMIZED_ONLY(Singleton::Lifetime m_loggerLifetime;) @@ -55,30 +56,42 @@ TEST_F(BigFileFixture, Lol) FlatAssetWrapper::TypeName().size())); UUID uuid; - std::ignore = m_assetAContainer.Add(uuid, "Instance"); + std::ignore = m_assetAContainer.Add(uuid); - AssetA* test = m_assetAContainer.Get(uuid); + FlatAssetWrapper test {}; + test.Asset().asset_header->name = "Instance"; + test.Asset().asset_header->uuid = uuid; - test->Health() = 100; - test->Mana() = 42; + const eastl::vector flatBuffer = test.Pack(); - const eastl::vector flatbuffer = m_assetAContainer.Pack(uuid); - m_assetAContainer.Remove(uuid); + std::ignore = m_assetAContainer.Load(uuid, flatBuffer); + m_assetAContainer.UnloadUnreferenced(); - std::ignore = m_assetAContainer.Add(uuid, flatbuffer); - std::ignore = m_assetAContainer.Add(UUID {}, "Instance2"); - std::ignore = m_assetAContainer.Add(UUID {}, "Instance3"); + // UUID uuid; + // std::ignore = m_assetAContainer.Add(uuid, "Instance"); - AssetA* test2 = m_assetAContainer.Get(uuid); + // AssetA* test = m_assetAContainer.Get(uuid); - EXPECT_EQ(test2->Health(), 100); - EXPECT_EQ(test2->Mana(), 42); + // test->Health() = 100; + // test->Mana() = 42; - EXPECT_STREQ(test2->AssetHeader()->name.c_str(), "Instance"); - EXPECT_EQ(test2->AssetHeader()->type_id, FlatAssetWrapper::TypeID()); - EXPECT_STREQ(test2->AssetHeader()->type_name.c_str(), FlatAssetWrapper::TypeName().data()); - EXPECT_EQ(test2->AssetHeader()->uuid, uuid); - EXPECT_EQ(test2->AssetHeader()->version, 2); + // const eastl::vector flatbuffer = m_assetAContainer.Pack(uuid); + // m_assetAContainer.Remove(uuid); + + // std::ignore = m_assetAContainer.Add(uuid, flatbuffer); + // 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::TypeID()); + // EXPECT_STREQ(test2->AssetHeader()->type_name.c_str(), FlatAssetWrapper::TypeName().data()); + // EXPECT_EQ(test2->AssetHeader()->uuid, uuid); + // EXPECT_EQ(test2->AssetHeader()->version, 2); } UUID uuid; diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetA.fbs b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetA.fbs index 930a130..05e85ab 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetA.fbs +++ b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetA.fbs @@ -2,6 +2,16 @@ include "Engine/BigFile/Asset/AssetHeader.fbs"; 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 { asset_header: AssetHeader; diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetA_generated.hpp b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetA_generated.hpp index e693171..d56a00b 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetA_generated.hpp +++ b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetA_generated.hpp @@ -24,12 +24,76 @@ static_assert(FLATBUFFERS_VERSION_MAJOR == 25 && namespace Bigfoot { namespace Flat { +struct AssetAHardRef; + +struct AssetASoftRef; + struct AssetA; struct AssetABuilder; struct AssetAT; +inline const ::flatbuffers::TypeTable *AssetAHardRefTypeTable(); + +inline const ::flatbuffers::TypeTable *AssetASoftRefTypeTable(); + 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 { typedef AssetA TableType; static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { @@ -170,6 +234,40 @@ inline ::flatbuffers::Offset AssetA::Pack(::flatbuffers::FlatBufferBuild _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() { static const ::flatbuffers::TypeCode type_codes[] = { { ::flatbuffers::ET_SEQUENCE, 0, 0 }, diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB.fbs b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB.fbs new file mode 100644 index 0000000..f35db17 --- /dev/null +++ b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB.fbs @@ -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; \ No newline at end of file diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB.hpp b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB.hpp new file mode 100644 index 0000000..863f058 --- /dev/null +++ b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB.hpp @@ -0,0 +1,59 @@ +/********************************************************************* + * \file AssetB.hpp + * + * \author Romain BOULLARD + * \date February 2026 + *********************************************************************/ +#ifndef BIGFOOT_ENGINETESTS_ASSETB_HPP +#define BIGFOOT_ENGINETESTS_ASSETB_HPP +#include + +#include +#include + +namespace Bigfoot +{ +class AssetB +{ + public: + using FLAT_ASSET = Flat::AssetB; + + AssetB(FlatAssetWrapper* p_flatAsset): + m_flatAsset(p_flatAsset) + { + } + + AssetB(const AssetB& p_assetB) = default; + AssetB(AssetB&& p_assetB) = default; + + [[nodiscard]] + HardRef 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* m_flatAsset; +}; + +using AssetBContainer = AssetContainer; +} // namespace Bigfoot + +#endif diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB_generated.hpp b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB_generated.hpp new file mode 100644 index 0000000..282bfec --- /dev/null +++ b/Bigfoot/Tests/Engine/Include/EngineTests/BigFile/Asset/AssetB_generated.hpp @@ -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 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(VT_ASSET_HEADER); + } + const Bigfoot::Flat::AssetAHardRef *asset_a_hard_ref() const { + return GetStruct(VT_ASSET_A_HARD_REF); + } + template + bool Verify(::flatbuffers::VerifierTemplate &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_ASSET_HEADER) && + verifier.VerifyTable(asset_header()) && + VerifyField(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 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 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 Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateAssetB( + ::flatbuffers::FlatBufferBuilder &_fbb, + ::flatbuffers::Offset 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 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(); + 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(_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 CreateAssetB(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) { + return AssetB::Pack(_fbb, _o, _rehasher); +} + +inline ::flatbuffers::Offset 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(buf); +} + +inline const Bigfoot::Flat::AssetB *GetSizePrefixedAssetB(const void *buf) { + return ::flatbuffers::GetSizePrefixedRoot(buf); +} + +template +inline bool VerifyAssetBBuffer( + ::flatbuffers::VerifierTemplate &verifier) { + return verifier.template VerifyBuffer(nullptr); +} + +template +inline bool VerifySizePrefixedAssetBBuffer( + ::flatbuffers::VerifierTemplate &verifier) { + return verifier.template VerifySizePrefixedBuffer(nullptr); +} + +inline void FinishAssetBBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.Finish(root); +} + +inline void FinishSizePrefixedAssetBBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); +} + +inline eastl::unique_ptr UnPackAssetB( + const void *buf, + const ::flatbuffers::resolver_function_t *res = nullptr) { + return eastl::unique_ptr(GetAssetB(buf)->UnPack(res)); +} + +inline eastl::unique_ptr UnPackSizePrefixedAssetB( + const void *buf, + const ::flatbuffers::resolver_function_t *res = nullptr) { + return eastl::unique_ptr(GetSizePrefixedAssetB(buf)->UnPack(res)); +} + +} // namespace Flat +} // namespace Bigfoot + +#endif // FLATBUFFERS_GENERATED_ASSETB_BIGFOOT_FLAT_H_ diff --git a/CMake/Package.cmake b/CMake/Package.cmake index ed86db9..e9e5ef3 100644 --- a/CMake/Package.cmake +++ b/CMake/Package.cmake @@ -41,6 +41,8 @@ function(bigfoot_create_package_tests ParentFolder BigfootDependencies) add_executable(${PROJECT_NAME}) set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) + target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Include) + bigfoot_compile_flatbuffers("${BigfootDependencies}") 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_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 $) target_link_libraries(${PROJECT_NAME} PRIVATE gtest::gtest)