From 1b3c914037ce9811f2bce53843de76364089052a Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Sun, 26 Apr 2026 15:07:26 +0200 Subject: [PATCH] header manipulation --- .../Include/Engine/BigFile/Asset/Asset.hpp | 34 +++++++++++++++---- Bigfoot/Tests/Engine/BigFile/BigFile.cpp | 2 ++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Bigfoot/Sources/Engine/Include/Engine/BigFile/Asset/Asset.hpp b/Bigfoot/Sources/Engine/Include/Engine/BigFile/Asset/Asset.hpp index 1da3405..e0fe46d 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/BigFile/Asset/Asset.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/BigFile/Asset/Asset.hpp @@ -9,6 +9,7 @@ #include #include +#include namespace Bigfoot { @@ -16,7 +17,11 @@ template class Asset { public: - Asset() = default; + Asset() + { + m_header.type_id = GetTypeID(); + m_header.type_name = GetTypeName(); + } explicit Asset(const eastl::span p_flatbuffer): m_header(UnPackHeader(p_flatbuffer)), @@ -29,11 +34,6 @@ class Asset return m_header; } - Bigfoot::Flat::AssetHeaderT& GetHeader() - { - return m_header; - } - const typename FLAT_ASSET::NativeTableType& GetAsset() const { return m_asset; @@ -60,6 +60,28 @@ class Asset std::bit_cast(fullFbb.GetBufferPointer() + fullFbb.GetSize())}; } + void SetName(const eastl::string_view p_name) + { + m_header.name = p_name; + } + + void SetVersion(const std::uint32_t p_version) + { + m_header.version = p_version; + } + + static std::uint64_t GetTypeID() + { + static const std::uint64_t typeID = rapidhash(FLAT_ASSET::GetFullyQualifiedName(), + std::strlen(FLAT_ASSET::GetFullyQualifiedName())); + return typeID; + } + + static eastl::string_view GetTypeName() + { + return FLAT_ASSET::GetFullyQualifiedName(); + } + private: static Bigfoot::Flat::AssetHeaderT UnPackHeader(const eastl::span p_flatbuffer) { diff --git a/Bigfoot/Tests/Engine/BigFile/BigFile.cpp b/Bigfoot/Tests/Engine/BigFile/BigFile.cpp index 385e993..89bb0ac 100644 --- a/Bigfoot/Tests/Engine/BigFile/BigFile.cpp +++ b/Bigfoot/Tests/Engine/BigFile/BigFile.cpp @@ -53,6 +53,8 @@ class BigFileFixture: public ::testing::Test TEST_F(BigFileFixture, Asset) { AssetA assetA; + assetA.SetName("Hello"); + assetA.SetVersion(42); const eastl::vector test = assetA.Pack();