FlatAssetWrapper
All checks were successful
Bigfoot / Build & Test Debug (Unity Build: OFF) (push) Successful in 2m25s
Bigfoot / Build & Test Debug (Unity Build: ON) (push) Successful in 35s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: OFF) (push) Successful in 1m9s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: ON) (push) Successful in 1m3s
Bigfoot / Build & Test Release (Unity Build: OFF) (push) Successful in 1m3s
Bigfoot / Build & Test Release (Unity Build: ON) (push) Successful in 59s
Bigfoot / Clang Format Checks (push) Successful in 11s

This commit is contained in:
2026-02-10 17:52:07 +01:00
parent f5ad5adff6
commit 46c3034ea6
5 changed files with 142 additions and 19 deletions

View File

@@ -6,6 +6,8 @@
*********************************************************************/
#include <Engine/BigFile/BigFile.hpp>
#include <Engine/BigFile/Asset/Asset.hpp>
#include <System/Log/Log.hpp>
#include <System/Time/Time.hpp>
#include <System/UUID/UUID.hpp>
@@ -34,6 +36,8 @@ class BigFileFixture: public ::testing::Test
m_bigFile.CommitTransaction();
}
FlatAssetWrapper<Flat::AssetA> test;
BIGFOOT_NOT_OPTIMIZED_ONLY(Singleton<Log>::Lifetime m_loggerLifetime;)
BigFile m_bigFile {File {BIGFILE_ENGINETESTS_LOCATION}};
@@ -43,6 +47,31 @@ class BigFileFixture: public ::testing::Test
TEST_F(BigFileFixture, Lol)
{
{
UUID uuid;
test.Asset().health = 100;
test.Asset().mana = 42;
test.Asset().asset_header->name = "Instance";
test.Asset().asset_header->type_id = 1;
test.Asset().asset_header->type_name = "AssetA";
test.Asset().asset_header->uuid = uuid;
test.Asset().asset_header->version = 2;
const eastl::vector<std::byte> flatbuffer = test.Pack();
FlatAssetWrapper<Flat::AssetA> test2 {flatbuffer};
EXPECT_EQ(test2.Asset().health, 100);
EXPECT_EQ(test2.Asset().mana, 42);
EXPECT_STREQ(test2.Asset().asset_header->name.c_str(), "Instance");
EXPECT_EQ(test2.Asset().asset_header->type_id, 1);
EXPECT_STREQ(test2.Asset().asset_header->type_name.c_str(), "AssetA");
EXPECT_EQ(test2.Asset().asset_header->uuid, uuid);
EXPECT_EQ(test2.Asset().asset_header->version, 2);
}
UUID uuid;
UUID uuid2;

View File

@@ -7,7 +7,7 @@ table AssetA
asset_header: AssetHeader;
health: uint;
hp: uint;
mana: uint;
}
root_type AssetA;

View File

@@ -37,7 +37,7 @@ struct AssetAT : public ::flatbuffers::NativeTable {
}
eastl::unique_ptr<Bigfoot::Flat::AssetHeaderT> asset_header{};
uint32_t health = 0;
uint32_t hp = 0;
uint32_t mana = 0;
AssetAT() = default;
AssetAT(const AssetAT &o);
AssetAT(AssetAT&&) FLATBUFFERS_NOEXCEPT = default;
@@ -57,7 +57,7 @@ struct AssetA FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_ASSET_HEADER = 4,
VT_HEALTH = 6,
VT_HP = 8
VT_MANA = 8
};
const Bigfoot::Flat::AssetHeader *asset_header() const {
return GetPointer<const Bigfoot::Flat::AssetHeader *>(VT_ASSET_HEADER);
@@ -65,8 +65,8 @@ struct AssetA FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
uint32_t health() const {
return GetField<uint32_t>(VT_HEALTH, 0);
}
uint32_t hp() const {
return GetField<uint32_t>(VT_HP, 0);
uint32_t mana() const {
return GetField<uint32_t>(VT_MANA, 0);
}
template <bool B = false>
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
@@ -74,7 +74,7 @@ struct AssetA FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
VerifyOffset(verifier, VT_ASSET_HEADER) &&
verifier.VerifyTable(asset_header()) &&
VerifyField<uint32_t>(verifier, VT_HEALTH, 4) &&
VerifyField<uint32_t>(verifier, VT_HP, 4) &&
VerifyField<uint32_t>(verifier, VT_MANA, 4) &&
verifier.EndTable();
}
AssetAT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
@@ -92,8 +92,8 @@ struct AssetABuilder {
void add_health(uint32_t health) {
fbb_.AddElement<uint32_t>(AssetA::VT_HEALTH, health, 0);
}
void add_hp(uint32_t hp) {
fbb_.AddElement<uint32_t>(AssetA::VT_HP, hp, 0);
void add_mana(uint32_t mana) {
fbb_.AddElement<uint32_t>(AssetA::VT_MANA, mana, 0);
}
explicit AssetABuilder(::flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
@@ -110,9 +110,9 @@ inline ::flatbuffers::Offset<AssetA> CreateAssetA(
::flatbuffers::FlatBufferBuilder &_fbb,
::flatbuffers::Offset<Bigfoot::Flat::AssetHeader> asset_header = 0,
uint32_t health = 0,
uint32_t hp = 0) {
uint32_t mana = 0) {
AssetABuilder builder_(_fbb);
builder_.add_hp(hp);
builder_.add_mana(mana);
builder_.add_health(health);
builder_.add_asset_header(asset_header);
return builder_.Finish();
@@ -128,13 +128,13 @@ struct AssetA::Traits {
inline AssetAT::AssetAT(const AssetAT &o)
: asset_header((o.asset_header) ? new Bigfoot::Flat::AssetHeaderT(*o.asset_header) : nullptr),
health(o.health),
hp(o.hp) {
mana(o.mana) {
}
inline AssetAT &AssetAT::operator=(AssetAT o) FLATBUFFERS_NOEXCEPT {
std::swap(asset_header, o.asset_header);
std::swap(health, o.health);
std::swap(hp, o.hp);
std::swap(mana, o.mana);
return *this;
}
@@ -149,7 +149,7 @@ inline void AssetA::UnPackTo(AssetAT *_o, const ::flatbuffers::resolver_function
(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 = health(); _o->health = _e; }
{ auto _e = hp(); _o->hp = _e; }
{ auto _e = mana(); _o->mana = _e; }
}
inline ::flatbuffers::Offset<AssetA> CreateAssetA(::flatbuffers::FlatBufferBuilder &_fbb, const AssetAT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
@@ -162,12 +162,12 @@ inline ::flatbuffers::Offset<AssetA> AssetA::Pack(::flatbuffers::FlatBufferBuild
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const AssetAT* __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 _health = _o->health;
auto _hp = _o->hp;
auto _mana = _o->mana;
return Bigfoot::Flat::CreateAssetA(
_fbb,
_asset_header,
_health,
_hp);
_mana);
}
inline const ::flatbuffers::TypeTable *AssetATypeTable() {
@@ -182,7 +182,7 @@ inline const ::flatbuffers::TypeTable *AssetATypeTable() {
static const char * const names[] = {
"asset_header",
"health",
"hp"
"mana"
};
static const ::flatbuffers::TypeTable tt = {
::flatbuffers::ST_TABLE, 3, type_codes, type_refs, nullptr, nullptr, names