12 Commits

Author SHA1 Message Date
3f02f47ee4 Maintenance
All checks were successful
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m51s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m31s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m17s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m14s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m28s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m28s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 8m1s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m43s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m12s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m18s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m24s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m17s
Bigfoot / Clang Format Checks (push) Successful in 12s
2026-05-17 16:12:32 +02:00
8685f3d1dd Formatting
All checks were successful
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m48s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m32s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m17s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m14s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m20s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m21s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m50s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m49s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m20s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m24s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m34s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m23s
Bigfoot / Clang Format Checks (push) Successful in 2m0s
2026-05-17 12:54:44 +02:00
3fe5c31fc0 Use gtest recommandation and provide global environment through main
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m14s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
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 Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
2026-05-17 12:47:34 +02:00
8996adec61 Fix logging environment causing pointer corruption
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m46s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m30s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m16s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m14s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m27s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m23s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m40s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m49s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m13s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m13s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m21s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m10s
Bigfoot / Clang Format Checks (push) Failing after 12s
2026-05-16 22:10:25 +02:00
2003121d07 Logging changes
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m39s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m30s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Failing after 5m47s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Failing after 5m39s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m20s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m28s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Failing after 7m14s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Failing after 7m11s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m19s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m14s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m19s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m21s
Bigfoot / Clang Format Checks (push) Failing after 11s
2026-05-16 20:04:32 +02:00
902ef87e1d Environment for tests
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m47s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
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 Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
2026-05-16 19:56:54 +02:00
9bea52973b Maintenance
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 5m34s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 5m32s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 6m13s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 6m9s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m24s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m23s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m38s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Failing after 6m56s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 6m13s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 6m8s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Successful in 7m31s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Successful in 7m15s
Bigfoot / Clang Format Checks (push) Failing after 12s
2026-05-16 17:48:43 +02:00
a343d65598 Maintenance
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Failing after 5m22s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
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 Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
2026-05-16 17:39:58 +02:00
bb279bb212 UUID does not have spaceship operator
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Failing after 5m22s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Failing after 5m21s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Failing after 5m44s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
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: 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 Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
2026-05-16 17:19:01 +02:00
00b86fbd00 Maintenance
Some checks failed
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Failing after 5m37s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
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 Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Has been cancelled
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Has been cancelled
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Has been cancelled
2026-05-16 17:10:17 +02:00
87d59a00c1 AssetContainer 2026-05-16 16:47:01 +02:00
2c83dcc0bc Move Singleton lifetime + refactor logs 2026-05-16 15:41:05 +02:00
42 changed files with 590 additions and 451 deletions

View File

@@ -227,12 +227,11 @@ void Iterate(benchmark::State& state)
state.SetItemsProcessed(state.iterations() * count);
}
// Register all four benchmarks for one container adapter under a readable name.
#define BIGFOOT_REGISTER_BENCHMARKS(ADAPTOR, NAME) \
BENCHMARK_TEMPLATE(Insert, ADAPTOR)->Name(NAME "/Insert")->Range(8, 8 << 20); \
BENCHMARK_TEMPLATE(Remove, ADAPTOR)->Name(NAME "/Remove")->Range(8, 8 << 20); \
BENCHMARK_TEMPLATE(Get, ADAPTOR)->Name(NAME "/Get")->Range(8, 8 << 20); \
BENCHMARK_TEMPLATE(Iterate, ADAPTOR)->Name(NAME "/Iterate")->Range(8, 8 << 20)
BENCHMARK_TEMPLATE(Insert, ADAPTOR)->Name(NAME "/Insert")->Arg(512)->Arg(8192)->Arg(262'144)->Arg(4'194'304); \
BENCHMARK_TEMPLATE(Remove, ADAPTOR)->Name(NAME "/Remove")->Arg(512)->Arg(8192)->Arg(262'144)->Arg(4'194'304); \
BENCHMARK_TEMPLATE(Get, ADAPTOR)->Name(NAME "/Get")->Arg(512)->Arg(8192)->Arg(262'144)->Arg(4'194'304); \
BENCHMARK_TEMPLATE(Iterate, ADAPTOR)->Name(NAME "/Iterate")->Arg(512)->Arg(8192)->Arg(262'144)->Arg(4'194'304);
using UnorderedDenseMapHarness = HashMapHarnessAdaptor<ankerl::unordered_dense::map<std::uint64_t, MyComplexStruct>>;
using UnorderedDenseSegementedMapHarness =
@@ -247,4 +246,5 @@ BIGFOOT_REGISTER_BENCHMARKS(UnorderedMapHarness, "std::unordered_map");
BIGFOOT_REGISTER_BENCHMARKS(MapHarness, "std::map");
#undef BIGFOOT_REGISTER_BENCHMARKS
#undef BIGFOOT_CACHE_TIER_ARGS
} // namespace Bigfoot

View File

@@ -13,11 +13,11 @@ namespace Bigfoot
BigFile::BigFile(const File& p_file)
{
[[maybe_unused]]
const int result = sqlite3_open_v2(p_file.Absolute().Path().data(), &m_db, SQLITE_OPEN_READWRITE, nullptr);
const int result = sqlite3_open_v2(p_file.ToAbsolute().GetPath().data(), &m_db, SQLITE_OPEN_READWRITE, nullptr);
CRITICAL_ASSERT(EngineAssertHandler,
result == SQLITE_OK,
"Failed to open BigFile {} DB: {}",
p_file.Absolute().Path(),
p_file.ToAbsolute().GetPath(),
sqlite3_errmsg(m_db));
}

View File

@@ -24,13 +24,17 @@ class Asset
public:
using FLAT_ASSET = typename ASSET::FLAT;
Asset()
Asset():
m_header(::Flat::Bigfoot::AssetHeaderT {.uuid = UUID {},
.name = eastl::string {},
.type_id = GetTypeID(),
.type_name = eastl::string {GetTypeName()},
.version = 0})
{
m_header.type_id = GetTypeID();
m_header.type_name = GetTypeName();
}
explicit Asset(const eastl::span<const std::byte> p_flatbuffer)
explicit Asset(const eastl::span<const std::byte> p_flatbuffer):
Asset()
{
#ifdef BIGFOOT_NOT_OPTIMIZED
flatbuffers::Verifier verifier {std::bit_cast<std::uint8_t*>(p_flatbuffer.data()), p_flatbuffer.size()};

View File

@@ -6,9 +6,10 @@
*********************************************************************/
#ifndef BIGFOOT_ENGINE_ASSET_ASSETCONTAINER_HPP
#define BIGFOOT_ENGINE_ASSET_ASSETCONTAINER_HPP
#include <Engine/Asset/Asset.hpp>
#include <Engine/EngineAssertHandler.hpp>
#include <System/UUID/UUID.hpp>
#include <Utils/Containers/SlotMap.hpp>
#include <ankerl/unordered_dense.h>
@@ -20,86 +21,82 @@ template<class ASSET>
class AssetContainer
{
public:
AssetContainer()
{
CRITICAL_ASSERT(EngineAssertHandler, !ms_instance, "Asset container already exists!");
ms_instance = this;
}
AssetContainer() = default;
AssetContainer(const AssetContainer&) = delete;
AssetContainer& operator=(const AssetContainer&) = delete;
AssetContainer(const AssetContainer& p_container) = default;
AssetContainer(AssetContainer&& p_container) = default;
~AssetContainer()
{
ms_instance = nullptr;
}
~AssetContainer() = default;
struct Entry
template<class... ARGS>
[[nodiscard]]
typename SlotMap<ASSET>::SlotKey Insert(ARGS&&... p_args)
{
std::uint32_t m_hardRefCount = 0;
std::uint32_t m_softRefCount = 0;
};
const typename SlotMap<ASSET>::SlotKey slotKey = m_assets.Insert(std::forward<ARGS>(p_args)...);
m_uuidToSlotKey.insert({m_assets.Get(slotKey)->GetHeader().uuid, slotKey});
void IncrementHardRefCount(const UUID& p_uuid)
{
++m_entries[p_uuid].m_hardRefCount;
}
void DecrementHardRefCount(const UUID& p_uuid)
{
if (const auto entry = m_entries.find(p_uuid); entry != m_entries.end())
{
CRITICAL_ASSERT(
EngineAssertHandler,
entry->second.m_hardRefCount > 0,
"Double release detected! Decrementing a hard reference to an asset that already does not have any "
"more hardrefs");
--entry->second.m_hardRefCount;
}
}
void IncrementSoftRefCount(const UUID& p_uuid)
{
++m_entries[p_uuid].m_softRefCount;
}
void DecrementSoftRefCount(const UUID& p_uuid)
{
if (const auto entry = m_entries.find(p_uuid); entry != m_entries.end())
{
CRITICAL_ASSERT(
EngineAssertHandler,
entry->second.m_softRefCount > 0,
"Double release detected! Decrementing a soft reference to an asset that already does not have any "
"more softrefs");
--entry->second.m_softRefCount;
}
return slotKey;
}
[[nodiscard]]
std::uint32_t HardRefCount(const UUID& p_uuid) const
ASSET* Get(const typename SlotMap<ASSET>::SlotKey p_key)
{
const auto entry = m_entries.find(p_uuid);
return entry != m_entries.end() ? entry->second.m_hardRefCount : 0;
return m_assets.Get(p_key);
}
[[nodiscard]]
std::uint32_t SoftRefCount(const UUID& p_uuid) const
const ASSET* Get(const typename SlotMap<ASSET>::SlotKey p_key) const
{
const auto entry = m_entries.find(p_uuid);
return entry != m_entries.end() ? entry->second.m_softRefCount : 0;
return m_assets.Get(p_key);
}
[[nodiscard]]
static AssetContainer& Get()
typename SlotMap<ASSET>::SlotKey GetSlotKey(const UUID& p_uuid) const
{
return *ms_instance;
if (const auto it = m_uuidToSlotKey.find(p_uuid); it != m_uuidToSlotKey.end())
{
return it->second;
}
return typename SlotMap<ASSET>::SlotKey {};
}
[[nodiscard]]
bool Has(const typename SlotMap<ASSET>::SlotKey p_key) const
{
return m_assets.Has(p_key);
}
[[nodiscard]]
bool Has(const UUID& p_uuid) const
{
return m_uuidToSlotKey.contains(p_uuid);
}
void Remove(const typename SlotMap<ASSET>::SlotKey p_key)
{
if (const ASSET* asset = Get(p_key))
{
const UUID uuid = asset->GetHeader().uuid;
m_assets.Remove(p_key);
m_uuidToSlotKey.erase(uuid);
}
}
void Remove(const UUID& p_uuid)
{
if (const auto it = m_uuidToSlotKey.find(p_uuid); it != m_uuidToSlotKey.end())
{
Remove(it->second);
}
}
AssetContainer& operator=(const AssetContainer& p_container) = default;
AssetContainer& operator=(AssetContainer&& p_container) = default;
private:
ankerl::unordered_dense::segmented_map<UUID, Entry> m_entries;
ankerl::unordered_dense::segmented_map<UUID, typename SlotMap<ASSET>::SlotKey> m_uuidToSlotKey;
inline static constinit AssetContainer* ms_instance = nullptr;
SlotMap<ASSET> m_assets;
};
} // namespace Bigfoot

View File

@@ -24,19 +24,11 @@
Bigfoot::HardReference<AssetType> UnPackHardReference##AssetName(const Flat::Bigfoot::HardReference& p_hardRef); \
}
#define ASSET_CONTAINER(AssetName, AssetType) \
namespace Bigfoot \
{ \
inline AssetContainer<AssetType> g_##AssetName##Container; \
}
#define ASSET_REF_DECL(AssetName, AssetType) \
ASSET_SOFT_REF_DECL(AssetName, AssetType) \
ASSET_HARD_REF_DECL(AssetName, AssetType)
#define ASSET_DECL(AssetName, AssetType) \
ASSET_REF_DECL(AssetName, AssetType) \
ASSET_CONTAINER(AssetName, AssetType)
#define ASSET_DECL(AssetName, AssetType) ASSET_REF_DECL(AssetName, AssetType)
/****************************************************************************************/

View File

@@ -80,7 +80,7 @@ class HardReference
{
if (m_uuid)
{
AssetContainer<ASSET>::Get().IncrementHardRefCount(m_uuid);
// AssetContainer<ASSET>::Get().IncrementHardRefCount(m_uuid);
}
}
@@ -88,7 +88,7 @@ class HardReference
{
if (m_uuid)
{
AssetContainer<ASSET>::Get().DecrementHardRefCount(m_uuid);
// AssetContainer<ASSET>::Get().DecrementHardRefCount(m_uuid);
}
}
@@ -161,7 +161,7 @@ class SoftReference
{
if (m_uuid)
{
AssetContainer<ASSET>::Get().IncrementSoftRefCount(m_uuid);
// AssetContainer<ASSET>::Get().IncrementSoftRefCount(m_uuid);
}
}
@@ -169,7 +169,7 @@ class SoftReference
{
if (m_uuid)
{
AssetContainer<ASSET>::Get().DecrementSoftRefCount(m_uuid);
// AssetContainer<ASSET>::Get().DecrementSoftRefCount(m_uuid);
}
}

View File

@@ -11,11 +11,9 @@
#include <Utils/Assert.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <EASTL/utility.h>
#include <format>
#include <source_location>
#include <string_view>
namespace Bigfoot
{

View File

@@ -6,7 +6,7 @@
*********************************************************************/
#ifndef BIGFOOT_ENGINELOGGER_GENERATED_HPP
#define BIGFOOT_ENGINELOGGER_GENERATED_HPP
#include <Utils/Log/Log.hpp>
#include <Utils/Log/LogMacros.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED

View File

@@ -37,21 +37,21 @@ bool File::Exists() const
/****************************************************************************************/
eastl::string_view File::Path() const
eastl::string_view File::GetPath() const
{
return m_pathString;
}
/****************************************************************************************/
File File::Absolute() const
File File::ToAbsolute() const
{
return File {std::filesystem::absolute(m_path)};
}
/****************************************************************************************/
File File::Relative() const
File File::ToRelative() const
{
return File {std::filesystem::relative(m_path)};
}

View File

@@ -57,7 +57,7 @@ class File
* \return The path
*/
[[nodiscard]]
eastl::string_view Path() const;
eastl::string_view GetPath() const;
/**
* Get the same file, relative to the current executable
@@ -65,7 +65,7 @@ class File
* \return The relative file
*/
[[nodiscard]]
File Relative() const;
File ToRelative() const;
/**
* Get the same file, with an absolute path
@@ -73,7 +73,7 @@ class File
* \return The absolute file
*/
[[nodiscard]]
File Absolute() const;
File ToAbsolute() const;
~File() = default;

View File

@@ -11,11 +11,9 @@
#include <Utils/Assert.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <EASTL/utility.h>
#include <format>
#include <source_location>
#include <string_view>
namespace Bigfoot
{

View File

@@ -6,7 +6,7 @@
*********************************************************************/
#ifndef BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
#define BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
#include <Utils/Log/Log.hpp>
#include <Utils/Log/LogMacros.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED

View File

@@ -21,28 +21,28 @@ class Time
Time(Time&& p_time) = default;
[[nodiscard]]
std::uint32_t Year() const;
std::uint32_t GetYear() const;
[[nodiscard]]
std::uint32_t Month() const;
std::uint32_t GetMonth() const;
[[nodiscard]]
std::uint32_t Day() const;
std::uint32_t GetDay() const;
[[nodiscard]]
std::uint32_t Hour() const;
std::uint32_t GetHour() const;
[[nodiscard]]
std::uint32_t Minute() const;
std::uint32_t GetMinute() const;
[[nodiscard]]
std::uint32_t Second() const;
std::uint32_t GetSecond() const;
[[nodiscard]]
std::uint32_t Microsecond() const;
std::uint32_t GetMicrosecond() const;
[[nodiscard]]
std::uint64_t Epoch() const;
std::uint64_t GetEpoch() const;
~Time() = default;

View File

@@ -34,19 +34,31 @@ class UUID
UUID(const UUID& p_uuid) = default;
UUID(UUID&& p_uuid) noexcept = default;
/**
* Gets the raw bytes of a UUID
*
* \return A view to the raw bytes
*/
[[nodiscard]]
std::span<const std::byte, UUID_BYTE_SIZE> ToBytes() const;
/**
* Gets the string representation of a UUID
*
* \return A string representing the UUID
*/
[[nodiscard]]
std::string ToString() const;
~UUID() = default;
operator std::span<const std::byte, UUID_BYTE_SIZE>() const;
operator std::string() const;
operator bool() const;
UUID& operator=(const UUID& p_uuid) = default;
UUID& operator=(UUID&& p_uuid) noexcept = default;
[[nodiscard]]
bool operator==(const UUID& p_uuid) const = default;
[[nodiscard]]
bool operator!=(const UUID& p_uuid) const = default;
bool operator==(const UUID& p_uuid) const;
[[nodiscard]]
bool operator<(const UUID& p_uuid) const;
@@ -113,7 +125,7 @@ struct std::formatter<Bigfoot::UUID, char>
template<typename FormatContext>
auto format(const Bigfoot::UUID& p_uuid, FormatContext& ctx) const
{
return std::format_to(ctx.out(), "{}", static_cast<std::string>(p_uuid));
return std::format_to(ctx.out(), "{}", p_uuid.ToString());
}
};
@@ -132,7 +144,7 @@ struct fmtquill::formatter<Bigfoot::UUID>
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
{
return fmtquill::format_to(ctx.out(), "{}", static_cast<std::string>(p_uuid));
return fmtquill::format_to(ctx.out(), "{}", p_uuid.ToString());
}
};

View File

@@ -55,56 +55,56 @@ Time::Time(const std::uint64_t p_epoch):
/****************************************************************************************/
std::uint32_t Time::Year() const
std::uint32_t Time::GetYear() const
{
return m_timeInfo.tm_year + 1900;
}
/****************************************************************************************/
std::uint32_t Time::Month() const
std::uint32_t Time::GetMonth() const
{
return m_timeInfo.tm_mon + 1;
}
/****************************************************************************************/
std::uint32_t Time::Day() const
std::uint32_t Time::GetDay() const
{
return m_timeInfo.tm_mday;
}
/****************************************************************************************/
std::uint32_t Time::Hour() const
std::uint32_t Time::GetHour() const
{
return m_timeInfo.tm_hour;
}
/****************************************************************************************/
std::uint32_t Time::Minute() const
std::uint32_t Time::GetMinute() const
{
return m_timeInfo.tm_min;
}
/****************************************************************************************/
std::uint32_t Time::Second() const
std::uint32_t Time::GetSecond() const
{
return m_timeInfo.tm_sec;
}
/****************************************************************************************/
std::uint32_t Time::Microsecond() const
std::uint32_t Time::GetMicrosecond() const
{
return static_cast<std::uint32_t>(m_microseconds.count());
}
/****************************************************************************************/
std::uint64_t Time::Epoch() const
std::uint64_t Time::GetEpoch() const
{
return m_epoch;
}
@@ -127,7 +127,7 @@ namespace flatbuffers
{
Flat::Bigfoot::Time Pack(const Bigfoot::Time& p_time)
{
return Flat::Bigfoot::Time {p_time.Epoch()};
return Flat::Bigfoot::Time {p_time.GetEpoch()};
}
/****************************************************************************************/

View File

@@ -43,14 +43,14 @@ UUID::UUID(const std::span<const std::byte, UUID_BYTE_SIZE> p_raw)
/****************************************************************************************/
UUID::operator std::span<const std::byte, UUID::UUID_BYTE_SIZE>() const
std::span<const std::byte, UUID::UUID_BYTE_SIZE> UUID::ToBytes() const
{
return m_uuid.as_bytes();
}
/****************************************************************************************/
UUID::operator std::string() const
std::string UUID::ToString() const
{
return uuids::to_string(m_uuid);
}
@@ -62,6 +62,11 @@ UUID::operator bool() const
return *this != NULL_UUID;
}
bool UUID::operator==(const UUID& p_uuid) const
{
return m_uuid == p_uuid.m_uuid;
}
/****************************************************************************************/
bool UUID::operator<(const UUID& p_uuid) const
@@ -94,7 +99,7 @@ namespace flatbuffers
{
Flat::Bigfoot::UUID Pack(const Bigfoot::UUID& p_uuid)
{
const std::span<const std::byte, Bigfoot::UUID::UUID_BYTE_SIZE> bytes = p_uuid;
const std::span<const std::byte, Bigfoot::UUID::UUID_BYTE_SIZE> bytes = p_uuid.ToBytes();
return Flat::Bigfoot::UUID {
std::span<const std::uint8_t, Bigfoot::UUID::UUID_BYTE_SIZE> {reinterpret_cast<const std::uint8_t*>(bytes.data()),
bytes.size()}};

View File

@@ -6,7 +6,7 @@
*********************************************************************/
#ifndef BIGFOOT_UTILS_ASSERT_HPP
#define BIGFOOT_UTILS_ASSERT_HPP
#include <Utils/Log/Log.hpp>
#include <Utils/Log/LogMacros.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
@@ -62,7 +62,7 @@
HANDLER::Handle(location, p_message __VA_OPT__(, ) __VA_ARGS__); \
if (Bigfoot::Singleton<Bigfoot::Log>::HasInstance()) \
{ \
Bigfoot::Singleton<Bigfoot::Log>::Instance().Flush(); \
Bigfoot::Singleton<Bigfoot::Log>::GetInstance().Flush(); \
} \
BREAK; \
std::abort(); \

View File

@@ -61,15 +61,15 @@ class SlotMap
constexpr bool Valid() const
{
return Version() != INVALID_VERSION;
return GetVersion() != INVALID_VERSION;
}
constexpr VersionType Version() const
constexpr VersionType GetVersion() const
{
return static_cast<VersionType>(m_key >> INDEX_BIT_COUNT);
}
constexpr IndexType Index() const
constexpr IndexType GetIndex() const
{
return static_cast<IndexType>(m_key & INDEX_MASK);
}
@@ -107,12 +107,12 @@ class SlotMap
{
const typename SlotKey::IndexType slotIndex = m_freeSlotHead;
m_freeSlotHead = m_slots[slotIndex].Index();
m_freeSlotHead = m_slots[slotIndex].GetIndex();
m_slots[slotIndex] = SlotKey {m_slots[slotIndex].Version(), dataIndex};
m_slots[slotIndex] = SlotKey {m_slots[slotIndex].GetVersion(), dataIndex};
m_dataToSlots.push_back(slotIndex);
return SlotKey {m_slots[slotIndex].Version(), slotIndex};
return SlotKey {m_slots[slotIndex].GetVersion(), slotIndex};
}
const typename SlotKey::IndexType slotIndex = static_cast<SlotKey::IndexType>(m_slots.size());
@@ -129,36 +129,36 @@ class SlotMap
return;
}
const typename SlotKey::IndexType dataIndex = m_slots[p_slotKey.Index()].Index();
const typename SlotKey::IndexType dataIndex = m_slots[p_slotKey.GetIndex()].GetIndex();
m_data.erase_unsorted(m_data.begin() + dataIndex);
m_dataToSlots.erase_unsorted(m_dataToSlots.begin() + dataIndex);
if (dataIndex < m_data.size())
{
m_slots[m_dataToSlots[dataIndex]] = SlotKey {m_slots[m_dataToSlots[dataIndex]].Version(), dataIndex};
m_slots[m_dataToSlots[dataIndex]] = SlotKey {m_slots[m_dataToSlots[dataIndex]].GetVersion(), dataIndex};
}
RecycleSlot(p_slotKey.Version() + 1, p_slotKey.Index());
RecycleSlot(p_slotKey.GetVersion() + 1, p_slotKey.GetIndex());
}
[[nodiscard]]
bool Has(const SlotKey p_slotKey) const
{
return p_slotKey.Valid() &&
(p_slotKey.Index() < m_slots.size() && p_slotKey.Version() == m_slots[p_slotKey.Index()].Version());
return p_slotKey.Valid() && (p_slotKey.GetIndex() < m_slots.size() &&
p_slotKey.GetVersion() == m_slots[p_slotKey.GetIndex()].GetVersion());
}
[[nodiscard]]
TYPE* Get(const SlotKey p_slotKey)
{
return Has(p_slotKey) ? &m_data[m_slots[p_slotKey.Index()].Index()] : nullptr;
return Has(p_slotKey) ? &m_data[m_slots[p_slotKey.GetIndex()].GetIndex()] : nullptr;
}
[[nodiscard]]
const TYPE* Get(const SlotKey p_slotKey) const
{
return Has(p_slotKey) ? &m_data[m_slots[p_slotKey.Index()].Index()] : nullptr;
return Has(p_slotKey) ? &m_data[m_slots[p_slotKey.GetIndex()].GetIndex()] : nullptr;
}
void Reset()
@@ -173,7 +173,7 @@ class SlotMap
{
for (const typename eastl::vector<TYPE>::size_type slotIndex: m_dataToSlots)
{
RecycleSlot(m_slots[slotIndex].Version() + 1, static_cast<SlotKey::IndexType>(slotIndex));
RecycleSlot(m_slots[slotIndex].GetVersion() + 1, static_cast<SlotKey::IndexType>(slotIndex));
}
m_data.clear();
@@ -181,13 +181,13 @@ class SlotMap
}
[[nodiscard]]
eastl::vector<TYPE>::size_type Size() const
eastl::vector<TYPE>::size_type GetSize() const
{
return m_data.size();
}
[[nodiscard]]
eastl::vector<TYPE>::size_type Capacity() const
eastl::vector<TYPE>::size_type GetCapacity() const
{
return m_data.capacity();
}

View File

@@ -10,7 +10,6 @@
#if defined BIGFOOT_NOT_OPTIMIZED
#include <Utils/Log/Log_generated.hpp>
#include <Utils/Singleton.hpp>
#include <EASTL/array.h>
@@ -50,6 +49,13 @@ class Log
[[nodiscard]]
quill::Logger* RegisterLogger(const LoggerInfo& p_loggerInfo);
/**
* Unregister a logger.
*
* \param p_loggerInfo The logger to unregister
*/
void UnregisterLogger(const LoggerInfo& p_loggerInfo);
/**
* Register a logger.
*
@@ -92,96 +98,5 @@ class Log
eastl::array<std::shared_ptr<quill::Sink>, 1> m_sinks;
};
} // namespace Bigfoot
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_DEBUG(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_TRACE_L3(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_INFO(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_WARNING(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_ERROR(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_CRITICAL(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#else
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...)
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...)
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...)
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...)
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...)
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...)
#endif
#endif

View File

@@ -0,0 +1,104 @@
/*********************************************************************
* \file LogMacros.hpp
*
* \author Romain BOULLARD
* \date May 2026
*********************************************************************/
#ifndef BIGFOOT_UTILS_LOG_LOGMACROS_HPP
#define BIGFOOT_UTILS_LOG_LOGMACROS_HPP
#include <Utils/Log/Log.hpp>
#include <Utils/Singleton.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...) \
do \
{ \
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
{ \
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_DEBUG(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...) \
do \
{ \
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
{ \
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_TRACE_L3(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...) \
do \
{ \
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
{ \
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_INFO(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...) \
do \
{ \
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
{ \
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_WARNING(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...) \
do \
{ \
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
{ \
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_ERROR(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...) \
do \
{ \
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
{ \
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_CRITICAL(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#else
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...)
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...)
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...)
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...)
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...)
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...)
#endif
#endif

View File

@@ -6,7 +6,7 @@
*********************************************************************/
#ifndef BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
#define BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
#include <Utils/Log/Log.hpp>
#include <Utils/Log/LogMacros.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED

View File

@@ -6,12 +6,7 @@
*********************************************************************/
#ifndef BIGFOOT_UTILS_SINGLETON_HPP
#define BIGFOOT_UTILS_SINGLETON_HPP
#include <EASTL/array.h>
#include <EASTL/bit.h>
#include <EASTL/optional.h>
#include <EASTL/type_traits.h>
#include <EASTL/utility.h>
namespace Bigfoot
{
@@ -31,7 +26,7 @@ class Singleton
*
* \return The instance
*/
static constexpr TYPE& Instance()
static constexpr TYPE& GetInstance()
{
return ms_instance.value();
}
@@ -69,7 +64,7 @@ class Singleton
}
Lifetime& operator=(const Lifetime& p_lifetime) = delete;
Lifetime& operator=(Lifetime&& p_lifetime) = delete;
Lifetime& operator=(Lifetime&& p_lifetime) noexcept = delete;
};
Singleton& operator=(const Singleton& p_singleton) = delete;

View File

@@ -7,15 +7,12 @@
#ifndef BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
#define BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
#include <Utils/Assert.hpp>
#include <Utils/Log/Log.hpp>
#include <Utils/UtilsLogger_generated.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <EASTL/utility.h>
#include <format>
#include <source_location>
#include <string_view>
namespace Bigfoot
{

View File

@@ -6,7 +6,7 @@
*********************************************************************/
#ifndef BIGFOOT_UTILSLOGGER_GENERATED_HPP
#define BIGFOOT_UTILSLOGGER_GENERATED_HPP
#include <Utils/Log/Log.hpp>
#include <Utils/Log/LogMacros.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED

View File

@@ -53,7 +53,7 @@ class Version
* \return The major part of the version.
*/
[[nodiscard]]
constexpr std::uint8_t Major() const
constexpr std::uint8_t GetMajor() const
{
constexpr std::uint32_t mask = 0b00000000111111110000000000000000;
@@ -66,7 +66,7 @@ class Version
* \return The minor part of the version.
*/
[[nodiscard]]
constexpr std::uint8_t Minor() const
constexpr std::uint8_t GetMinor() const
{
constexpr std::uint32_t mask = 0b00000000000000001111111100000000;
@@ -79,54 +79,37 @@ class Version
* \return The patch part of the version.
*/
[[nodiscard]]
constexpr std::uint8_t Patch() const
constexpr std::uint8_t GetPatch() const
{
constexpr std::uint32_t mask = 0b00000000000000000000000011111111;
return static_cast<std::uint8_t>(m_combined & mask);
}
/**
* Gets the raw Version
*
* \return the raw version
*/
[[nodiscard]]
constexpr operator std::uint32_t() const
constexpr std::uint32_t Raw() const
{
return m_combined;
}
operator std::string() const;
/**
* Gets the string representation of the Version
*
* \return The string
*/
[[nodiscard]]
std::string ToString() const;
constexpr Version& operator=(const Version& p_version) = default;
constexpr Version& operator=(Version&& p_version) = default;
[[nodiscard]]
constexpr bool operator>(const Version& p_version) const
{
return m_combined > p_version.m_combined;
}
[[nodiscard]]
constexpr bool operator<(const Version& p_version) const
{
return m_combined < p_version.m_combined;
}
[[nodiscard]]
constexpr bool operator>=(const Version& p_version) const
{
return m_combined >= p_version.m_combined;
}
[[nodiscard]]
constexpr bool operator<=(const Version& p_version) const
{
return m_combined <= p_version.m_combined;
}
[[nodiscard]]
constexpr bool operator==(const Version& p_version) const = default;
[[nodiscard]]
constexpr bool operator!=(const Version& p_version) const = default;
constexpr auto operator<=>(const Version& p_version) const = default;
private:
/**
@@ -151,7 +134,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(), "{}", static_cast<std::string>(p_version));
return std::format_to(p_context.out(), "{}", p_version.ToString());
}
};
#endif

View File

@@ -33,6 +33,16 @@ quill::Logger* Log::RegisterLogger(const LoggerInfo& p_loggerInfo)
/****************************************************************************************/
void Log::UnregisterLogger(const LoggerInfo& p_loggerInfo)
{
if (quill::Logger* logger = quill::Frontend::get_logger(p_loggerInfo.m_name))
{
quill::Frontend::remove_logger_blocking(logger);
}
}
/****************************************************************************************/
quill::Logger* Log::GetLogger(const LoggerInfo& p_loggerInfo)
{
return quill::Frontend::get_logger(p_loggerInfo.m_name);
@@ -92,12 +102,10 @@ void Log::Flush()
Log::~Log()
{
Flush();
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
{
quill::Frontend::remove_logger(logger);
quill::Frontend::remove_logger_blocking(logger);
}
quill::Backend::stop();
}
} // namespace Bigfoot

View File

@@ -8,8 +8,8 @@
namespace Bigfoot
{
Version::operator std::string() const
std::string Version::ToString() const
{
return std::format("{}.{}.{}", Major(), Minor(), Patch());
return std::format("{}.{}.{}", GetMajor(), GetMinor(), GetPatch());
}
} // namespace Bigfoot

View File

@@ -6,12 +6,6 @@
*********************************************************************/
#include <Engine/Asset/Asset.hpp>
#include <Engine/EngineLogger_generated.hpp>
#include <Utils/Log/Log.hpp>
#include <Utils/Singleton.hpp>
#include <Utils/TargetMacros.h>
#include <EngineTests/Asset/AssetA.hpp>
#include <EngineTests/Asset/AssetB.hpp>
#include <EngineTests/Asset/AssetC.hpp>
@@ -23,12 +17,6 @@ namespace Bigfoot
class AssetFixture: public ::testing::Test
{
protected:
void SetUp() override
{
BIGFOOT_NOT_OPTIMIZED_ONLY(std::ignore = Singleton<Log>::Instance().RegisterLogger(ENGINE_LOGGER);)
}
BIGFOOT_NOT_OPTIMIZED_ONLY(Singleton<Log>::Lifetime m_loggerLifetime;)
};
/****************************************************************************************/

View File

@@ -0,0 +1,73 @@
/*********************************************************************
* \file BigFile.cpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#include <Engine/Asset/AssetContainer.hpp>
#include <EngineTests/Asset/AssetA.hpp>
#include <gtest/gtest.h>
namespace Bigfoot
{
class AssetContainerFixture: public ::testing::Test
{
protected:
AssetContainer<AssetA> m_container;
};
/****************************************************************************************/
TEST_F(AssetContainerFixture, Insert)
{
std::ignore = m_container.Insert();
}
/****************************************************************************************/
TEST_F(AssetContainerFixture, Get)
{
const auto key = m_container.Insert();
const auto& constContainer = m_container;
const auto validateKey = [&](auto& p_assetContainer)
{
const auto asset = p_assetContainer.Get(key);
EXPECT_NE(asset, nullptr);
};
validateKey(m_container);
validateKey(constContainer);
}
/****************************************************************************************/
TEST_F(AssetContainerFixture, GetSlotKey)
{
const auto key = m_container.Insert();
const auto asset = m_container.Get(key);
EXPECT_EQ(m_container.GetSlotKey(asset->GetHeader().uuid), key);
}
/****************************************************************************************/
TEST_F(AssetContainerFixture, Has)
{
const auto key = m_container.Insert();
EXPECT_TRUE(m_container.Has(key));
EXPECT_TRUE(m_container.Has(m_container.Get(key)->GetHeader().uuid));
}
/****************************************************************************************/
TEST_F(AssetContainerFixture, Remove)
{
const auto key1 = m_container.Insert();
m_container.Remove(key1);
const auto key2 = m_container.Insert();
m_container.Remove(m_container.Get(key2)->GetHeader().uuid);
}
} // namespace Bigfoot

View File

@@ -6,15 +6,9 @@
*********************************************************************/
#include <Engine/BigFile/BigFile.hpp>
#include <Engine/EngineLogger_generated.hpp>
#include <System/Time/Time.hpp>
#include <System/UUID/UUID.hpp>
#include <Utils/Log/Log.hpp>
#include <Utils/Singleton.hpp>
#include <Utils/TargetMacros.h>
#include <EngineTests/BigFileInfo_generated.hpp>
#include <ankerl/unordered_dense.h>
@@ -35,12 +29,8 @@ class BigFileFixture: public ::testing::Test
deleteHeader.Execute();
deleteAsset.Execute();
m_bigFile.CommitTransaction();
BIGFOOT_NOT_OPTIMIZED_ONLY(std::ignore = Singleton<Log>::Instance().RegisterLogger(ENGINE_LOGGER);)
}
BIGFOOT_NOT_OPTIMIZED_ONLY(Singleton<Log>::Lifetime m_loggerLifetime;)
BigFile m_bigFile {File {BIGFILE_ENGINETESTS_LOCATION}};
};
@@ -63,37 +53,37 @@ TEST_F(BigFileFixture, BigFileManipulation)
BigFile::Request assetHeaderRequest {
m_bigFile,
"INSERT INTO AssetHeader (UUID, Name, TypeID, TypeName) VALUES(?, ?, ?, ?)"};
assetHeaderRequest.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid));
assetHeaderRequest.Bind(1, uuid.ToBytes());
assetHeaderRequest.Bind(2, "Test");
assetHeaderRequest.Bind(3, typeIDRef);
assetHeaderRequest.Bind(4, "TypeTest");
BigFile::Request assetRequest {m_bigFile, "INSERT INTO Asset (UUID, Asset) VALUES(?, ?)"};
assetRequest.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid));
assetRequest.Bind(1, uuid.ToBytes());
assetRequest.Bind(2, blob);
BigFile::Request assetHeaderRequest2 {
m_bigFile,
"INSERT INTO AssetHeader (UUID, Name, TypeID, TypeName) VALUES(?, ?, ?, ?)"};
assetHeaderRequest2.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid2));
assetHeaderRequest2.Bind(1, uuid2.ToBytes());
assetHeaderRequest2.Bind(2, "Test2");
assetHeaderRequest2.Bind(3, typeIDRef);
assetHeaderRequest2.Bind(4, "TypeTest");
BigFile::Request assetRequest2 {m_bigFile, "INSERT INTO Asset (UUID, Asset) VALUES(?, ?)"};
assetRequest2.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid2));
assetRequest2.Bind(1, uuid2.ToBytes());
assetRequest2.Bind(2, blob3);
BigFile::Request assetHeaderRequest3 {
m_bigFile,
"INSERT INTO AssetHeader (UUID, Name, TypeID, TypeName) VALUES(?, ?, ?, ?)"};
assetHeaderRequest3.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid3));
assetHeaderRequest3.Bind(1, uuid3.ToBytes());
assetHeaderRequest3.Bind(2, "Test3");
assetHeaderRequest3.Bind(3, typeIDRef);
assetHeaderRequest3.Bind(4, "TypeTest");
BigFile::Request assetRequest3 {m_bigFile, "INSERT INTO Asset (UUID, Asset) VALUES(?, ?)"};
assetRequest3.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid3));
assetRequest3.Bind(1, uuid3.ToBytes());
assetRequest3.Bind(2, blob4);
m_bigFile.BeginTransaction();
@@ -118,7 +108,7 @@ TEST_F(BigFileFixture, BigFileManipulation)
{
BigFile::Request updateAsset {m_bigFile, "UPDATE Asset SET Asset = ? WHERE UUID = ?"};
updateAsset.Bind(1, blob2);
updateAsset.Bind(2, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid));
updateAsset.Bind(2, uuid.ToBytes());
m_bigFile.BeginTransaction();
std::uint32_t updateAssetChangedCount = updateAsset.Execute();
@@ -130,7 +120,7 @@ TEST_F(BigFileFixture, BigFileManipulation)
BigFile::Request request {
m_bigFile,
"SELECT Name, TypeID, TypeName, CreateTime, ModificationTime FROM AssetHeader WHERE UUID = ?"};
request.Bind(1, static_cast<std::span<const std::byte, UUID::UUID_BYTE_SIZE>>(uuid));
request.Bind(1, uuid.ToBytes());
const bool get = request.Step();
EXPECT_TRUE(get);
@@ -145,13 +135,13 @@ TEST_F(BigFileFixture, BigFileManipulation)
const Time createTime = static_cast<std::uint64_t>(request.Get(3));
const Time modificationTime = static_cast<std::uint64_t>(request.Get(4));
EXPECT_GT(createTime.Epoch(), 0);
EXPECT_GT(modificationTime.Epoch(), 0);
EXPECT_GT(createTime.GetEpoch(), 0);
EXPECT_GT(modificationTime.GetEpoch(), 0);
EXPECT_GE(createTime, modificationTime);
EXPECT_GT(createTime.Year(), 2025);
EXPECT_GT(modificationTime.Year(), 2025);
EXPECT_GT(createTime.GetYear(), 2025);
EXPECT_GT(modificationTime.GetYear(), 2025);
}
}
} // namespace Bigfoot

View File

@@ -0,0 +1,19 @@
/*********************************************************************
* \file main.cpp
*
* \author Romain BOULLARD
* \date May 2026
*********************************************************************/
#include <Utils/Log/LogMacros.hpp>
#include <Utils/TargetMacros.h>
#include <gtest/gtest.h>
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime);
return RUN_ALL_TESTS();
}

View File

@@ -28,14 +28,14 @@ TEST_F(FileFixture, IsRelative_ShouldReturnTrueOnRelativeFile)
TEST_F(FileFixture, IsRelative_ShouldReturnFalseOnAbsoluteFile)
{
EXPECT_FALSE(m_file.Absolute().IsRelative());
EXPECT_FALSE(m_file.ToAbsolute().IsRelative());
}
/****************************************************************************************/
TEST_F(FileFixture, IsAbsolute_ShouldReturnTrueOnAbsoluteFile)
{
EXPECT_TRUE(m_file.Absolute().IsAbsolute());
EXPECT_TRUE(m_file.ToAbsolute().IsAbsolute());
}
TEST_F(FileFixture, IsAbsolute_ShouldReturnFalseOnRelativeFile)
@@ -59,22 +59,22 @@ TEST_F(FileFixture, Exists_ShouldReturnFalseOnNonExistingFile)
/****************************************************************************************/
TEST_F(FileFixture, Path_ShouldReturnThePath)
TEST_F(FileFixture, GetPath_ShouldReturnThePath)
{
EXPECT_STREQ(m_file.Path().data(), "Fixture/file");
EXPECT_STREQ(m_file.GetPath().data(), "Fixture/file");
}
/****************************************************************************************/
TEST_F(FileFixture, Absolute_ShouldReturnTheAbsolutePath)
TEST_F(FileFixture, ToAbsolute_ShouldReturnTheAbsolutePath)
{
EXPECT_STREQ(std::filesystem::absolute("Fixture/file").string().c_str(), m_file.Absolute().Path().data());
EXPECT_STREQ(std::filesystem::absolute("Fixture/file").string().c_str(), m_file.ToAbsolute().GetPath().data());
}
/****************************************************************************************/
TEST_F(FileFixture, Relative_ShouldReturnTheRelativePath)
TEST_F(FileFixture, ToRelative_ShouldReturnTheRelativePath)
{
EXPECT_STREQ(std::filesystem::relative("Fixture/file").string().c_str(), m_file.Relative().Path().data());
EXPECT_STREQ(std::filesystem::relative("Fixture/file").string().c_str(), m_file.ToRelative().GetPath().data());
}
} // namespace Bigfoot

View File

@@ -0,0 +1,19 @@
/*********************************************************************
* \file main.cpp
*
* \author Romain BOULLARD
* \date May 2026
*********************************************************************/
#include <Utils/Log/LogMacros.hpp>
#include <Utils/TargetMacros.h>
#include <gtest/gtest.h>
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime);
return RUN_ALL_TESTS();
}

View File

@@ -18,50 +18,50 @@ class TimeFixture: public ::testing::Test
/****************************************************************************************/
TEST_F(TimeFixture, Year_ShouldReturnTheYear)
TEST_F(TimeFixture, GetYear_ShouldReturnTheYear)
{
EXPECT_EQ(m_time.Year(), 2026);
EXPECT_EQ(m_time.GetYear(), 2026);
}
/****************************************************************************************/
TEST_F(TimeFixture, Month_ShouldReturnTheMonth)
TEST_F(TimeFixture, GetMonth_ShouldReturnTheMonth)
{
EXPECT_EQ(m_time.Month(), 1);
EXPECT_EQ(m_time.GetMonth(), 1);
}
/****************************************************************************************/
TEST_F(TimeFixture, Day_ShouldReturnTheDay)
TEST_F(TimeFixture, GetDay_ShouldReturnTheDay)
{
EXPECT_EQ(m_time.Day(), 5);
EXPECT_EQ(m_time.GetDay(), 5);
}
/****************************************************************************************/
TEST_F(TimeFixture, Hour_ShouldReturnTheHour)
TEST_F(TimeFixture, GetHour_ShouldReturnTheHour)
{
EXPECT_EQ(m_time.Hour(), 20);
EXPECT_EQ(m_time.GetHour(), 20);
}
/****************************************************************************************/
TEST_F(TimeFixture, Minute_ShouldReturnTheMinute)
TEST_F(TimeFixture, GetMinute_ShouldReturnTheMinute)
{
EXPECT_EQ(m_time.Minute(), 9);
EXPECT_EQ(m_time.GetMinute(), 9);
}
/****************************************************************************************/
TEST_F(TimeFixture, Second_ShouldReturnTheSecond)
TEST_F(TimeFixture, GetSecond_ShouldReturnTheSecond)
{
EXPECT_EQ(m_time.Second(), 6);
EXPECT_EQ(m_time.GetSecond(), 6);
}
/****************************************************************************************/
TEST_F(TimeFixture, Microsecond_ShouldReturnTheMicrosecond)
TEST_F(TimeFixture, GetMicrosecond_ShouldReturnTheMicrosecond)
{
EXPECT_EQ(m_time.Microsecond(), 680'609);
EXPECT_EQ(m_time.GetMicrosecond(), 680'609);
}
} // namespace Bigfoot

View File

@@ -43,13 +43,13 @@ class UUIDFixture: public ::testing::Test
TEST_F(UUIDFixture, DumpingRawAndConstructAnUUIDWithItShouldGiveTheSameUUID)
{
std::span<const std::byte, UUID::UUID_BYTE_SIZE> raw = m_a;
std::span<const std::byte, UUID::UUID_BYTE_SIZE> raw = m_a.ToBytes();
EXPECT_EQ(m_a, UUID {raw});
raw = m_b;
raw = m_b.ToBytes();
EXPECT_EQ(m_b, UUID {raw});
raw = m_d;
raw = m_d.ToBytes();
EXPECT_EQ(m_d, UUID {raw});
}
@@ -57,21 +57,21 @@ TEST_F(UUIDFixture, DumpingRawAndConstructAnUUIDWithItShouldGiveTheSameUUID)
TEST_F(UUIDFixture, ValidIDFromStringShouldBeEqualToString)
{
EXPECT_EQ(static_cast<std::string>(m_b), "47183823-2574-4bfd-b411-99ed177d3e43");
EXPECT_EQ(m_b.ToString(), "47183823-2574-4bfd-b411-99ed177d3e43");
}
/****************************************************************************************/
TEST_F(UUIDFixture, InvalidIDFromStringShouldNotBeEqualToString)
{
EXPECT_NE(static_cast<std::string>(m_c), "4bfd-b411-99ed177d3e43");
EXPECT_NE(m_c.ToString(), "4bfd-b411-99ed177d3e43");
}
/****************************************************************************************/
TEST_F(UUIDFixture, NullIDStringShouldBeEqualToNullIDString)
{
EXPECT_EQ(static_cast<std::string>(UUID::NULL_UUID), "00000000-0000-0000-0000-000000000000");
EXPECT_EQ(UUID::NULL_UUID.ToString(), "00000000-0000-0000-0000-000000000000");
}
/****************************************************************************************/
@@ -168,9 +168,9 @@ TEST_F(UUIDFixture, GeneratingFiveMillionUniqueID)
/****************************************************************************************/
TEST_F(UUIDFixture, Raw_ShouldGiveBackTheRawDataOfTheID)
TEST_F(UUIDFixture, ToBytes_ShouldGiveBackTheRawDataOfTheID)
{
std::span<const std::byte, UUID::UUID_BYTE_SIZE> d = m_d;
std::span<const std::byte, UUID::UUID_BYTE_SIZE> d = m_d.ToBytes();
std::span<const std::byte, UUID::UUID_BYTE_SIZE> raw = m_raw;
for (std::uint32_t i = 0; i < UUID::UUID_BYTE_SIZE; ++i)

View File

@@ -60,8 +60,8 @@ TYPED_TEST(SlotKeyFixture, DefaultSlotKeyIsInvalid)
constexpr typename TestFixture::SlotKey slotKey {};
EXPECT_FALSE(slotKey.Valid());
EXPECT_EQ(slotKey.Version(), version);
EXPECT_EQ(slotKey.Index(), index);
EXPECT_EQ(slotKey.GetVersion(), version);
EXPECT_EQ(slotKey.GetIndex(), index);
}
/****************************************************************************************/
@@ -88,24 +88,24 @@ TYPED_TEST(SlotKeyFixture, Valid_ShouldReturnFalseIfTheSlotKeyIsValid)
/****************************************************************************************/
TYPED_TEST(SlotKeyFixture, Version_ShouldReturnTheVersion)
TYPED_TEST(SlotKeyFixture, GetVersion_ShouldReturnTheVersion)
{
constexpr typename TestFixture::SlotMapIndex index = 0;
constexpr typename TestFixture::SlotMapVersion version = 42;
constexpr typename TestFixture::SlotKey slotKey {version, index};
EXPECT_EQ(slotKey.Version(), version);
EXPECT_EQ(slotKey.GetVersion(), version);
}
/****************************************************************************************/
TYPED_TEST(SlotKeyFixture, Index_ShouldReturnTheIndex)
TYPED_TEST(SlotKeyFixture, GetIndex_ShouldReturnTheIndex)
{
constexpr typename TestFixture::SlotMapIndex index = 42;
constexpr typename TestFixture::SlotMapVersion version = 0;
constexpr typename TestFixture::SlotKey slotKey {version, index};
EXPECT_EQ(slotKey.Index(), index);
EXPECT_EQ(slotKey.GetIndex(), index);
}
/****************************************************************************************/
@@ -140,8 +140,8 @@ TYPED_TEST(SlotMapFixture, Insert_ShouldRecycleASlotKeyAfterARemove)
this->m_slotMap.Remove(slotKey);
const auto secondSlotKey = this->m_slotMap.Insert(69);
EXPECT_NE(secondSlotKey.Version(), slotKey.Version());
EXPECT_EQ(secondSlotKey.Index(), slotKey.Index());
EXPECT_NE(secondSlotKey.GetVersion(), slotKey.GetVersion());
EXPECT_EQ(secondSlotKey.GetIndex(), slotKey.GetIndex());
}
/****************************************************************************************/
@@ -190,19 +190,19 @@ TYPED_TEST(SlotMapFixture, Remove_ShouldNotRecycleASlotWhenVersionWasExhausted)
{
this->m_slotMap.Remove(key);
const auto newKey = this->m_slotMap.Insert(1);
EXPECT_EQ(newKey.Index(), key.Index());
EXPECT_EQ(newKey.GetIndex(), key.GetIndex());
key = newKey;
}
// Slot is at MAX_VERSION — one more remove should overflow and permanently deactivate it
EXPECT_EQ(key.Version(), std::numeric_limits<typename TestFixture::SlotMapVersion>::max());
EXPECT_EQ(key.GetVersion(), std::numeric_limits<typename TestFixture::SlotMapVersion>::max());
this->m_slotMap.Remove(key);
EXPECT_FALSE(this->m_slotMap.Has(key));
// Dead slot must not be recycled; a new insert must allocate a fresh slot index
const auto newKey = this->m_slotMap.Insert(2);
EXPECT_NE(newKey.Index(), key.Index());
EXPECT_NE(newKey.GetIndex(), key.GetIndex());
// Ensure an invalid key does not return an exhausted slot
EXPECT_EQ(this->m_slotMap.Get(typename TestFixture::SlotKey {}), nullptr);
@@ -313,35 +313,35 @@ TYPED_TEST(SlotMapFixture, Clear_ResetsTheSlotMapAndButGuaranteesNotCollisionWit
/****************************************************************************************/
TYPED_TEST(SlotMapFixture, Size_ReturnTheSizeOfTheSlotMap)
TYPED_TEST(SlotMapFixture, GetSize_ReturnTheSizeOfTheSlotMap)
{
EXPECT_EQ(this->m_slotMap.Size(), 0);
EXPECT_EQ(this->m_slotMap.GetSize(), 0);
std::ignore = this->m_slotMap.Insert(42);
const auto slotKey2 = this->m_slotMap.Insert(69);
std::ignore = this->m_slotMap.Insert(28);
std::ignore = this->m_slotMap.Insert(0);
EXPECT_EQ(this->m_slotMap.Size(), 4);
EXPECT_EQ(this->m_slotMap.GetSize(), 4);
this->m_slotMap.Remove(slotKey2);
EXPECT_EQ(this->m_slotMap.Size(), 3);
EXPECT_EQ(this->m_slotMap.GetSize(), 3);
this->m_slotMap.Clear();
EXPECT_EQ(this->m_slotMap.Size(), 0);
EXPECT_EQ(this->m_slotMap.GetSize(), 0);
std::ignore = this->m_slotMap.Insert(42);
std::ignore = this->m_slotMap.Insert(69);
std::ignore = this->m_slotMap.Insert(28);
std::ignore = this->m_slotMap.Insert(0);
EXPECT_EQ(this->m_slotMap.Size(), 4);
EXPECT_EQ(this->m_slotMap.GetSize(), 4);
this->m_slotMap.Reset();
EXPECT_EQ(this->m_slotMap.Size(), 0);
EXPECT_EQ(this->m_slotMap.GetSize(), 0);
}
/****************************************************************************************/

View File

@@ -6,7 +6,7 @@
*********************************************************************/
#ifndef BIGFOOT_UTILSTESTSLOGGER_GENERATED_HPP
#define BIGFOOT_UTILSTESTSLOGGER_GENERATED_HPP
#include <Utils/Log/Log.hpp>
#include <Utils/Log/LogMacros.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED

View File

@@ -19,11 +19,6 @@ namespace Bigfoot
class LogFixture: public ::testing::Test
{
protected:
void SetUp() override
{
UTILSTESTS_LOGGER = {"UTILSTESTS_LOGGER", Flat::LogLevel::Trace};
}
static constexpr Flat::LogLevel QuillLogLevelToLogLevel(const quill::LogLevel p_level)
{
switch (p_level)
@@ -46,93 +41,57 @@ class LogFixture: public ::testing::Test
return Flat::LogLevel::Trace;
}
Log m_log;
};
/****************************************************************************************/
TEST_F(LogFixture, RegisterLogger_ShouldRegisterTheLogger)
{
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
EXPECT_TRUE(logger);
EXPECT_EQ(logger, m_log.GetLogger(UTILSTESTS_LOGGER));
EXPECT_EQ(logger, Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER));
EXPECT_EQ(logger->get_logger_name(), UTILSTESTS_LOGGER.m_name);
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), UTILSTESTS_LOGGER.m_level);
}
/****************************************************************************************/
TEST_F(LogFixture, GetLogger_ShouldReturnNullptrIfTheLoggerDoesNotExist)
TEST_F(LogFixture, UnregisterLogger_ShouldUnregisterTheLogger)
{
EXPECT_FALSE(m_log.GetLogger(UTILSTESTS_LOGGER));
std::ignore = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
Singleton<Log>::GetInstance().UnregisterLogger(UTILSTESTS_LOGGER);
EXPECT_EQ(Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER), nullptr);
}
/****************************************************************************************/
TEST_F(LogFixture, GetLogger_ShouldReturnTheLoggerIfItExists)
TEST_F(LogFixture, GetLogger_ShouldReturnNullptrIfTheLoggerDoesNotExist)
{
EXPECT_FALSE(Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER));
}
/****************************************************************************************/
TEST_F(LogFixture, GetLoger_ShouldReturnTheLoggerIfItExists)
{
[[maybe_unused]]
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
EXPECT_TRUE(m_log.GetLogger(UTILSTESTS_LOGGER));
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
EXPECT_TRUE(Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER));
}
/****************************************************************************************/
TEST_F(LogFixture, ChangeLoggerLogLevel_ShouldChangeTheLoggerLogLevel)
{
const quill::Logger* logger = m_log.RegisterLogger(UTILSTESTS_LOGGER);
const Flat::LogLevel previous = UTILSTESTS_LOGGER.m_level;
m_log.ChangeLoggerLogLevel(UTILSTESTS_LOGGER, Flat::LogLevel::Critical);
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
Singleton<Log>::GetInstance().ChangeLoggerLogLevel(UTILSTESTS_LOGGER, Flat::LogLevel::Critical);
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), Flat::LogLevel::Critical);
}
/****************************************************************************************/
TEST_F(LogFixture, LogDebug)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_DEBUG(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogTrace)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_TRACE(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogInfo)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogWarn)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_WARN(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogError)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_ERROR(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogFixture, LogFatal)
{
Singleton<Log>::Lifetime singletonLifetime;
BIGFOOT_LOG_FATAL(UTILSTESTS_LOGGER, "Hello");
Singleton<Log>::GetInstance().ChangeLoggerLogLevel(UTILSTESTS_LOGGER, previous);
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), previous);
}
} // namespace Bigfoot
#endif

View File

@@ -0,0 +1,64 @@
/*********************************************************************
* \file LogMacros.cpp
*
* \author Romain BOULLARD
* \date May 2026
*********************************************************************/
#include <Utils/Log/LogMacros.hpp>
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <gtest/gtest.h>
namespace Bigfoot
{
class LogMacrosFixture: public ::testing::Test
{
protected:
};
/****************************************************************************************/
TEST_F(LogMacrosFixture, LogDebug)
{
BIGFOOT_LOG_DEBUG(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogMacrosFixture, LogTrace)
{
BIGFOOT_LOG_TRACE(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogMacrosFixture, LogInfo)
{
BIGFOOT_LOG_INFO(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogMacrosFixture, LogWarn)
{
BIGFOOT_LOG_WARN(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogMacrosFixture, LogError)
{
BIGFOOT_LOG_ERROR(UTILSTESTS_LOGGER, "Hello");
}
/****************************************************************************************/
TEST_F(LogMacrosFixture, LogFatal)
{
BIGFOOT_LOG_FATAL(UTILSTESTS_LOGGER, "Hello");
}
} // namespace Bigfoot
#endif

View File

@@ -42,7 +42,7 @@ class SingletonTest
}
[[nodiscard]]
std::uint32_t Data() const
std::uint32_t GetData() const
{
return m_data;
}
@@ -84,19 +84,19 @@ TEST_F(SingletonFixture, ConstructorAndDestructorShouldBeCalled)
{
::testing::InSequence seq;
EXPECT_CALL(*m_mock, Construct());
EXPECT_CALL(*m_mock, Destruct());
EXPECT_CALL(*m_mock, Construct()).Times(1);
EXPECT_CALL(*m_mock, Destruct()).Times(1);
Singleton<SingletonTest>::Lifetime singleton {42};
}
/****************************************************************************************/
TEST_F(SingletonFixture, Instance_ShouldReturnTheInstance)
TEST_F(SingletonFixture, GetInstance_ShouldReturnTheInstance)
{
Singleton<SingletonTest>::Lifetime singleton {42};
EXPECT_EQ(Singleton<SingletonTest>::Instance().Data(), 42);
EXPECT_EQ(Singleton<SingletonTest>::GetInstance().GetData(), 42);
}
} // namespace Bigfoot

View File

@@ -0,0 +1,19 @@
/*********************************************************************
* \file main.cpp
*
* \author Romain BOULLARD
* \date May 2026
*********************************************************************/
#include <Utils/Log/LogMacros.hpp>
#include <Utils/TargetMacros.h>
#include <gtest/gtest.h>
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
BIGFOOT_NOT_OPTIMIZED_ONLY(::Bigfoot::Singleton<::Bigfoot::Log>::Lifetime m_lifetime);
return RUN_ALL_TESTS();
}

View File

@@ -19,42 +19,42 @@ class VersionFixture: public ::testing::Test
/****************************************************************************************/
TEST_F(VersionFixture, string)
TEST_F(VersionFixture, ToString)
{
EXPECT_STREQ(static_cast<std::string>(m_detailed).data(), "1.2.3");
EXPECT_STREQ(static_cast<std::string>(m_combined).data(), "1.2.3");
EXPECT_STREQ(m_detailed.ToString().data(), "1.2.3");
EXPECT_STREQ(m_combined.ToString().data(), "1.2.3");
}
/****************************************************************************************/
TEST_F(VersionFixture, uint32_t)
TEST_F(VersionFixture, Raw)
{
EXPECT_EQ(static_cast<std::uint32_t>(m_detailed), (1 << 16) | (2 << 8) | 3);
EXPECT_EQ(static_cast<std::uint32_t>(m_combined), (1 << 16) | (2 << 8) | 3);
EXPECT_EQ(m_detailed.Raw(), (1 << 16) | (2 << 8) | 3);
EXPECT_EQ(m_combined.Raw(), (1 << 16) | (2 << 8) | 3);
}
/****************************************************************************************/
TEST_F(VersionFixture, Major_ShouldBeEqualToTheMajorPartOfTheVersion)
TEST_F(VersionFixture, GetMajor_ShouldBeEqualToTheMajorPartOfTheVersion)
{
EXPECT_EQ(m_detailed.Major(), 1);
EXPECT_EQ(m_combined.Major(), 1);
EXPECT_EQ(m_detailed.GetMajor(), 1);
EXPECT_EQ(m_combined.GetMajor(), 1);
}
/****************************************************************************************/
TEST_F(VersionFixture, Minor_ShouldBeEqualToTheMinorPartOfTheVersion)
TEST_F(VersionFixture, GetMinor_ShouldBeEqualToTheMinorPartOfTheVersion)
{
EXPECT_EQ(m_detailed.Minor(), 2);
EXPECT_EQ(m_combined.Minor(), 2);
EXPECT_EQ(m_detailed.GetMinor(), 2);
EXPECT_EQ(m_combined.GetMinor(), 2);
}
/****************************************************************************************/
TEST_F(VersionFixture, Patch_ShouldBeEqualToThePatchPartOfTheVersion)
TEST_F(VersionFixture, GetPatch_ShouldBeEqualToThePatchPartOfTheVersion)
{
EXPECT_EQ(m_detailed.Patch(), 3);
EXPECT_EQ(m_combined.Patch(), 3);
EXPECT_EQ(m_detailed.GetPatch(), 3);
EXPECT_EQ(m_combined.GetPatch(), 3);
}
/****************************************************************************************/