header manipulation
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 3m19s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 1m27s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 1m55s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 1m49s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 2m6s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Clang Format Checks (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 3m19s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 1m27s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 1m55s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 1m49s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 2m6s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Clang Format Checks (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <Engine/BigFile/Asset/Asset_generated.hpp>
|
||||
|
||||
#include <EASTL/vector.h>
|
||||
#include <rapidhash.h>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
@@ -16,7 +17,11 @@ template<class FLAT_ASSET>
|
||||
class Asset
|
||||
{
|
||||
public:
|
||||
Asset() = default;
|
||||
Asset()
|
||||
{
|
||||
m_header.type_id = GetTypeID();
|
||||
m_header.type_name = GetTypeName();
|
||||
}
|
||||
|
||||
explicit Asset(const eastl::span<const std::byte> 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<std::byte*>(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<const std::byte> p_flatbuffer)
|
||||
{
|
||||
|
||||
@@ -53,6 +53,8 @@ class BigFileFixture: public ::testing::Test
|
||||
TEST_F(BigFileFixture, Asset)
|
||||
{
|
||||
AssetA assetA;
|
||||
assetA.SetName("Hello");
|
||||
assetA.SetVersion(42);
|
||||
|
||||
const eastl::vector<std::byte> test = assetA.Pack();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user