diff --git a/Bigfoot/Benchmarks/Engine/Include/EngineBenchmarks/BigFileInfo_generated.hpp b/Bigfoot/Benchmarks/Engine/Include/EngineBenchmarks/BigFileInfo_generated.hpp index f9738c1..e0599ce 100644 --- a/Bigfoot/Benchmarks/Engine/Include/EngineBenchmarks/BigFileInfo_generated.hpp +++ b/Bigfoot/Benchmarks/Engine/Include/EngineBenchmarks/BigFileInfo_generated.hpp @@ -16,7 +16,7 @@ namespace Bigfoot /* * BigFile location */ -constexpr eastl::string_view BIGFILE_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks-bigfile.db"}; +constexpr eastl::string_view BIGFILE_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks.db"}; } // namespace Bigfoot #endif #endif diff --git a/Bigfoot/Benchmarks/Engine/Include/EngineBenchmarks/SasquatchInfo_generated.hpp b/Bigfoot/Benchmarks/Engine/Include/EngineBenchmarks/SasquatchInfo_generated.hpp index cb4561b..e24d963 100644 --- a/Bigfoot/Benchmarks/Engine/Include/EngineBenchmarks/SasquatchInfo_generated.hpp +++ b/Bigfoot/Benchmarks/Engine/Include/EngineBenchmarks/SasquatchInfo_generated.hpp @@ -16,7 +16,7 @@ namespace Bigfoot /* * Sasquatch location */ -constexpr eastl::string_view SASQUATCH_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks-sasquatch.sasquatch"}; +constexpr eastl::string_view SASQUATCH_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks.sasquatch"}; } // namespace Bigfoot #endif #endif diff --git a/Bigfoot/Benchmarks/Tools/SasquatchBaker/CMakeLists.txt b/Bigfoot/Benchmarks/Tools/SasquatchBaker/CMakeLists.txt index fb74bf8..baa81a7 100644 --- a/Bigfoot/Benchmarks/Tools/SasquatchBaker/CMakeLists.txt +++ b/Bigfoot/Benchmarks/Tools/SasquatchBaker/CMakeLists.txt @@ -9,5 +9,3 @@ target_link_libraries(${PROJECT_NAME} $) bigfoot_create_bigfile("Benchmarks/Tools") - -bigfoot_create_sasquatch_info() diff --git a/Bigfoot/Benchmarks/Tools/SasquatchBaker/Include/SasquatchBakerBenchmarks/BigFileInfo_generated.hpp b/Bigfoot/Benchmarks/Tools/SasquatchBaker/Include/SasquatchBakerBenchmarks/BigFileInfo_generated.hpp index 9b2a6fc..a98dccd 100644 --- a/Bigfoot/Benchmarks/Tools/SasquatchBaker/Include/SasquatchBakerBenchmarks/BigFileInfo_generated.hpp +++ b/Bigfoot/Benchmarks/Tools/SasquatchBaker/Include/SasquatchBakerBenchmarks/BigFileInfo_generated.hpp @@ -16,7 +16,7 @@ namespace Bigfoot /* * BigFile location */ -constexpr eastl::string_view BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks-bigfile.db"}; +constexpr eastl::string_view BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks.db"}; } // namespace Bigfoot #endif #endif diff --git a/Bigfoot/Benchmarks/Tools/SasquatchBaker/Include/SasquatchBakerBenchmarks/SasquatchInfo_generated.hpp b/Bigfoot/Benchmarks/Tools/SasquatchBaker/Include/SasquatchBakerBenchmarks/SasquatchInfo_generated.hpp deleted file mode 100644 index f565bd0..0000000 --- a/Bigfoot/Benchmarks/Tools/SasquatchBaker/Include/SasquatchBakerBenchmarks/SasquatchInfo_generated.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// AUTO-GENERATED DO NOT TOUCH - -/********************************************************************* - * \file SasquatchInfo.generated.hpp - * - *********************************************************************/ -#ifndef BIGFOOT_SASQUATCHBAKERBENCHMARKS_SASQUATCHINFO_GENERATED_HPP -#define BIGFOOT_SASQUATCHBAKERBENCHMARKS_SASQUATCHINFO_GENERATED_HPP - -#include - -#if defined BIGFOOT_GAME - -namespace Bigfoot -{ -/* - * Sasquatch location - */ -constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks-sasquatch.sasquatch"}; -} // namespace Bigfoot -#endif -#endif diff --git a/Bigfoot/Benchmarks/Tools/SasquatchBaker/SasquatchBaker.cpp b/Bigfoot/Benchmarks/Tools/SasquatchBaker/SasquatchBaker.cpp index 163c45f..c603825 100644 --- a/Bigfoot/Benchmarks/Tools/SasquatchBaker/SasquatchBaker.cpp +++ b/Bigfoot/Benchmarks/Tools/SasquatchBaker/SasquatchBaker.cpp @@ -11,10 +11,7 @@ #include -#define BIGFOOT_GAME #include -#include -#undef BIGFOOT_GAME #include @@ -35,7 +32,7 @@ class SasquatchBakerFixture: public benchmark::Fixture void SetUp(benchmark::State&) override { m_bigFile.Clear(); - m_sasquatch.Delete(); + m_outputFile.Delete(); eastl::vector metadatas; eastl::vector> flatbuffers; @@ -64,11 +61,13 @@ class SasquatchBakerFixture: public benchmark::Fixture void TearDown(benchmark::State&) override { - m_sasquatch.Delete(); + m_outputFile.Delete(); } + static constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION { + "./SasquatchBakerBenchmarks.sasquatch"}; BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION}}; - File m_sasquatch {SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION}; + File m_outputFile {SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION}; }; /****************************************************************************************/ @@ -79,8 +78,8 @@ BENCHMARK_DEFINE_F(SasquatchBakerFixture, Bake)(benchmark::State& state) for (auto _: state) { - Bake(m_bigFile, m_sasquatch); - bytesProcessed += static_cast(m_sasquatch.GetSize()); + Bake(m_bigFile, m_outputFile); + bytesProcessed += static_cast(m_outputFile.GetSize()); } state.SetItemsProcessed(state.iterations() * ASSET_COUNT); diff --git a/Bigfoot/Sources/Engine/Include/Engine/BigFile/BigFile.hpp b/Bigfoot/Sources/Engine/Include/Engine/BigFile/BigFile.hpp index a67f50c..66c2612 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/BigFile/BigFile.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/BigFile/BigFile.hpp @@ -63,6 +63,7 @@ class BigFile: public DataAccessor * \param p_uuid The asset to get the flatbuffer of * \return The flatbuffer, or nullopt if the asset was not found */ + [[nodiscard]] eastl::vector GetAssetFlatbuffer(const UUID& p_uuid) const override; /** @@ -71,6 +72,7 @@ class BigFile: public DataAccessor * \param p_uuids The assets to get the flatbuffers of * \return The flatbuffers that were found */ + [[nodiscard]] eastl::vector> GetAssetFlatbuffers(eastl::span p_uuids) const override; /** @@ -79,6 +81,7 @@ class BigFile: public DataAccessor * \param p_uuid The asset to get the metadata of * \return The metadata, or nullopt if the asset was not found */ + [[nodiscard]] AssetMetadata GetAssetMetadata(const UUID& p_uuid) const override; /** @@ -87,6 +90,7 @@ class BigFile: public DataAccessor * \param p_uuids The assets to get the metadatas of * \return The metadatas that were found */ + [[nodiscard]] eastl::vector GetAssetMetadatas(eastl::span p_uuids) const override; /** @@ -95,6 +99,7 @@ class BigFile: public DataAccessor * \param p_uuid The asset to get the HardReferences of * \return The HardReferences of the asset */ + [[nodiscard]] eastl::vector GetAssetHardReferences(const UUID& p_uuid) const override; /** @@ -103,6 +108,7 @@ class BigFile: public DataAccessor * \param p_uuids The assets to get the HardReferences of * \return The HardReferences of the assets */ + [[nodiscard]] eastl::vector> GetAssetsHardReferences(eastl::span p_uuids) const override; /** @@ -112,6 +118,7 @@ class BigFile: public DataAccessor * \p_flatbuffer The flatbuffer of the asset * \param p_hardReferences The HardReferences the asset points to */ + [[nodiscard]] void SaveAssetFlatbuffer(const AssetMetadata& p_metadata, const eastl::span p_flatbuffer, const eastl::span p_hardReferences) override; @@ -123,6 +130,7 @@ class BigFile: public DataAccessor * \p_flatbuffers The flatbuffers of the assets, matching p_metadatas by index * \param p_hardReferences The HardReferences the asset points to */ + [[nodiscard]] void SaveAssetFlatbuffers(eastl::span p_metadatas, eastl::span> p_flatbuffers, const eastl::span> p_uuids) override; @@ -133,6 +141,7 @@ class BigFile: public DataAccessor * \param p_uuid The asset to check * \param True if it exists, false otherwise */ + [[nodiscard]] bool Has(const UUID& p_uuid) const override; BigFile& operator=(const BigFile& p_bigFile) = delete; diff --git a/Bigfoot/Sources/Engine/Include/Engine/DataAccessor/DataAccessor.hpp b/Bigfoot/Sources/Engine/Include/Engine/DataAccessor/DataAccessor.hpp index f2b90ef..1f0d422 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/DataAccessor/DataAccessor.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/DataAccessor/DataAccessor.hpp @@ -45,6 +45,7 @@ class DataAccessor * \param p_uuid The asset to get the flatbuffer of * \return The flatbuffer, or nullopt if the asset was not found */ + [[nodiscard]] virtual eastl::vector GetAssetFlatbuffer(const UUID& p_uuid) const = 0; /** @@ -53,6 +54,7 @@ class DataAccessor * \param p_uuids The assets to get the flatbuffers of * \return The flatbuffers that were found */ + [[nodiscard]] virtual eastl::vector> GetAssetFlatbuffers(eastl::span p_uuids) const = 0; /** @@ -61,6 +63,7 @@ class DataAccessor * \param p_uuid The asset to get the metadata of * \return The metadata, or nullopt if the asset was not found */ + [[nodiscard]] virtual AssetMetadata GetAssetMetadata(const UUID& p_uuid) const = 0; /** @@ -69,6 +72,7 @@ class DataAccessor * \param p_uuids The assets to get the metadatas of * \return The metadatas that were found */ + [[nodiscard]] virtual eastl::vector GetAssetMetadatas(eastl::span p_uuids) const = 0; /** @@ -77,6 +81,7 @@ class DataAccessor * \param p_uuid The asset to get the HardReferences of * \return The HardReferences of the asset */ + [[nodiscard]] virtual eastl::vector GetAssetHardReferences(const UUID& p_uuid) const = 0; /** @@ -85,6 +90,7 @@ class DataAccessor * \param p_uuids The assets to get the HardReferences of * \return The HardReferences of the assets */ + [[nodiscard]] virtual eastl::vector> GetAssetsHardReferences(eastl::span p_uuids) const = 0; /** @@ -94,6 +100,7 @@ class DataAccessor * \p_flatbuffer The flatbuffer of the asset * \param p_hardReferences The HardReferences the asset points to */ + [[nodiscard]] virtual void SaveAssetFlatbuffer(const AssetMetadata& p_metadata, const eastl::span p_flatbuffer, const eastl::span p_hardReferences) = 0; @@ -105,6 +112,7 @@ class DataAccessor * \p_flatbuffers The flatbuffers of the assets, matching p_metadatas by index * \param p_hardReferences The HardReferences the asset points to */ + [[nodiscard]] virtual void SaveAssetFlatbuffers(eastl::span p_metadatas, eastl::span> p_flatbuffers, const eastl::span> p_uuids) = 0; @@ -115,6 +123,7 @@ class DataAccessor * \param p_uuid The asset to check * \param True if it exists, false otherwise */ + [[nodiscard]] virtual bool Has(const UUID& p_uuid) const = 0; DataAccessor& operator=(const DataAccessor& p_accessor) = default; diff --git a/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/Sasquatch.hpp b/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/Sasquatch.hpp index 3628cfc..14481d7 100644 --- a/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/Sasquatch.hpp +++ b/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/Sasquatch.hpp @@ -117,11 +117,9 @@ class SasquatchWriter */ eastl::vector m_entries; }; -#endif /****************************************************************************************/ -#ifdef BIGFOOT_GAME class Sasquatch: public DataAccessor { public: @@ -137,12 +135,20 @@ class Sasquatch: public DataAccessor ~Sasquatch() override = default; + /** + * Get the header + * + * \return The header + */ + const SasquatchHeader& GetHeader() const; + /** * Get an Asset flatbuffer * * \param p_uuid The asset to get the flatbuffer of * \return The flatbuffer, or nullopt if the asset was not found */ + [[nodiscard]] eastl::vector GetAssetFlatbuffer(const UUID& p_uuid) const override; /** @@ -151,18 +157,21 @@ class Sasquatch: public DataAccessor * \param p_uuids The assets to get the flatbuffers of * \return The flatbuffers that were found */ + [[nodiscard]] eastl::vector> GetAssetFlatbuffers(eastl::span p_uuids) const override; /** * Sasquatch only serves flatbuffers: this will always fail * */ + [[nodiscard]] AssetMetadata GetAssetMetadata(const UUID& p_uuid) const override; /** * Sasquatch only serves flatbuffers: this will always fail * */ + [[nodiscard]] eastl::vector GetAssetMetadatas(eastl::span p_uuids) const override; /** @@ -171,6 +180,7 @@ class Sasquatch: public DataAccessor * \param p_uuid The asset to get the HardReferences of * \return The HardReferences of the asset */ + [[nodiscard]] eastl::vector GetAssetHardReferences(const UUID& p_uuid) const override; /** @@ -179,12 +189,14 @@ class Sasquatch: public DataAccessor * \param p_uuids The assets to get the HardReferences of * \return The HardReferences of the assets */ + [[nodiscard]] eastl::vector> GetAssetsHardReferences(eastl::span p_uuids) const override; /** * Sasquatch is read-only: this will always fail * */ + [[nodiscard]] void SaveAssetFlatbuffer(const AssetMetadata& p_metadata, eastl::span p_flatbuffer, eastl::span p_hardReferences) override; @@ -193,6 +205,7 @@ class Sasquatch: public DataAccessor * Sasquatch is read-only: this will always fail * */ + [[nodiscard]] void SaveAssetFlatbuffers(eastl::span p_metadatas, eastl::span> p_flatbuffers, eastl::span> p_hardReferences) override; @@ -203,6 +216,7 @@ class Sasquatch: public DataAccessor * \param p_uuid The asset to check * \param True if it exists, false otherwise */ + [[nodiscard]] bool Has(const UUID& p_uuid) const override; Sasquatch& operator=(const Sasquatch& p_sasquatch) = delete; @@ -223,6 +237,11 @@ class Sasquatch: public DataAccessor */ MemoryMappedFile m_file; + /** + * The sasquatch header + */ + SasquatchHeader m_header; + /** * UUID to entry */ diff --git a/Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp b/Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp index c5532d6..85ce888 100644 --- a/Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp +++ b/Bigfoot/Sources/Engine/Sasquatch/Sasquatch.cpp @@ -104,11 +104,9 @@ void SasquatchWriter::WriteAsset(const UUID& p_uuid, m_entries.push_back(entry); } -#endif /****************************************************************************************/ -#ifdef BIGFOOT_GAME Sasquatch::Sasquatch(const File& p_file): m_file(p_file) { @@ -119,36 +117,35 @@ Sasquatch::Sasquatch(const File& p_file): "Sasquatch file {} is smaller than its header", p_file.GetPath()); - SasquatchHeader header; - std::memcpy(&header, data.data(), sizeof(SasquatchHeader)); + std::memcpy(&m_header, data.data(), sizeof(SasquatchHeader)); CRITICAL_ASSERT(EngineAssertHandler, - header.m_magic == SasquatchHeader::MAGIC, + m_header.m_magic == SasquatchHeader::MAGIC, "Sasquatch file {} has an invalid magic number (got {} / expected {})", p_file.GetPath(), - header.m_magic, + m_header.m_magic, SasquatchHeader::MAGIC); CRITICAL_ASSERT(EngineAssertHandler, - header.m_version == SasquatchHeader::VERSION, + m_header.m_version == SasquatchHeader::VERSION, "Sasquatch file {} has an unsupported version (got {} / expected {})", p_file.GetPath(), - header.m_version, + m_header.m_version, SasquatchHeader::VERSION); CRITICAL_ASSERT(EngineAssertHandler, - data.size() >= sizeof(SasquatchHeader) + header.m_assetCount * sizeof(SasquatchEntry), + data.size() >= sizeof(SasquatchHeader) + m_header.m_assetCount * sizeof(SasquatchEntry), "Sasquatch file {} index is truncated (got {} / expected at least {})", p_file.GetPath(), data.size(), - sizeof(SasquatchHeader) + header.m_assetCount * sizeof(SasquatchEntry)); + sizeof(SasquatchHeader) + m_header.m_assetCount * sizeof(SasquatchEntry)); - eastl::vector entries(header.m_assetCount); + eastl::vector entries(m_header.m_assetCount); if (!entries.empty()) { std::memcpy(entries.data(), data.data() + sizeof(SasquatchHeader), entries.size() * sizeof(SasquatchEntry)); } - m_entries.reserve(header.m_assetCount); + m_entries.reserve(m_header.m_assetCount); for (const SasquatchEntry& entry: entries) { CRITICAL_ASSERT(EngineAssertHandler, @@ -166,6 +163,13 @@ Sasquatch::Sasquatch(const File& p_file): /****************************************************************************************/ +const SasquatchHeader& Sasquatch::GetHeader() const +{ + return m_header; +} + +/****************************************************************************************/ + eastl::vector Sasquatch::GetAssetFlatbuffer(const UUID& p_uuid) const { const auto it = m_entries.find(p_uuid); diff --git a/Bigfoot/Sources/Tools/SasquatchBaker/SasquatchBaker.cpp b/Bigfoot/Sources/Tools/SasquatchBaker/SasquatchBaker.cpp index 45eb593..9293392 100644 --- a/Bigfoot/Sources/Tools/SasquatchBaker/SasquatchBaker.cpp +++ b/Bigfoot/Sources/Tools/SasquatchBaker/SasquatchBaker.cpp @@ -35,11 +35,11 @@ void Bake(const BigFile& p_bigFile, const File& p_outputFile) std::uint64_t totalHardReferencesBytes = 0; { BigFile::Request sizeRequest {p_bigFile, - "SELECT COALESCE(SUM(LENGTH(AssetHardReference)), 0) FROM AssetHardReference;"}; + "SELECT COALESCE(SUM(LENGTH(HardReference)), 0) FROM AssetHardReference;"}; [[maybe_unused]] const bool hasSize = sizeRequest.Step(); ASSERT(SasquatchBakerAssertHandler, hasSize, "Failed to sum the hardreferences sizes of the BigFile"); - totalFlatbufferBytes = sizeRequest.Get(0); + totalHardReferencesBytes = sizeRequest.Get(0); } SasquatchWriter writer {p_outputFile, assetCount, totalFlatbufferBytes, totalHardReferencesBytes}; diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/BigFileInfo_generated.hpp b/Bigfoot/Tests/Engine/Include/EngineTests/BigFileInfo_generated.hpp index 1ea83d2..9422ab2 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/BigFileInfo_generated.hpp +++ b/Bigfoot/Tests/Engine/Include/EngineTests/BigFileInfo_generated.hpp @@ -16,7 +16,7 @@ namespace Bigfoot /* * BigFile location */ -constexpr eastl::string_view BIGFILE_ENGINETESTS_LOCATION {"./EngineTests-bigfile.db"}; +constexpr eastl::string_view BIGFILE_ENGINETESTS_LOCATION {"./EngineTests.db"}; } // namespace Bigfoot #endif #endif diff --git a/Bigfoot/Tests/Engine/Include/EngineTests/SasquatchInfo_generated.hpp b/Bigfoot/Tests/Engine/Include/EngineTests/SasquatchInfo_generated.hpp index 5ba2982..1f28036 100644 --- a/Bigfoot/Tests/Engine/Include/EngineTests/SasquatchInfo_generated.hpp +++ b/Bigfoot/Tests/Engine/Include/EngineTests/SasquatchInfo_generated.hpp @@ -16,7 +16,7 @@ namespace Bigfoot /* * Sasquatch location */ -constexpr eastl::string_view SASQUATCH_ENGINETESTS_LOCATION {"./EngineTests-sasquatch.sasquatch"}; +constexpr eastl::string_view SASQUATCH_ENGINETESTS_LOCATION {"./EngineTests.sasquatch"}; } // namespace Bigfoot #endif #endif diff --git a/Bigfoot/Tests/Engine/Sasquatch/Sasquatch.cpp b/Bigfoot/Tests/Engine/Sasquatch/Sasquatch.cpp index b7cb64f..6379a03 100644 --- a/Bigfoot/Tests/Engine/Sasquatch/Sasquatch.cpp +++ b/Bigfoot/Tests/Engine/Sasquatch/Sasquatch.cpp @@ -80,6 +80,15 @@ class SasquatchFixture: public ::testing::Test /****************************************************************************************/ +TEST_F(SasquatchFixture, GetHeader_ShouldGetTheHeader) +{ + EXPECT_EQ(m_sasquatch->GetHeader().m_magic, SasquatchHeader::MAGIC); + EXPECT_EQ(m_sasquatch->GetHeader().m_version, SasquatchHeader::VERSION); + EXPECT_EQ(m_sasquatch->GetHeader().m_assetCount, 2); +} + +/****************************************************************************************/ + TEST_F(SasquatchFixture, GetAssetHardReference_ShouldReturnEmptyVectorForNonExistentUUID) { const UUID uuid; diff --git a/Bigfoot/Tests/Tools/SasquatchBaker/Include/SasquatchBakerTests/BigFileInfo_generated.hpp b/Bigfoot/Tests/Tools/SasquatchBaker/Include/SasquatchBakerTests/BigFileInfo_generated.hpp index ed9ee3c..b19d7b9 100644 --- a/Bigfoot/Tests/Tools/SasquatchBaker/Include/SasquatchBakerTests/BigFileInfo_generated.hpp +++ b/Bigfoot/Tests/Tools/SasquatchBaker/Include/SasquatchBakerTests/BigFileInfo_generated.hpp @@ -16,7 +16,7 @@ namespace Bigfoot /* * BigFile location */ -constexpr eastl::string_view BIGFILE_SASQUATCHBAKERTESTS_LOCATION {"./SasquatchBakerTests-bigfile.db"}; +constexpr eastl::string_view BIGFILE_SASQUATCHBAKERTESTS_LOCATION {"./SasquatchBakerTests.db"}; } // namespace Bigfoot #endif #endif diff --git a/Bigfoot/Tests/Tools/SasquatchBaker/SasquatchBaker.cpp b/Bigfoot/Tests/Tools/SasquatchBaker/SasquatchBaker.cpp index 93c6097..e0ff82e 100644 --- a/Bigfoot/Tests/Tools/SasquatchBaker/SasquatchBaker.cpp +++ b/Bigfoot/Tests/Tools/SasquatchBaker/SasquatchBaker.cpp @@ -27,57 +27,28 @@ class SasquatchBakerFixture: public ::testing::Test void SetUp() override { m_bigFile.Clear(); - m_sasquatch.Delete(); - } - - [[nodiscard]] - SasquatchHeader ReadHeader(const eastl::vector& p_data) - { - SasquatchHeader header; - std::memcpy(&header, p_data.data(), sizeof(SasquatchHeader)); - return header; - } - - [[nodiscard]] - eastl::optional FindEntry(const eastl::vector& p_data, const UUID& p_uuid) - { - const SasquatchHeader header = ReadHeader(p_data); - - for (std::uint64_t i = 0; i < header.m_assetCount; ++i) - { - SasquatchEntry entry; - std::memcpy(&entry, - p_data.data() + sizeof(SasquatchHeader) + i * sizeof(SasquatchEntry), - sizeof(SasquatchEntry)); - - if (UUID {entry.m_uuid} == p_uuid) - { - return entry; - } - } - - return eastl::nullopt; + m_outputFile.Delete(); } static constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERTESTS_LOCATION { - "./SasquatchBakerTests-sasquatch.sasquatch"}; + "./SasquatchBakerTests.sasquatch"}; BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERTESTS_LOCATION}}; - File m_sasquatch {SASQUATCH_SASQUATCHBAKERTESTS_LOCATION}; + File m_outputFile {SASQUATCH_SASQUATCHBAKERTESTS_LOCATION}; }; /****************************************************************************************/ TEST_F(SasquatchBakerFixture, Bake_ShouldWriteAnEmptyFileWhenTheBigFileIsEmpty) { - Bake(m_bigFile, m_sasquatch); + Bake(m_bigFile, m_outputFile); + Sasquatch sasquatch {m_outputFile}; - const eastl::vector data = m_sasquatch.Read(0, m_sasquatch.GetSize()); - ASSERT_EQ(data.size(), sizeof(SasquatchHeader)); + const eastl::vector data = m_outputFile.Read(0, m_outputFile.GetSize()); + ASSERT_EQ(m_outputFile.GetSize(), sizeof(SasquatchHeader)); - const SasquatchHeader header = ReadHeader(data); - EXPECT_EQ(header.m_magic, SasquatchHeader::MAGIC); - EXPECT_EQ(header.m_version, SasquatchHeader::VERSION); - EXPECT_EQ(header.m_assetCount, 0); + EXPECT_EQ(sasquatch.GetHeader().m_magic, SasquatchHeader::MAGIC); + EXPECT_EQ(sasquatch.GetHeader().m_version, SasquatchHeader::VERSION); + EXPECT_EQ(sasquatch.GetHeader().m_assetCount, 0); } /****************************************************************************************/ @@ -109,13 +80,16 @@ TEST_F(SasquatchBakerFixture, Bake_ShouldWriteEveryAssetOfTheBigFile) flatbufferB, AssetB::GetHardReferences(flatbufferB)); - Bake(m_bigFile, m_sasquatch); + Bake(m_bigFile, m_outputFile); + Sasquatch sasquatch {m_outputFile}; - const eastl::vector data = m_sasquatch.Read(0, m_sasquatch.GetSize()); - const SasquatchHeader header = ReadHeader(data); - EXPECT_EQ(header.m_assetCount, 2); + EXPECT_EQ(sasquatch.GetHeader().m_magic, SasquatchHeader::MAGIC); + EXPECT_EQ(sasquatch.GetHeader().m_version, SasquatchHeader::VERSION); + EXPECT_EQ(sasquatch.GetHeader().m_assetCount, 2); - EXPECT_TRUE(FindEntry(data, assetA.GetHeader().uuid).has_value()); - EXPECT_TRUE(FindEntry(data, assetB.GetHeader().uuid).has_value()); + EXPECT_FALSE(sasquatch.GetAssetFlatbuffer(assetA.GetHeader().uuid).empty()); + EXPECT_FALSE(sasquatch.GetAssetFlatbuffer(assetB.GetHeader().uuid).empty()); + + EXPECT_FALSE(sasquatch.GetAssetHardReferences(assetB.GetHeader().uuid).empty()); } } // namespace Bigfoot diff --git a/CMake/Utils.cmake b/CMake/Utils.cmake index a953366..ce0d0df 100644 --- a/CMake/Utils.cmake +++ b/CMake/Utils.cmake @@ -8,7 +8,7 @@ function(bigfoot_create_logger) endfunction() function(bigfoot_create_bigfile ParentFolder) - set(OUTPUT_PATH_BIGFILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}-bigfile.db") + set(OUTPUT_PATH_BIGFILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.db") get_filename_component(OUTPUT_PATH_BIGFILE_ABSOLUTE ${OUTPUT_PATH_BIGFILE} ABSOLUTE) get_filename_component(OUTPUT_PATH_BIGFILE_DIRECTORY ${OUTPUT_PATH_BIGFILE_ABSOLUTE} DIRECTORY) @@ -30,7 +30,7 @@ function(bigfoot_create_bigfile ParentFolder) add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}BigFile) string(TOUPPER ${PROJECT_NAME} BIGFILE_NAME) - set(BIGFILE_LOCATION "./${PROJECT_NAME}-bigfile.db") + set(BIGFILE_LOCATION "./${PROJECT_NAME}.db") configure_file( ${CMAKE_SOURCE_DIR}/Bigfoot/Sources/Engine/Include/Engine/BigFile/BigFileInfo_generated.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/Include/${PROJECT_NAME}/BigFileInfo_generated.hpp @@ -40,7 +40,7 @@ endfunction() function(bigfoot_create_sasquatch_info) string(TOUPPER ${PROJECT_NAME} SASQUATCH_NAME) - set(SASQUATCH_LOCATION "./${PROJECT_NAME}-sasquatch.sasquatch") + set(SASQUATCH_LOCATION "./${PROJECT_NAME}.sasquatch") configure_file( ${CMAKE_SOURCE_DIR}/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/SasquatchInfo_generated.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/Include/${PROJECT_NAME}/SasquatchInfo_generated.hpp