BigFile access
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Canceled after 4m13s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Clang Format Checks (push) Canceled after 0s
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Canceled after 4m13s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Clang Format Checks (push) Canceled after 0s
This commit is contained in:
@@ -8,6 +8,11 @@
|
||||
|
||||
#include <Engine/EngineAssertHandler.hpp>
|
||||
|
||||
#include <EASTL/algorithm.h>
|
||||
#include <EASTL/sort.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
#ifdef BIGFOOT_TOOLMODE
|
||||
@@ -60,45 +65,110 @@ BigFile::~BigFile()
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
eastl::vector<std::byte> BigFile::GetAssetFlatbuffer(const UUID& p_uuid) const
|
||||
eastl::vector<eastl::vector<std::byte>> BigFile::GetAssetFlatbuffers(const eastl::span<const UUID> p_uuids) const
|
||||
{
|
||||
BigFile::Request assetRequest {*this,
|
||||
"SELECT Asset.Asset FROM Asset "
|
||||
"JOIN AssetMetadata ON AssetMetadata.UUID = Asset.UUID "
|
||||
"WHERE Asset.UUID = ?1;"};
|
||||
assetRequest.Bind(1, p_uuid.ToBytes());
|
||||
|
||||
if (!assetRequest.Step())
|
||||
eastl::vector<eastl::vector<std::byte>> flatbuffers;
|
||||
if (p_uuids.empty())
|
||||
{
|
||||
return {};
|
||||
return flatbuffers;
|
||||
}
|
||||
|
||||
const eastl::span<const std::byte> flatbuffer = assetRequest.Get(0);
|
||||
return eastl::vector<std::byte> {flatbuffer.begin(), flatbuffer.end()};
|
||||
eastl::vector<UUID> uniqueUUIDs {p_uuids.begin(), p_uuids.end()};
|
||||
eastl::sort(uniqueUUIDs.begin(), uniqueUUIDs.end());
|
||||
uniqueUUIDs.erase(eastl::unique(uniqueUUIDs.begin(), uniqueUUIDs.end()), uniqueUUIDs.end());
|
||||
|
||||
eastl::string placeholders;
|
||||
for (std::size_t i = 0; i < uniqueUUIDs.size(); ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
placeholders += ", ";
|
||||
}
|
||||
placeholders += "?";
|
||||
placeholders += std::to_string(i + 1).c_str();
|
||||
}
|
||||
|
||||
const std::string sqlRequest = fmt::format("SELECT Asset.Asset FROM Asset "
|
||||
"JOIN AssetMetadata ON AssetMetadata.UUID = Asset.UUID "
|
||||
"WHERE Asset.UUID IN ({});",
|
||||
placeholders);
|
||||
|
||||
BigFile::Request assetRequest {*this, sqlRequest.c_str()};
|
||||
for (std::size_t i = 0; i < uniqueUUIDs.size(); ++i)
|
||||
{
|
||||
assetRequest.Bind(static_cast<std::uint32_t>(i + 1), uniqueUUIDs[i].ToBytes());
|
||||
}
|
||||
|
||||
flatbuffers.reserve(uniqueUUIDs.size());
|
||||
for (std::size_t i = 0; i < uniqueUUIDs.size(); ++i)
|
||||
{
|
||||
if (!assetRequest.Step())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
const eastl::span<const std::byte> flatbuffer = assetRequest.Get(0);
|
||||
flatbuffers.emplace_back(flatbuffer.begin(), flatbuffer.end());
|
||||
}
|
||||
|
||||
return flatbuffers;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
AssetMetadata BigFile::GetAssetMetadata(const UUID& p_uuid) const
|
||||
eastl::vector<AssetMetadata> BigFile::GetAssetMetadatas(const eastl::span<const UUID> p_uuids) const
|
||||
{
|
||||
BigFile::Request assetRequest {
|
||||
*this,
|
||||
"SELECT UUID, Name, TypeID, TypeName, CreateTime, ModificationTime FROM AssetMetadata WHERE UUID = ?1;"};
|
||||
assetRequest.Bind(1, p_uuid.ToBytes());
|
||||
|
||||
if (!assetRequest.Step())
|
||||
eastl::vector<AssetMetadata> metadatas;
|
||||
if (p_uuids.empty())
|
||||
{
|
||||
return {};
|
||||
return metadatas;
|
||||
}
|
||||
|
||||
return AssetMetadata {.m_uuid = UUID {std::span<const std::byte, UUID::UUID_BYTE_SIZE> {
|
||||
static_cast<eastl::span<const std::byte>>(assetRequest.Get(0)).data(),
|
||||
UUID::UUID_BYTE_SIZE}},
|
||||
.m_name = eastl::string {static_cast<eastl::string_view>(assetRequest.Get(1))},
|
||||
.m_typeID = assetRequest.Get(2),
|
||||
.m_typeName = eastl::string {static_cast<eastl::string_view>(assetRequest.Get(3))},
|
||||
.m_creationTime = Time {static_cast<std::uint64_t>(assetRequest.Get(4))},
|
||||
.m_modificationTime = Time {static_cast<std::uint64_t>(assetRequest.Get(5))}};
|
||||
eastl::vector<UUID> uniqueUUIDs {p_uuids.begin(), p_uuids.end()};
|
||||
eastl::sort(uniqueUUIDs.begin(), uniqueUUIDs.end());
|
||||
uniqueUUIDs.erase(eastl::unique(uniqueUUIDs.begin(), uniqueUUIDs.end()), uniqueUUIDs.end());
|
||||
|
||||
eastl::string placeholders;
|
||||
for (std::size_t i = 0; i < uniqueUUIDs.size(); ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
placeholders += ", ";
|
||||
}
|
||||
placeholders += "?";
|
||||
placeholders += std::to_string(i + 1).c_str();
|
||||
}
|
||||
|
||||
const std::string sqlRequest = fmt::format("SELECT UUID, Name, TypeID, TypeName, CreateTime, ModificationTime "
|
||||
"FROM AssetMetadata WHERE UUID IN ({});",
|
||||
placeholders);
|
||||
|
||||
BigFile::Request assetRequest {*this, sqlRequest.c_str()};
|
||||
for (std::size_t i = 0; i < uniqueUUIDs.size(); ++i)
|
||||
{
|
||||
assetRequest.Bind(static_cast<std::uint32_t>(i + 1), uniqueUUIDs[i].ToBytes());
|
||||
}
|
||||
|
||||
metadatas.reserve(uniqueUUIDs.size());
|
||||
for (std::size_t i = 0; i < uniqueUUIDs.size(); ++i)
|
||||
{
|
||||
if (!assetRequest.Step())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
metadatas.push_back(
|
||||
AssetMetadata {.m_uuid = UUID {std::span<const std::byte, UUID::UUID_BYTE_SIZE> {
|
||||
static_cast<eastl::span<const std::byte>>(assetRequest.Get(0)).data(),
|
||||
UUID::UUID_BYTE_SIZE}},
|
||||
.m_name = eastl::string {static_cast<eastl::string_view>(assetRequest.Get(1))},
|
||||
.m_typeID = assetRequest.Get(2),
|
||||
.m_typeName = eastl::string {static_cast<eastl::string_view>(assetRequest.Get(3))},
|
||||
.m_creationTime = Time {static_cast<std::uint64_t>(assetRequest.Get(4))},
|
||||
.m_modificationTime = Time {static_cast<std::uint64_t>(assetRequest.Get(5))}});
|
||||
}
|
||||
|
||||
return metadatas;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
@@ -52,20 +52,20 @@ class BigFile: public DataAccessor
|
||||
~BigFile();
|
||||
|
||||
/**
|
||||
* Get an Asset flatbuffer
|
||||
* Get several Asset flatbuffers
|
||||
*
|
||||
* \param p_uuid The asset to get the flatbuffer of
|
||||
* \return The flatbuffer, can be empty if asset was not found
|
||||
* \param p_uuids The assets to get the flatbuffers of
|
||||
* \return The flatbuffers that were found
|
||||
*/
|
||||
eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const override;
|
||||
eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const override;
|
||||
|
||||
/**
|
||||
* Get an Asset metadata
|
||||
* Get several Asset metadatas
|
||||
*
|
||||
* \param p_uuid The asset to get the metadata of
|
||||
* \return The metadata, default initialized if not found (ie: UUID = NULL)
|
||||
* \param p_uuids The assets to get the metadatas of
|
||||
* \return The metadatas that were found
|
||||
*/
|
||||
AssetMetadata GetAssetMetadata(const UUID& p_uuid) const override;
|
||||
eastl::vector<AssetMetadata> GetAssetMetadatas(eastl::span<const UUID> p_uuids) const override;
|
||||
|
||||
/**
|
||||
* Save an asset
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <System/Time/Time.hpp>
|
||||
#include <System/UUID/UUID.hpp>
|
||||
|
||||
#include <EASTL/optional.h>
|
||||
#include <EASTL/span.h>
|
||||
#include <EASTL/string.h>
|
||||
#include <EASTL/vector.h>
|
||||
@@ -43,17 +44,51 @@ class DataAccessor
|
||||
* Get an Asset flatbuffer
|
||||
*
|
||||
* \param p_uuid The asset to get the flatbuffer of
|
||||
* \return The flatbuffer, can be empty if asset was not found
|
||||
* \return The flatbuffer, or nullopt if the asset was not found
|
||||
*/
|
||||
virtual eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const = 0;
|
||||
eastl::optional<eastl::vector<std::byte>> GetAssetFlatbuffer(const UUID& p_uuid) const
|
||||
{
|
||||
eastl::vector<eastl::vector<std::byte>> flatbuffers = GetAssetFlatbuffers(eastl::span<const UUID> {&p_uuid, 1});
|
||||
if (flatbuffers.empty())
|
||||
{
|
||||
return eastl::nullopt;
|
||||
}
|
||||
|
||||
return std::move(flatbuffers.front());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get several Asset flatbuffers
|
||||
*
|
||||
* \param p_uuids The assets to get the flatbuffers of
|
||||
* \return The flatbuffers that were found
|
||||
*/
|
||||
virtual eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const = 0;
|
||||
|
||||
/**
|
||||
* Get an Asset metadata
|
||||
*
|
||||
* \param p_uuid The asset to get the metadata of
|
||||
* \return The metadata, default initialized if not found (ie: UUID = NULL)
|
||||
* \return The metadata, or nullopt if the asset was not found
|
||||
*/
|
||||
virtual AssetMetadata GetAssetMetadata(const UUID& p_uuid) const = 0;
|
||||
eastl::optional<AssetMetadata> GetAssetMetadata(const UUID& p_uuid) const
|
||||
{
|
||||
eastl::vector<AssetMetadata> metadatas = GetAssetMetadatas(eastl::span<const UUID> {&p_uuid, 1});
|
||||
if (metadatas.empty())
|
||||
{
|
||||
return eastl::nullopt;
|
||||
}
|
||||
|
||||
return std::move(metadatas.front());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get several Asset metadatas
|
||||
*
|
||||
* \param p_uuids The assets to get the metadatas of
|
||||
* \return The metadatas that were found
|
||||
*/
|
||||
virtual eastl::vector<AssetMetadata> GetAssetMetadatas(eastl::span<const UUID> p_uuids) const = 0;
|
||||
|
||||
/**
|
||||
* Save an asset
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#define BIGFOOT_SYSTEM_UUID_UUID_HPP
|
||||
#include <uuid.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
class UUID
|
||||
@@ -112,17 +114,16 @@ struct std::hash<Bigfoot::UUID>
|
||||
};
|
||||
|
||||
template<>
|
||||
struct std::formatter<Bigfoot::UUID, char>
|
||||
struct fmt::formatter<Bigfoot::UUID>
|
||||
{
|
||||
constexpr auto parse(std::format_parse_context& ctx)
|
||||
constexpr auto parse(format_parse_context& ctx)
|
||||
{
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template<typename FormatContext>
|
||||
auto format(const Bigfoot::UUID& p_uuid, FormatContext& ctx) const
|
||||
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
|
||||
{
|
||||
return std::format_to(ctx.out(), "{}", p_uuid.ToString());
|
||||
return fmt::format_to(ctx.out(), "{}", p_uuid.ToString());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ set(PublicDependencies
|
||||
$<IF:$<BOOL:${ASAN}>,mimalloc-asan,mimalloc-static>
|
||||
unordered_dense::unordered_dense
|
||||
EASTL::EASTL
|
||||
EAStdC::EAStdC
|
||||
fmt::fmt
|
||||
flatbuffers::flatbuffers
|
||||
rapidhash::rapidhash)
|
||||
set(PrivateDependencies)
|
||||
@@ -19,6 +21,7 @@ bigfoot_create_package_lib(
|
||||
"${BigfootPrivateDependencies}"
|
||||
"")
|
||||
set_source_files_properties(../Utils/MimallocImpl.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
set_source_files_properties(../Utils/EASTLVsnprintfImpl.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||
|
||||
bigfoot_create_logger()
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
|
||||
#include <format>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <source_location>
|
||||
|
||||
namespace Bigfoot
|
||||
@@ -35,11 +36,11 @@ class AssertHandler
|
||||
* \param p_args Arguments for the format string.
|
||||
*/
|
||||
template<typename... ARGS>
|
||||
static void Handle(const std::source_location& p_location, std::format_string<ARGS...> p_format, ARGS&&... p_args)
|
||||
static void Handle(const std::source_location& p_location, fmt::format_string<ARGS...> p_format, ARGS&&... p_args)
|
||||
{
|
||||
BIGFOOT_LOG_FATAL(LOGGER,
|
||||
"Assert: {} (File:{}, Line:{}, Function:{}\n",
|
||||
std::format(p_format, std::forward<ARGS>(p_args)...),
|
||||
fmt::format(p_format, std::forward<ARGS>(p_args)...),
|
||||
p_location.file_name(),
|
||||
p_location.line(),
|
||||
p_location.function_name());
|
||||
|
||||
@@ -15,22 +15,21 @@
|
||||
#include <EASTL/string.h>
|
||||
#include <EASTL/string_view.h>
|
||||
|
||||
#include <format>
|
||||
#include <fmt/format.h>
|
||||
|
||||
// STRING
|
||||
|
||||
template<>
|
||||
struct std::formatter<eastl::string>
|
||||
struct fmt::formatter<eastl::string>
|
||||
{
|
||||
constexpr auto parse(std::format_parse_context& ctx)
|
||||
constexpr auto parse(format_parse_context& ctx)
|
||||
{
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template<typename FormatContext>
|
||||
auto format(const eastl::string& p_string, FormatContext& ctx) const
|
||||
auto format(const eastl::string& p_string, format_context& ctx) const
|
||||
{
|
||||
return std::format_to(ctx.out(), "{}", p_string.c_str());
|
||||
return fmt::format_to(ctx.out(), "{}", p_string.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -58,17 +57,16 @@ struct quill::Codec<eastl::string>: quill::DeferredFormatCodec<eastl::string>
|
||||
// STRING_VIEW
|
||||
|
||||
template<>
|
||||
struct std::formatter<eastl::string_view>
|
||||
struct fmt::formatter<eastl::string_view>
|
||||
{
|
||||
constexpr auto parse(std::format_parse_context& ctx)
|
||||
constexpr auto parse(format_parse_context& ctx)
|
||||
{
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template<typename FormatContext>
|
||||
auto format(const eastl::string_view& p_stringView, FormatContext& ctx) const
|
||||
auto format(const eastl::string_view& p_stringView, format_context& ctx) const
|
||||
{
|
||||
return std::format_to(ctx.out(), "{}", p_stringView.data());
|
||||
return fmt::format_to(ctx.out(), "{}", p_stringView.data());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#include <Utils/Caster.hpp>
|
||||
#include <Utils/TargetMacros.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <string>
|
||||
|
||||
namespace Bigfoot
|
||||
@@ -115,7 +116,7 @@ class Version
|
||||
|
||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||
template<>
|
||||
struct std::formatter<Bigfoot::Version>
|
||||
struct fmt::formatter<Bigfoot::Version>
|
||||
{
|
||||
template<typename ParseContext>
|
||||
constexpr auto parse(ParseContext& p_context)
|
||||
@@ -126,7 +127,7 @@ struct std::formatter<Bigfoot::Version>
|
||||
template<typename FormatContext>
|
||||
auto format(const Bigfoot::Version& p_version, FormatContext& p_context) const
|
||||
{
|
||||
return std::format_to(p_context.out(), "{}", p_version.ToString());
|
||||
return fmt::format_to(p_context.out(), "{}", p_version.ToString());
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,6 @@ namespace Bigfoot
|
||||
{
|
||||
std::string Version::ToString() const
|
||||
{
|
||||
return std::format("{}.{}.{}", GetMajor(), GetMinor(), GetPatch());
|
||||
return fmt::format("{}.{}.{}", GetMajor(), GetMinor(), GetPatch());
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
|
||||
@@ -33,11 +33,11 @@ class BigFileFixture: public ::testing::Test
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(BigFileFixture, GetAssetFlatbuffer_ShouldReturnEmptyForNonExistentUUID)
|
||||
TEST_F(BigFileFixture, GetAssetFlatbuffer_ShouldReturnNulloptForNonExistentUUID)
|
||||
{
|
||||
const UUID uuid;
|
||||
|
||||
EXPECT_TRUE(m_bigFile.GetAssetFlatbuffer(uuid).empty());
|
||||
EXPECT_FALSE(m_bigFile.GetAssetFlatbuffer(uuid).has_value());
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -57,24 +57,70 @@ TEST_F(BigFileFixture, GetAssetFlatbuffer_ShouldGetTheAssetFlatbuffer)
|
||||
|
||||
m_bigFile.SaveAssetFlatbuffer(metadata, flatbuffer);
|
||||
|
||||
const eastl::vector<std::byte> savedFlatbuffer = m_bigFile.GetAssetFlatbuffer(asset.GetHeader().uuid);
|
||||
EXPECT_EQ(savedFlatbuffer, flatbuffer);
|
||||
const eastl::optional<eastl::vector<std::byte>> savedFlatbuffer = m_bigFile.GetAssetFlatbuffer(asset.GetHeader().uuid);
|
||||
ASSERT_TRUE(savedFlatbuffer.has_value());
|
||||
EXPECT_EQ(*savedFlatbuffer, flatbuffer);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(BigFileFixture, GetAssetMetadata_ShouldReturnDefaultForNonExistentUUID)
|
||||
TEST_F(BigFileFixture, GetAssetFlatbuffers_ShouldOmitUUIDsThatDoNotExist)
|
||||
{
|
||||
AssetA assetA;
|
||||
assetA.SetName("hello");
|
||||
const eastl::vector<std::byte> flatbufferA = assetA.Pack();
|
||||
m_bigFile.SaveAssetFlatbuffer(AssetMetadata {.m_uuid = assetA.GetHeader().uuid,
|
||||
.m_name = assetA.GetHeader().name,
|
||||
.m_typeID = assetA.GetHeader().type_id,
|
||||
.m_typeName = assetA.GetHeader().type_name},
|
||||
flatbufferA);
|
||||
|
||||
AssetA assetB;
|
||||
assetB.SetName("world");
|
||||
const eastl::vector<std::byte> flatbufferB = assetB.Pack();
|
||||
m_bigFile.SaveAssetFlatbuffer(AssetMetadata {.m_uuid = assetB.GetHeader().uuid,
|
||||
.m_name = assetB.GetHeader().name,
|
||||
.m_typeID = assetB.GetHeader().type_id,
|
||||
.m_typeName = assetB.GetHeader().type_name},
|
||||
flatbufferB);
|
||||
|
||||
const eastl::vector<UUID> uuids {assetA.GetHeader().uuid, UUID {}, assetB.GetHeader().uuid};
|
||||
|
||||
const eastl::vector<eastl::vector<std::byte>> flatbuffers = m_bigFile.GetAssetFlatbuffers(uuids);
|
||||
|
||||
ASSERT_EQ(flatbuffers.size(), 2);
|
||||
EXPECT_TRUE((flatbuffers[0] == flatbufferA && flatbuffers[1] == flatbufferB) ||
|
||||
(flatbuffers[0] == flatbufferB && flatbuffers[1] == flatbufferA));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(BigFileFixture, GetAssetFlatbuffers_ShouldNotDuplicateResultsForADuplicateUUID)
|
||||
{
|
||||
AssetA assetA;
|
||||
assetA.SetName("hello");
|
||||
const eastl::vector<std::byte> flatbufferA = assetA.Pack();
|
||||
m_bigFile.SaveAssetFlatbuffer(AssetMetadata {.m_uuid = assetA.GetHeader().uuid,
|
||||
.m_name = assetA.GetHeader().name,
|
||||
.m_typeID = assetA.GetHeader().type_id,
|
||||
.m_typeName = assetA.GetHeader().type_name},
|
||||
flatbufferA);
|
||||
|
||||
const eastl::vector<UUID> uuids {assetA.GetHeader().uuid, assetA.GetHeader().uuid};
|
||||
|
||||
const eastl::vector<eastl::vector<std::byte>> flatbuffers = m_bigFile.GetAssetFlatbuffers(uuids);
|
||||
|
||||
ASSERT_EQ(flatbuffers.size(), 1);
|
||||
EXPECT_EQ(flatbuffers[0], flatbufferA);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(BigFileFixture, GetAssetMetadata_ShouldReturnNulloptForNonExistentUUID)
|
||||
{
|
||||
const UUID uuid;
|
||||
|
||||
const AssetMetadata result = m_bigFile.GetAssetMetadata(uuid);
|
||||
|
||||
EXPECT_EQ(result.m_uuid, UUID::NULL_UUID);
|
||||
EXPECT_TRUE(result.m_name.empty());
|
||||
EXPECT_EQ(result.m_typeID, 0);
|
||||
EXPECT_TRUE(result.m_typeName.empty());
|
||||
EXPECT_EQ(result.m_creationTime, Time {0});
|
||||
EXPECT_EQ(result.m_modificationTime, Time {0});
|
||||
EXPECT_FALSE(m_bigFile.GetAssetMetadata(uuid).has_value());
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -94,14 +140,47 @@ TEST_F(BigFileFixture, GetAssetMetadata_ShouldGetTheAssetMetadata)
|
||||
|
||||
m_bigFile.SaveAssetFlatbuffer(metadata, flatbuffer);
|
||||
|
||||
const AssetMetadata savedMetadata = m_bigFile.GetAssetMetadata(asset.GetHeader().uuid);
|
||||
const eastl::optional<AssetMetadata> savedMetadata = m_bigFile.GetAssetMetadata(asset.GetHeader().uuid);
|
||||
ASSERT_TRUE(savedMetadata.has_value());
|
||||
|
||||
EXPECT_EQ(savedMetadata.m_uuid, metadata.m_uuid);
|
||||
EXPECT_EQ(savedMetadata.m_name, metadata.m_name);
|
||||
EXPECT_EQ(savedMetadata.m_typeID, metadata.m_typeID);
|
||||
EXPECT_EQ(savedMetadata.m_typeName, metadata.m_typeName);
|
||||
EXPECT_GT(savedMetadata.m_creationTime, Time {0});
|
||||
EXPECT_GT(savedMetadata.m_modificationTime, Time {0});
|
||||
EXPECT_EQ(savedMetadata->m_uuid, metadata.m_uuid);
|
||||
EXPECT_EQ(savedMetadata->m_name, metadata.m_name);
|
||||
EXPECT_EQ(savedMetadata->m_typeID, metadata.m_typeID);
|
||||
EXPECT_EQ(savedMetadata->m_typeName, metadata.m_typeName);
|
||||
EXPECT_GT(savedMetadata->m_creationTime, Time {0});
|
||||
EXPECT_GT(savedMetadata->m_modificationTime, Time {0});
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(BigFileFixture, GetAssetMetadatas_ShouldOmitUUIDsThatDoNotExist)
|
||||
{
|
||||
AssetA assetA;
|
||||
assetA.SetName("hello");
|
||||
m_bigFile.SaveAssetFlatbuffer(AssetMetadata {.m_uuid = assetA.GetHeader().uuid,
|
||||
.m_name = assetA.GetHeader().name,
|
||||
.m_typeID = assetA.GetHeader().type_id,
|
||||
.m_typeName = assetA.GetHeader().type_name},
|
||||
assetA.Pack());
|
||||
|
||||
AssetA assetB;
|
||||
assetB.SetName("world");
|
||||
m_bigFile.SaveAssetFlatbuffer(AssetMetadata {.m_uuid = assetB.GetHeader().uuid,
|
||||
.m_name = assetB.GetHeader().name,
|
||||
.m_typeID = assetB.GetHeader().type_id,
|
||||
.m_typeName = assetB.GetHeader().type_name},
|
||||
assetB.Pack());
|
||||
|
||||
const UUID missingUUID;
|
||||
const eastl::vector<UUID> uuids {assetA.GetHeader().uuid, missingUUID, assetB.GetHeader().uuid};
|
||||
|
||||
const eastl::vector<AssetMetadata> metadatas = m_bigFile.GetAssetMetadatas(uuids);
|
||||
|
||||
ASSERT_EQ(metadatas.size(), 2);
|
||||
EXPECT_TRUE((metadatas[0].m_uuid == assetA.GetHeader().uuid && metadatas[0].m_name == "hello" &&
|
||||
metadatas[1].m_uuid == assetB.GetHeader().uuid && metadatas[1].m_name == "world") ||
|
||||
(metadatas[0].m_uuid == assetB.GetHeader().uuid && metadatas[0].m_name == "world" &&
|
||||
metadatas[1].m_uuid == assetA.GetHeader().uuid && metadatas[1].m_name == "hello"));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -138,14 +217,18 @@ TEST_F(BigFileFixture, SaveAssetFlatbuffer_ShouldUpdateTheDataWhenCalledTwice)
|
||||
.m_typeName = eastl::string {AssetA::GetTypeName()}},
|
||||
asset.Pack());
|
||||
|
||||
const AssetMetadata savedMetadata1 = m_bigFile.GetAssetMetadata(uuid);
|
||||
EXPECT_EQ(savedMetadata1.m_name, "hello");
|
||||
EXPECT_EQ(savedMetadata1.m_typeID, AssetA::GetTypeID());
|
||||
EXPECT_EQ(savedMetadata1.m_typeName, eastl::string {AssetA::GetTypeName()});
|
||||
EXPECT_EQ(savedMetadata1.m_modificationTime, savedMetadata1.m_creationTime);
|
||||
const eastl::optional<AssetMetadata> savedMetadata1 = m_bigFile.GetAssetMetadata(uuid);
|
||||
ASSERT_TRUE(savedMetadata1.has_value());
|
||||
EXPECT_EQ(savedMetadata1->m_name, "hello");
|
||||
EXPECT_EQ(savedMetadata1->m_typeID, AssetA::GetTypeID());
|
||||
EXPECT_EQ(savedMetadata1->m_typeName, eastl::string {AssetA::GetTypeName()});
|
||||
EXPECT_EQ(savedMetadata1->m_modificationTime, savedMetadata1->m_creationTime);
|
||||
|
||||
const eastl::optional<eastl::vector<std::byte>> savedFlatbuffer1 = m_bigFile.GetAssetFlatbuffer(uuid);
|
||||
ASSERT_TRUE(savedFlatbuffer1.has_value());
|
||||
|
||||
AssetA savedAsset1;
|
||||
savedAsset1.Unpack(m_bigFile.GetAssetFlatbuffer(uuid));
|
||||
savedAsset1.Unpack(*savedFlatbuffer1);
|
||||
EXPECT_EQ(savedAsset1.GetAsset().health, 1);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
@@ -157,16 +240,20 @@ TEST_F(BigFileFixture, SaveAssetFlatbuffer_ShouldUpdateTheDataWhenCalledTwice)
|
||||
.m_typeName = eastl::string {AssetA::GetTypeName()}},
|
||||
asset.Pack());
|
||||
|
||||
const AssetMetadata savedMetadata2 = m_bigFile.GetAssetMetadata(uuid);
|
||||
EXPECT_EQ(savedMetadata2.m_name, "world");
|
||||
EXPECT_EQ(savedMetadata2.m_typeID, AssetA::GetTypeID());
|
||||
EXPECT_EQ(savedMetadata2.m_typeName, eastl::string {AssetA::GetTypeName()});
|
||||
EXPECT_GT(savedMetadata2.m_modificationTime, savedMetadata2.m_creationTime);
|
||||
const eastl::optional<AssetMetadata> savedMetadata2 = m_bigFile.GetAssetMetadata(uuid);
|
||||
ASSERT_TRUE(savedMetadata2.has_value());
|
||||
EXPECT_EQ(savedMetadata2->m_name, "world");
|
||||
EXPECT_EQ(savedMetadata2->m_typeID, AssetA::GetTypeID());
|
||||
EXPECT_EQ(savedMetadata2->m_typeName, eastl::string {AssetA::GetTypeName()});
|
||||
EXPECT_GT(savedMetadata2->m_modificationTime, savedMetadata2->m_creationTime);
|
||||
|
||||
EXPECT_LT(savedMetadata1.m_modificationTime, savedMetadata2.m_modificationTime);
|
||||
EXPECT_LT(savedMetadata1->m_modificationTime, savedMetadata2->m_modificationTime);
|
||||
|
||||
const eastl::optional<eastl::vector<std::byte>> savedFlatbuffer2 = m_bigFile.GetAssetFlatbuffer(uuid);
|
||||
ASSERT_TRUE(savedFlatbuffer2.has_value());
|
||||
|
||||
AssetA savedAsset2;
|
||||
savedAsset2.Unpack(m_bigFile.GetAssetFlatbuffer(uuid));
|
||||
savedAsset2.Unpack(*savedFlatbuffer2);
|
||||
EXPECT_EQ(savedAsset2.GetAsset().health, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,11 @@ class DataAccessorFixture: public ::testing::Test
|
||||
class DataAccessorMock: public DataAccessor
|
||||
{
|
||||
public:
|
||||
MOCK_METHOD(eastl::vector<std::byte>, GetAssetFlatbuffer, (const UUID& p_uuid), (const, override));
|
||||
MOCK_METHOD(AssetMetadata, GetAssetMetadata, (const UUID& p_uuid), (const, override));
|
||||
MOCK_METHOD(eastl::vector<eastl::vector<std::byte>>,
|
||||
GetAssetFlatbuffers,
|
||||
(eastl::span<const UUID> p_uuids),
|
||||
(const, override));
|
||||
MOCK_METHOD(eastl::vector<AssetMetadata>, GetAssetMetadatas, (eastl::span<const UUID> p_uuids), (const, override));
|
||||
MOCK_METHOD(void,
|
||||
SaveAssetFlatbuffer,
|
||||
(const AssetMetadata& p_metaData, const eastl::span<const std::byte> p_flatbuffer),
|
||||
|
||||
@@ -6,6 +6,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
endif()
|
||||
|
||||
find_package(EASTL REQUIRED)
|
||||
find_package(EAStdC REQUIRED)
|
||||
find_package(unordered_dense REQUIRED)
|
||||
if(${ASAN})
|
||||
find_package(mimalloc-asan REQUIRED)
|
||||
@@ -16,6 +17,7 @@ find_package(stduuid REQUIRED)
|
||||
find_package(SQLite3 REQUIRED)
|
||||
find_package(rapidhash REQUIRED)
|
||||
find_package(effolkronium_random REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(flatbuffers CONFIG REQUIRED)
|
||||
|
||||
if(TRACY)
|
||||
|
||||
+7
-5
@@ -64,30 +64,32 @@ class Bigfoot(ConanFile):
|
||||
|
||||
def requirements(self):
|
||||
self.requires("eastl/3.27.01@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("unordered_dense/4.8.1@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("eastdc/25082026@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("unordered_dense/4.9.2", transitive_headers=True)
|
||||
self.requires("mimalloc/3.3.2@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("stduuid/1.2.3@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("sqlite3/3.53.3@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("rapidhash/3.0@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("effolkronium-random/1.5.0", transitive_headers=True)
|
||||
self.requires("fmt/12.2.0", transitive_headers=True)
|
||||
self.requires("flatbuffers/25.12.19-2026-02-06-03fffb2-bigfoot@bigfootdev/main", transitive_headers=True)
|
||||
|
||||
if(self.settings.build_type == "RelWithDebInfo" or self.settings.build_type == "Debug"):
|
||||
self.requires("quill/12.0.0", transitive_headers=True)
|
||||
self.requires("quill/12.1.0", transitive_headers=True)
|
||||
|
||||
if(self.options.tracy):
|
||||
self.requires("tracy/0.13.1", transitive_headers=True)
|
||||
|
||||
self.requires("glm/1.0.3@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("glm/1.0.3", transitive_headers=True)
|
||||
self.requires("lodepng/cci.20260210@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("imgui/1.92.8-docking@bigfootdev/main", transitive_headers=True)
|
||||
self.requires("imgui/1.92.9b-docking", transitive_headers=True)
|
||||
|
||||
if(self.options.vulkan):
|
||||
self.requires("vulkan-headers/1.4.341.0@bigfootdev/main", override=True)
|
||||
self.requires("vulkan-memory-allocator/3.3.0@bigfootdev/main")
|
||||
|
||||
if(self.options.build_tests):
|
||||
self.test_requires("gtest/1.17.0")
|
||||
self.test_requires("gtest/1.18.0")
|
||||
self.test_requires("pixelmatch-cpp17/1.0.3@bigfootdev/main")
|
||||
|
||||
if(self.options.build_benchmarks):
|
||||
|
||||
Reference in New Issue
Block a user