Compare commits
26
Commits
main
...
1c2f9344b0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c2f9344b0 | ||
|
|
09014277a1 | ||
|
|
8e28f50e1d | ||
|
|
407401bea2 | ||
|
|
cbf4de6003 | ||
|
|
0ba9e062d4 | ||
|
|
33331ea529 | ||
|
|
8a36af6bcb | ||
|
|
c6ccdf8214 | ||
|
|
d9f4a0e896 | ||
|
|
1d572b9d09 | ||
|
|
870bfe57e6 | ||
|
|
9978ff358b | ||
|
|
8be97bacb5 | ||
|
|
cea3b8a904 | ||
|
|
1d2dafff48 | ||
|
|
17ab916b11 | ||
|
|
3c306dd2c7 | ||
|
|
a1e4119311 | ||
|
|
1bae20b79c | ||
|
|
39d2ddbe49 | ||
|
|
6bc25a776e | ||
|
|
96c4353a8a | ||
|
|
9733860ecd | ||
|
|
2062b8169f | ||
|
|
e825728867 |
+22
-2
@@ -51,7 +51,7 @@ CompactNamespaces: false
|
|||||||
Cpp11BracedListStyle: true
|
Cpp11BracedListStyle: true
|
||||||
EmptyLineBeforeAccessModifier: Always
|
EmptyLineBeforeAccessModifier: Always
|
||||||
FixNamespaceComments: true
|
FixNamespaceComments: true
|
||||||
IncludeBlocks: Preserve
|
IncludeBlocks: Regroup
|
||||||
IndentCaseBlocks: true
|
IndentCaseBlocks: true
|
||||||
IndentCaseLabels: false
|
IndentCaseLabels: false
|
||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
@@ -119,4 +119,24 @@ SpaceAroundPointerQualifiers: Default
|
|||||||
SpaceBeforeCpp11BracedList: true
|
SpaceBeforeCpp11BracedList: true
|
||||||
SpaceInEmptyBlock: true
|
SpaceInEmptyBlock: true
|
||||||
PenaltyBreakAssignment: 200
|
PenaltyBreakAssignment: 200
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<Engine/'
|
||||||
|
Priority: 1
|
||||||
|
- Regex: '^<System/'
|
||||||
|
Priority: 2
|
||||||
|
- Regex: '^<Utils/'
|
||||||
|
Priority: 3
|
||||||
|
- Regex: '^<EngineTests/'
|
||||||
|
Priority: 4
|
||||||
|
- Regex: '^<SystemTests/'
|
||||||
|
Priority: 5
|
||||||
|
- Regex: '^<UtilsTests/'
|
||||||
|
Priority: 6
|
||||||
|
- Regex: '^<[a-zA-Z0-9_/]+\.h>'
|
||||||
|
Priority: 7
|
||||||
|
- Regex: '^<[a-zA-Z0-9_/]+\.hpp>'
|
||||||
|
Priority: 7
|
||||||
|
- Regex: '^<[a-zA-Z0-9_/]+>'
|
||||||
|
Priority: 8
|
||||||
|
MainIncludeChar: AngleBracket
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(./EngineTests.exe)",
|
||||||
|
"Bash(echo \"EXIT: $?\")",
|
||||||
|
"Bash(cmake --build build-windows --target EngineTests --config Debug -- -m)",
|
||||||
|
"Bash(cmake --build build-windows --config Debug -- -m)",
|
||||||
|
"Bash(./SystemTests.exe)",
|
||||||
|
"Bash(./UtilsTests.exe)",
|
||||||
|
"Bash(cmake --build build-windows --target EngineBenchmarks --config RelWithDebInfo -- -m)",
|
||||||
|
"Bash(./EngineBenchmarks.exe --benchmark_counters_tabular=true)",
|
||||||
|
"Bash(cmake --build build-windows --target EngineBenchmarks --config Release -- -m)",
|
||||||
|
"Bash(./EngineBenchmarks.exe --benchmark_repetitions=10 --benchmark_report_aggregates_only=true)",
|
||||||
|
"Bash(cmake . -G \"Visual Studio 17 2022\")"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"name": "Bigfoot",
|
"name": "Bigfoot",
|
||||||
"image": "git.romainboullard.com/bigfootdev/linuxbigfootbuilder:main"
|
"image": "git.romainboullard.com/bigfootdev/linuxcppbuilder:development"
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-16
@@ -6,20 +6,22 @@ on:
|
|||||||
- '**'
|
- '**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
|
||||||
CCACHE_BASEDIR: ${{ github.workspace }}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 120
|
timeout-minutes: 120
|
||||||
container:
|
container:
|
||||||
image: git.romainboullard.com/bigfootdev/linuxbigfootbuilder:main
|
image: git.romainboullard.com/bigfootdev/linuxcppbuilder:development
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
build_type: ["Debug", "RelWithDebInfo", "Release"]
|
build_type: ["Debug", "RelWithDebInfo", "Release"]
|
||||||
unity_build: ["ON", "OFF"]
|
unity_build: ["ON", "OFF"]
|
||||||
name: "Build & Test ${{ matrix.build_type }} (Unity Build: ${{ matrix.unity_build }})"
|
conan_profile: ["./ConanProfiles/host/clang", "./ConanProfiles/host/clang_asan"]
|
||||||
|
toolmode:
|
||||||
|
- { value: "True", name: "toolmode" }
|
||||||
|
- { value: "False", name: "game" }
|
||||||
|
name: "Build & Test ${{ matrix.build_type }} with ${{ matrix.conan_profile }} (Unity Build: ${{ matrix.unity_build }}, Variant: ${{ matrix.toolmode.name }})"
|
||||||
steps:
|
steps:
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
run: apt-get update && apt-get install -y nodejs
|
run: apt-get update && apt-get install -y nodejs
|
||||||
@@ -29,28 +31,26 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Show ccache stats before
|
|
||||||
run: ccache --zero-stats
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
conan install . --deployer=full_deploy --deployer-folder=build --remote=bigfootpackages -pr:h=clang -pr:b=clang --build=missing -s build_type=${{ matrix.build_type }} -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=False -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True
|
conan install . --remote=bigfootpackages -pr:h=${{ matrix.conan_profile }} -pr:b=./ConanProfiles/build/clang --build=* -s build_type=${{ matrix.build_type }} -o bigfoot/*:build_tests=True -o bigfoot/*:build_benchmarks=True -o bigfoot/*:tracy=False -o bigfoot/*:vulkan=True -o bigfoot/*:toolmode=${{ matrix.toolmode.value }} -of build-${{ matrix.toolmode.name }}
|
||||||
cmake -S . -B ./build/${{ matrix.build_type }} --toolchain ./build/${{ matrix.build_type }}/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -G "Ninja"
|
. ./build-${{ matrix.toolmode.name }}/build/${{ matrix.build_type }}/generators/conanbuild.sh
|
||||||
cmake --build build/${{ matrix.build_type }} --parallel $(nproc)
|
cmake -S . -B ./build-${{ matrix.toolmode.name }}/${{ matrix.build_type }} --toolchain ./build-${{ matrix.toolmode.name }}/build/${{ matrix.build_type }}/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_UNITY_BUILD=${{ matrix.unity_build }} -G "Ninja"
|
||||||
|
cmake --build build-${{ matrix.toolmode.name }}/${{ matrix.build_type }} --parallel $(nproc)
|
||||||
- name: Show ccache stats after
|
. ./build-${{ matrix.toolmode.name }}/build/${{ matrix.build_type }}/generators/deactivate_conanbuild.sh
|
||||||
run: ccache --show-stats
|
|
||||||
|
|
||||||
- name: Unit Tests
|
- name: Unit Tests
|
||||||
run: |
|
run: |
|
||||||
cd ./build/${{ matrix.build_type }}
|
cd ./build-${{ matrix.toolmode.name }}/${{ matrix.build_type }}
|
||||||
|
. ../../build-${{ matrix.toolmode.name }}/build/${{ matrix.build_type }}/generators/conanbuild.sh
|
||||||
xvfb-run ctest . --output-on-failure
|
xvfb-run ctest . --output-on-failure
|
||||||
|
. ../../build-${{ matrix.toolmode.name }}/build/${{ matrix.build_type }}/generators/deactivate_conanbuild.sh
|
||||||
|
|
||||||
clang-format:
|
clang-format:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 120
|
timeout-minutes: 120
|
||||||
container:
|
container:
|
||||||
image: git.romainboullard.com/bigfootdev/linuxbigfootbuilder:main
|
image: git.romainboullard.com/bigfootdev/linuxcppbuilder:main
|
||||||
name: "Clang Format Checks"
|
name: "Clang Format Checks"
|
||||||
steps:
|
steps:
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 120
|
timeout-minutes: 120
|
||||||
container:
|
container:
|
||||||
image: git.romainboullard.com/bigfootdev/linuxbigfootbuilder:main
|
image: git.romainboullard.com/bigfootdev/linuxcppbuilder:development
|
||||||
|
|
||||||
name: "Sonarqube"
|
name: "Sonarqube"
|
||||||
steps:
|
steps:
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
@@ -23,11 +24,13 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Generate
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
conan install . --deployer=full_deploy --deployer-folder=build --remote=bigfootpackages -pr:h=clang_coverage -pr:b=clang_coverage --build=missing -s build_type=Debug -o bigfoot/*:build_tests=True -o bigfoot/*:tracy=False -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True -o bigfoot/*:build_benchmarks=True
|
conan install . --remote=bigfootpackages -pr:h=./ConanProfiles/host/clang_coverage -pr:b=./ConanProfiles/build/clang --build=* -s build_type=Debug -o bigfoot/*:build_tests=True -o bigfoot/*:build_benchmarks=True -o bigfoot/*:tracy=False -o bigfoot/*:build_tools=True -o bigfoot/*:vulkan=True
|
||||||
|
. ./build/Debug/generators/conanbuild.sh
|
||||||
cmake -S . -B ./build/Debug --toolchain ./build/Debug/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -G "Ninja"
|
cmake -S . -B ./build/Debug --toolchain ./build/Debug/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -G "Ninja"
|
||||||
cmake --build build/Debug --parallel $(nproc)
|
cmake --build build/Debug --parallel $(nproc)
|
||||||
|
. ./build/Debug/generators/deactivate_conanbuild.sh
|
||||||
|
|
||||||
- name: Clang-Tidy
|
- name: Clang-Tidy
|
||||||
run: run-clang-tidy -p ./build/Debug/ >> tidy_result.txt
|
run: run-clang-tidy -p ./build/Debug/ >> tidy_result.txt
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
[Bb]uild*
|
[Bb]uild*
|
||||||
|
!ConanProfiles/build/
|
||||||
|
!ConanProfiles/build/**
|
||||||
Environment/output
|
Environment/output
|
||||||
*.generated.h
|
*.generated.h
|
||||||
|
|
||||||
@@ -18,4 +20,4 @@ graph_info.json
|
|||||||
|
|
||||||
test_package/Vendor
|
test_package/Vendor
|
||||||
|
|
||||||
graphviz
|
graphviz*
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Utils)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
|
project(${PackageName}Benchmarks)
|
||||||
|
|
||||||
|
bigfoot_create_package_benchmarks(
|
||||||
|
"")
|
||||||
@@ -0,0 +1,254 @@
|
|||||||
|
#include <Utils/Containers/SlotMap.hpp>
|
||||||
|
|
||||||
|
#include <ankerl/unordered_dense.h>
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <random>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
struct MyComplexStruct
|
||||||
|
{
|
||||||
|
std::uint32_t m_actualValueForBench = 0; // field summed by the Iterate benchmark
|
||||||
|
|
||||||
|
float m_position[3] = {0.0f, 0.0f, 0.0f};
|
||||||
|
float m_rotation[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
|
float m_scale[3] = {1.0f, 1.0f, 1.0f};
|
||||||
|
|
||||||
|
std::uint64_t m_entityId = 0;
|
||||||
|
std::uint32_t m_parentSlot = 0;
|
||||||
|
std::uint32_t m_flags = 0;
|
||||||
|
|
||||||
|
MyComplexStruct() = default;
|
||||||
|
|
||||||
|
explicit MyComplexStruct(const std::uint32_t p_value):
|
||||||
|
m_actualValueForBench(p_value),
|
||||||
|
m_entityId(p_value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(MyComplexStruct) == 64, "Payload should be exactly one cache line.");
|
||||||
|
static_assert(std::is_trivially_copyable_v<MyComplexStruct>,
|
||||||
|
"Container moves should be a plain memcpy, not a heap-touching move.");
|
||||||
|
|
||||||
|
template<class SLOTMAP>
|
||||||
|
class SlotMapAdaptor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Key = SLOTMAP::SlotMapKey;
|
||||||
|
|
||||||
|
Key Add(MyComplexStruct&& p_value)
|
||||||
|
{
|
||||||
|
return m_container.Insert(std::move(p_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
const MyComplexStruct* Find(const Key p_key) const
|
||||||
|
{
|
||||||
|
return m_container.Get(p_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Remove(const Key p_key)
|
||||||
|
{
|
||||||
|
m_container.Remove(p_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
m_container.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class FUNC>
|
||||||
|
void ForEachValue(FUNC&& p_func) const
|
||||||
|
{
|
||||||
|
for (const MyComplexStruct& value: m_container)
|
||||||
|
{
|
||||||
|
p_func(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
SLOTMAP m_container;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class MAP>
|
||||||
|
class HashMapHarnessAdaptor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Key = typename MAP::key_type;
|
||||||
|
|
||||||
|
Key Add(MyComplexStruct&& p_value)
|
||||||
|
{
|
||||||
|
const Key key = m_nextKey++;
|
||||||
|
m_container.emplace(key, std::move(p_value));
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MyComplexStruct* Find(const Key p_key) const
|
||||||
|
{
|
||||||
|
const auto it = m_container.find(p_key);
|
||||||
|
return it != m_container.end() ? &it->second : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Remove(const Key p_key)
|
||||||
|
{
|
||||||
|
m_container.erase(p_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
m_container.clear();
|
||||||
|
m_nextKey = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class FUNC>
|
||||||
|
void ForEachValue(FUNC&& p_func) const
|
||||||
|
{
|
||||||
|
for (const auto& keyValue: m_container)
|
||||||
|
{
|
||||||
|
p_func(keyValue.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MAP m_container;
|
||||||
|
Key m_nextKey = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class ADAPTOR>
|
||||||
|
void Insert(benchmark::State& state)
|
||||||
|
{
|
||||||
|
const auto count = static_cast<std::uint32_t>(state.range(0));
|
||||||
|
|
||||||
|
for (auto _: state)
|
||||||
|
{
|
||||||
|
ADAPTOR adaptor;
|
||||||
|
for (std::uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
benchmark::DoNotOptimize(adaptor.Add(MyComplexStruct {i}));
|
||||||
|
}
|
||||||
|
benchmark::DoNotOptimize(adaptor);
|
||||||
|
benchmark::ClobberMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
state.SetItemsProcessed(state.iterations() * count);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ADAPTOR>
|
||||||
|
void Remove(benchmark::State& state)
|
||||||
|
{
|
||||||
|
const auto count = static_cast<std::uint32_t>(state.range(0));
|
||||||
|
|
||||||
|
ADAPTOR adaptor;
|
||||||
|
std::vector<typename ADAPTOR::Key> keys;
|
||||||
|
keys.reserve(count);
|
||||||
|
std::mt19937 rng(0x5EEDU);
|
||||||
|
|
||||||
|
for (auto _: state)
|
||||||
|
{
|
||||||
|
state.PauseTiming();
|
||||||
|
adaptor.Clear();
|
||||||
|
keys.clear();
|
||||||
|
for (std::uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
keys.push_back(adaptor.Add(MyComplexStruct {i}));
|
||||||
|
}
|
||||||
|
std::shuffle(keys.begin(), keys.end(), rng);
|
||||||
|
state.ResumeTiming();
|
||||||
|
|
||||||
|
for (const typename ADAPTOR::Key key: keys)
|
||||||
|
{
|
||||||
|
adaptor.Remove(key);
|
||||||
|
}
|
||||||
|
benchmark::DoNotOptimize(adaptor);
|
||||||
|
benchmark::ClobberMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
state.SetItemsProcessed(state.iterations() * count);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ADAPTOR>
|
||||||
|
void Get(benchmark::State& state)
|
||||||
|
{
|
||||||
|
const auto count = static_cast<std::uint32_t>(state.range(0));
|
||||||
|
|
||||||
|
ADAPTOR adaptor;
|
||||||
|
std::vector<typename ADAPTOR::Key> keys;
|
||||||
|
keys.reserve(count);
|
||||||
|
for (std::uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
keys.push_back(adaptor.Add(MyComplexStruct {i}));
|
||||||
|
}
|
||||||
|
std::mt19937 rng(0x5EEDU);
|
||||||
|
std::shuffle(keys.begin(), keys.end(), rng);
|
||||||
|
|
||||||
|
for (auto _: state)
|
||||||
|
{
|
||||||
|
std::uint64_t sum = 0;
|
||||||
|
for (const typename ADAPTOR::Key key: keys)
|
||||||
|
{
|
||||||
|
if (const MyComplexStruct* const value = adaptor.Find(key))
|
||||||
|
{
|
||||||
|
sum += value->m_actualValueForBench;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
benchmark::DoNotOptimize(sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.SetItemsProcessed(state.iterations() * count);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ADAPTOR>
|
||||||
|
void Iterate(benchmark::State& state)
|
||||||
|
{
|
||||||
|
const auto count = static_cast<std::uint32_t>(state.range(0));
|
||||||
|
|
||||||
|
ADAPTOR adaptor;
|
||||||
|
for (std::uint32_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
adaptor.Add(MyComplexStruct {i});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto _: state)
|
||||||
|
{
|
||||||
|
std::uint64_t sum = 0;
|
||||||
|
adaptor.ForEachValue(
|
||||||
|
[&sum](const MyComplexStruct& value)
|
||||||
|
{
|
||||||
|
sum += value.m_actualValueForBench;
|
||||||
|
});
|
||||||
|
benchmark::DoNotOptimize(sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.SetItemsProcessed(state.iterations() * count);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BIGFOOT_REGISTER_BENCHMARKS(ADAPTOR, NAME) \
|
||||||
|
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 DenseSlotMapHarness = SlotMapAdaptor<DenseSlotMap<MyComplexStruct>>;
|
||||||
|
using StableSlotMapHarness = SlotMapAdaptor<StableSlotMap<MyComplexStruct>>;
|
||||||
|
using UnorderedDenseMapHarness = HashMapHarnessAdaptor<ankerl::unordered_dense::map<std::uint64_t, MyComplexStruct>>;
|
||||||
|
using UnorderedDenseSegementedMapHarness =
|
||||||
|
HashMapHarnessAdaptor<ankerl::unordered_dense::segmented_map<std::uint64_t, MyComplexStruct>>;
|
||||||
|
using UnorderedMapHarness = HashMapHarnessAdaptor<std::unordered_map<std::uint64_t, MyComplexStruct>>;
|
||||||
|
using MapHarness = HashMapHarnessAdaptor<std::map<std::uint64_t, MyComplexStruct>>;
|
||||||
|
|
||||||
|
BIGFOOT_REGISTER_BENCHMARKS(DenseSlotMapHarness, "Bigfoot::DenseSlotMap");
|
||||||
|
BIGFOOT_REGISTER_BENCHMARKS(StableSlotMapHarness, "Bigfoot::StableSlotMap");
|
||||||
|
BIGFOOT_REGISTER_BENCHMARKS(UnorderedDenseMapHarness, "ankerl::unordered_dense::map");
|
||||||
|
BIGFOOT_REGISTER_BENCHMARKS(UnorderedDenseSegementedMapHarness, "ankerl::unordered_dense::segmented_map");
|
||||||
|
BIGFOOT_REGISTER_BENCHMARKS(UnorderedMapHarness, "std::unordered_map");
|
||||||
|
BIGFOOT_REGISTER_BENCHMARKS(MapHarness, "std::map");
|
||||||
|
|
||||||
|
#undef BIGFOOT_REGISTER_BENCHMARKS
|
||||||
|
#undef BIGFOOT_CACHE_TIER_ARGS
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetLibrary.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date August 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/Asset/AssetLibrary.hpp>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
void SetActiveAssetLibrary(AssetLibrary* p_assetLibrary)
|
||||||
|
{
|
||||||
|
g_activeAssetLibrary = p_assetLibrary;
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetTypeID.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date May 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/Asset/AssetTypeID.hpp>
|
||||||
|
|
||||||
|
#include <Engine/Asset/AssetTypeID_generated.hpp>
|
||||||
|
|
||||||
|
namespace flatbuffers
|
||||||
|
{
|
||||||
|
Flat::Bigfoot::AssetTypeID Pack(const Bigfoot::AssetTypeID& p_assetTypeID)
|
||||||
|
{
|
||||||
|
return Flat::Bigfoot::AssetTypeID {p_assetTypeID};
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
Bigfoot::AssetTypeID UnPack(const Flat::Bigfoot::AssetTypeID& p_flatAssetTypeID)
|
||||||
|
{
|
||||||
|
return Bigfoot::AssetTypeID {p_flatAssetTypeID.value()};
|
||||||
|
}
|
||||||
|
} // namespace flatbuffers
|
||||||
@@ -0,0 +1,299 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file BigFile.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date October 2025
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/BigFile/BigFile.hpp>
|
||||||
|
|
||||||
|
#include <Engine/EngineAssertHandler.hpp>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
BigFile::BigFile(const File& p_file)
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
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.ToAbsolute().GetPath(),
|
||||||
|
sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::BeginTransaction()
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_exec(m_db, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to begin transaction: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::CommitTransaction()
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_exec(m_db, "COMMIT TRANSACTION;", nullptr, nullptr, nullptr);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to commit: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::RollbackTransaction()
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_exec(m_db, "ROLLBACK TRANSACTION;", nullptr, nullptr, nullptr);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to rollback: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::~BigFile()
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_close_v2(m_db);
|
||||||
|
CRITICAL_ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to close BigFile DB: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Request(const BigFile& p_bigFile, const eastl::string_view p_request):
|
||||||
|
m_db(p_bigFile.m_db)
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_prepare_v2(m_db,
|
||||||
|
p_request.data(),
|
||||||
|
static_cast<std::uint32_t>(p_request.size()),
|
||||||
|
&m_statement,
|
||||||
|
nullptr);
|
||||||
|
CRITICAL_ASSERT(EngineAssertHandler,
|
||||||
|
result == SQLITE_OK,
|
||||||
|
"Failed to create statement from BigFile DB: {}",
|
||||||
|
sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::Request::Bind(const std::uint32_t p_index, const std::int32_t p_value)
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(p_index >= 1) && (p_index <= static_cast<std::uint32_t>(sqlite3_bind_parameter_count(m_statement))),
|
||||||
|
"Invalid index for statement");
|
||||||
|
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_bind_int(m_statement, p_index, p_value);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to bind value for statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::Request::Bind(const std::uint32_t p_index, const std::uint32_t p_value)
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(p_index >= 1) && (p_index <= static_cast<std::uint32_t>(sqlite3_bind_parameter_count(m_statement))),
|
||||||
|
"Invalid index for statement");
|
||||||
|
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_bind_int(m_statement, p_index, p_value);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to bind value for statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::Request::Bind(const std::uint32_t p_index, const std::int64_t p_value)
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(p_index >= 1) && (p_index <= static_cast<std::uint32_t>(sqlite3_bind_parameter_count(m_statement))),
|
||||||
|
"Invalid index for statement");
|
||||||
|
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_bind_int64(m_statement, p_index, p_value);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to bind value for statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::Request::Bind(const std::uint32_t p_index, const std::uint64_t p_value)
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(p_index >= 1) && (p_index <= static_cast<std::uint32_t>(sqlite3_bind_parameter_count(m_statement))),
|
||||||
|
"Invalid index for statement");
|
||||||
|
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_bind_int64(m_statement, p_index, std::bit_cast<std::int64_t>(p_value));
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to bind value for statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::Request::Bind(const std::uint32_t p_index, const float p_value)
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(p_index >= 1) && (p_index <= static_cast<std::uint32_t>(sqlite3_bind_parameter_count(m_statement))),
|
||||||
|
"Invalid index for statement");
|
||||||
|
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_bind_double(m_statement, p_index, p_value);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to bind value for statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::Request::Bind(const std::uint32_t p_index, const double p_value)
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(p_index >= 1) && (p_index <= static_cast<std::uint32_t>(sqlite3_bind_parameter_count(m_statement))),
|
||||||
|
"Invalid index for statement");
|
||||||
|
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_bind_double(m_statement, p_index, p_value);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to bind value for statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::Request::Bind(const std::uint32_t p_index, const eastl::string_view p_value, const CopyValue p_copy)
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(p_index >= 1) && (p_index <= static_cast<std::uint32_t>(sqlite3_bind_parameter_count(m_statement))),
|
||||||
|
"Invalid index for statement");
|
||||||
|
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_bind_text(m_statement,
|
||||||
|
p_index,
|
||||||
|
p_value.data(),
|
||||||
|
static_cast<std::uint32_t>(p_value.size()),
|
||||||
|
p_copy ? SQLITE_TRANSIENT : SQLITE_STATIC);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to bind value for statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
void BigFile::Request::Bind(const std::uint32_t p_index,
|
||||||
|
const eastl::span<const std::byte> p_value,
|
||||||
|
const CopyValue p_copy)
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(p_index >= 1) && (p_index <= static_cast<std::uint32_t>(sqlite3_bind_parameter_count(m_statement))),
|
||||||
|
"Invalid index for statement");
|
||||||
|
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_bind_blob(m_statement,
|
||||||
|
p_index,
|
||||||
|
p_value.data(),
|
||||||
|
static_cast<std::uint32_t>(p_value.size()),
|
||||||
|
p_copy ? SQLITE_TRANSIENT : SQLITE_STATIC);
|
||||||
|
ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to bind value for statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
bool BigFile::Request::Step()
|
||||||
|
{
|
||||||
|
const int result = sqlite3_step(m_statement);
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
(result == SQLITE_DONE) || (result == SQLITE_ROW),
|
||||||
|
"Failed to step through the statement: {}",
|
||||||
|
sqlite3_errmsg(m_db));
|
||||||
|
|
||||||
|
return result == SQLITE_ROW;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
std::uint32_t BigFile::Request::Execute()
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_step(m_statement);
|
||||||
|
ASSERT(EngineAssertHandler, (result == SQLITE_DONE), "Failed to execute the statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
|
||||||
|
return sqlite3_changes(m_db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::Column(const Request& p_request, const std::uint32_t p_index):
|
||||||
|
m_statement(p_request.m_statement),
|
||||||
|
m_index(p_index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator std::int32_t() const
|
||||||
|
{
|
||||||
|
return sqlite3_column_int(m_statement, m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator std::uint32_t() const
|
||||||
|
{
|
||||||
|
return sqlite3_column_int(m_statement, m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator std::int64_t() const
|
||||||
|
{
|
||||||
|
return sqlite3_column_int64(m_statement, m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator std::uint64_t() const
|
||||||
|
{
|
||||||
|
return std::bit_cast<std::uint64_t>(sqlite3_column_int64(m_statement, m_index));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator float() const
|
||||||
|
{
|
||||||
|
return static_cast<float>(sqlite3_column_double(m_statement, m_index));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator double() const
|
||||||
|
{
|
||||||
|
return sqlite3_column_double(m_statement, m_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator eastl::string_view() const
|
||||||
|
{
|
||||||
|
return eastl::string_view {reinterpret_cast<const char*>(sqlite3_column_text(m_statement, m_index)),
|
||||||
|
static_cast<std::size_t>(sqlite3_column_bytes(m_statement, m_index))};
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column::operator eastl::span<const std::byte>() const
|
||||||
|
{
|
||||||
|
return eastl::span<const std::byte> {static_cast<const std::byte*>(sqlite3_column_blob(m_statement, m_index)),
|
||||||
|
static_cast<std::size_t>(sqlite3_column_bytes(m_statement, m_index))};
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::Column BigFile::Request::Get(const std::uint32_t p_index) const
|
||||||
|
{
|
||||||
|
ASSERT(EngineAssertHandler,
|
||||||
|
p_index < static_cast<std::uint32_t>(sqlite3_column_count(m_statement)),
|
||||||
|
"Invalid index for column!");
|
||||||
|
return {*this, p_index};
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
BigFile::Request::~Request()
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
const int result = sqlite3_finalize(m_statement);
|
||||||
|
CRITICAL_ASSERT(EngineAssertHandler, result == SQLITE_OK, "Failed to finalize statement: {}", sqlite3_errmsg(m_db));
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
PRAGMA journal_mode=WAL;
|
PRAGMA journal_mode=WAL;
|
||||||
PRAGMA foreign_keys = ON;
|
PRAGMA foreign_keys = ON;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS AssetHeader;
|
|
||||||
CREATE TABLE IF NOT EXISTS AssetHeader (
|
CREATE TABLE IF NOT EXISTS AssetHeader (
|
||||||
UUID BLOB NOT NULL UNIQUE,
|
UUID BLOB NOT NULL UNIQUE,
|
||||||
Name TEXT NOT NULL UNIQUE,
|
Name TEXT NOT NULL UNIQUE,
|
||||||
@@ -22,7 +21,6 @@ BEGIN
|
|||||||
WHERE UUID = NEW.UUID;
|
WHERE UUID = NEW.UUID;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS Asset;
|
|
||||||
CREATE TABLE IF NOT EXISTS Asset (
|
CREATE TABLE IF NOT EXISTS Asset (
|
||||||
UUID BLOB NOT NULL UNIQUE,
|
UUID BLOB NOT NULL UNIQUE,
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ set(PublicDependencies
|
|||||||
SQLite::SQLite3)
|
SQLite::SQLite3)
|
||||||
set(PrivateDependencies)
|
set(PrivateDependencies)
|
||||||
set(BigfootPublicDependencies
|
set(BigfootPublicDependencies
|
||||||
System
|
System)
|
||||||
Utils)
|
|
||||||
set(BigfootPrivateDependencies)
|
set(BigfootPrivateDependencies)
|
||||||
|
|
||||||
set(BIGFOOT_MAJOR 0)
|
set(BIGFOOT_MAJOR 0)
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
include "Engine/Asset/AssetTypeID.fbs";
|
||||||
|
|
||||||
|
include "System/UUID/UUID.fbs";
|
||||||
|
|
||||||
|
namespace Flat.Bigfoot;
|
||||||
|
|
||||||
|
table AssetHeader
|
||||||
|
{
|
||||||
|
uuid: UUID (required, native_inline, id: 0);
|
||||||
|
name: string (required, id: 1);
|
||||||
|
type_id: AssetTypeID (required, native_inline, id: 2);
|
||||||
|
type_name: string (required, id: 3);
|
||||||
|
version: uint = 0 (id: 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
table Asset
|
||||||
|
{
|
||||||
|
header: AssetHeader (required, id: 0);
|
||||||
|
inner_asset: [ubyte] (required, id: 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
root_type Asset;
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file Asset.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date April 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINE_ASSET_ASSET_HPP
|
||||||
|
#define BIGFOOT_ENGINE_ASSET_ASSET_HPP
|
||||||
|
#include <Engine/Asset/AssetConcepts.hpp>
|
||||||
|
#include <Engine/Asset/Asset_generated.hpp>
|
||||||
|
#include <Engine/EngineAssertHandler.hpp>
|
||||||
|
|
||||||
|
#include <EASTL/span.h>
|
||||||
|
#include <EASTL/vector.h>
|
||||||
|
#include <ankerl/unordered_dense.h>
|
||||||
|
#include <flatbuffers/reflection.h>
|
||||||
|
#include <rapidhash.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class AssetBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~AssetBase() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
AssetBase() = default;
|
||||||
|
|
||||||
|
AssetBase(const AssetBase& p_asset) = default;
|
||||||
|
AssetBase(AssetBase&& p_asset) = default;
|
||||||
|
|
||||||
|
AssetBase& operator=(const AssetBase& p_asset) = default;
|
||||||
|
AssetBase& operator=(AssetBase&& p_asset) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class ASSET>
|
||||||
|
requires AssetTraits<ASSET>
|
||||||
|
class Asset: public AssetBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using FLAT_ASSET = typename ASSET::FLAT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* Will default initialize header
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Asset()
|
||||||
|
{
|
||||||
|
m_header.type_id = GetTypeID();
|
||||||
|
m_header.type_name = eastl::string {GetTypeName()};
|
||||||
|
}
|
||||||
|
|
||||||
|
Asset(const Asset& p_asset) = default;
|
||||||
|
Asset(Asset&& p_asset) = default;
|
||||||
|
|
||||||
|
~Asset() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the header of the asset
|
||||||
|
*
|
||||||
|
* \return The header of the asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const ::Flat::Bigfoot::AssetHeaderT& GetHeader() const
|
||||||
|
{
|
||||||
|
return m_header;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name of the asset
|
||||||
|
*
|
||||||
|
* \param p_name The name of the asset
|
||||||
|
*/
|
||||||
|
void SetName(const eastl::string_view p_name)
|
||||||
|
{
|
||||||
|
m_header.name = p_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the version of the asset
|
||||||
|
*
|
||||||
|
* \param p_name The version of the asset
|
||||||
|
*/
|
||||||
|
void SetVersion(const std::uint32_t p_version)
|
||||||
|
{
|
||||||
|
m_header.version = p_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the asset
|
||||||
|
*
|
||||||
|
* \return The asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const typename FLAT_ASSET::NativeTableType& GetAsset() const
|
||||||
|
{
|
||||||
|
return m_asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the asset
|
||||||
|
*
|
||||||
|
* \return The asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
typename FLAT_ASSET::NativeTableType& GetAsset()
|
||||||
|
{
|
||||||
|
return m_asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpack a flatbuffer to the asset
|
||||||
|
*
|
||||||
|
* \param p_flatbuffer The flatbuffer to unpack
|
||||||
|
*/
|
||||||
|
void Unpack(const eastl::span<const std::byte> p_flatbuffer)
|
||||||
|
{
|
||||||
|
#ifdef BIGFOOT_NOT_OPTIMIZED
|
||||||
|
flatbuffers::Verifier verifier {std::bit_cast<std::uint8_t*>(p_flatbuffer.data()), p_flatbuffer.size()};
|
||||||
|
const bool assetVerified = ::Flat::Bigfoot::VerifyAssetBuffer(verifier);
|
||||||
|
CRITICAL_ASSERT(EngineAssertHandler, assetVerified, "Given asset could not be verified!");
|
||||||
|
|
||||||
|
const ::Flat::Bigfoot::Asset* asset = flatbuffers::GetRoot<::Flat::Bigfoot::Asset>(p_flatbuffer.data());
|
||||||
|
|
||||||
|
flatbuffers::Verifier innerAssetVerifier {asset->inner_asset()->data(), asset->inner_asset()->size()};
|
||||||
|
const bool innerAssetVerified = innerAssetVerifier.VerifyBuffer<FLAT_ASSET>();
|
||||||
|
CRITICAL_ASSERT(EngineAssertHandler, innerAssetVerified, "Given asset could not be verified!");
|
||||||
|
#else
|
||||||
|
const ::Flat::Bigfoot::Asset* asset = flatbuffers::GetRoot<::Flat::Bigfoot::Asset>(p_flatbuffer.data());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
asset->header()->UnPackTo(&m_header);
|
||||||
|
flatbuffers::GetRoot<FLAT_ASSET>(asset->inner_asset()->data())->UnPackTo(&m_asset, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef BIGFOOT_TOOLMODE
|
||||||
|
/**
|
||||||
|
* Pack the asset to a flatbuffer
|
||||||
|
*
|
||||||
|
* \return The packed asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
eastl::vector<std::byte> Pack() const
|
||||||
|
{
|
||||||
|
flatbuffers::FlatBufferBuilder innerAssetFbb;
|
||||||
|
innerAssetFbb.Finish(FLAT_ASSET::Pack(innerAssetFbb, &m_asset));
|
||||||
|
|
||||||
|
flatbuffers::FlatBufferBuilder assetFbb;
|
||||||
|
const auto header = ::Flat::Bigfoot::AssetHeader::Pack(assetFbb, &m_header);
|
||||||
|
const auto innerAsset = assetFbb.CreateVector(innerAssetFbb.GetBufferPointer(), innerAssetFbb.GetSize());
|
||||||
|
assetFbb.Finish(::Flat::Bigfoot::CreateAsset(assetFbb, header, innerAsset));
|
||||||
|
|
||||||
|
return eastl::vector<std::byte> {std::bit_cast<std::byte*>(assetFbb.GetBufferPointer()),
|
||||||
|
std::bit_cast<std::byte*>(assetFbb.GetBufferPointer() + assetFbb.GetSize())};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AssetTypeID
|
||||||
|
*
|
||||||
|
* \return The AssetTypeIPD
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
static AssetTypeID GetTypeID()
|
||||||
|
{
|
||||||
|
static const AssetTypeID typeID = rapidhash(FLAT_ASSET::GetFullyQualifiedName(),
|
||||||
|
std::strlen(FLAT_ASSET::GetFullyQualifiedName()));
|
||||||
|
return typeID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type name
|
||||||
|
*
|
||||||
|
* \return The type name
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
static eastl::string_view GetTypeName()
|
||||||
|
{
|
||||||
|
return FLAT_ASSET::GetFullyQualifiedName();
|
||||||
|
}
|
||||||
|
|
||||||
|
Asset& operator=(const Asset& p_asset) = default;
|
||||||
|
Asset& operator=(Asset&& p_asset) = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* The asset
|
||||||
|
*/
|
||||||
|
typename FLAT_ASSET::NativeTableType m_asset;
|
||||||
|
/**
|
||||||
|
* The asset header
|
||||||
|
*/
|
||||||
|
::Flat::Bigfoot::AssetHeaderT m_header;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetConcepts.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date August 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINE_ASSET_ASSETCONCEPTS_HPP
|
||||||
|
#define BIGFOOT_ENGINE_ASSET_ASSETCONCEPTS_HPP
|
||||||
|
#include <Engine/Asset/AssetTypeID.hpp>
|
||||||
|
|
||||||
|
#include <System/UUID/UUID.hpp>
|
||||||
|
|
||||||
|
#include <concepts>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class AssetBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The traits struct passed to Asset<TRAITS> (e.g. AssetATraits).
|
||||||
|
* Must name the generated flatbuffers table type for the asset.
|
||||||
|
*/
|
||||||
|
template<class TRAITS>
|
||||||
|
concept AssetTraits = requires {
|
||||||
|
typename TRAITS::FLAT;
|
||||||
|
typename TRAITS::FLAT::NativeTableType;
|
||||||
|
{ TRAITS::FLAT::GetFullyQualifiedName() } -> std::convertible_to<const char*>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A concrete Asset type (e.g. AssetA), usable with AssetContainer, AssetLibrary and References.
|
||||||
|
*/
|
||||||
|
template<class ASSET>
|
||||||
|
concept AssetType = std::derived_from<ASSET, AssetBase> && !std::same_as<ASSET, AssetBase> &&
|
||||||
|
requires(const ASSET& p_asset) {
|
||||||
|
{ ASSET::GetTypeID() } -> std::convertible_to<AssetTypeID>;
|
||||||
|
{ p_asset.GetHeader().uuid } -> std::convertible_to<UUID>;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,383 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetContainer.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date May 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINE_ASSET_ASSETCONTAINER_HPP
|
||||||
|
#define BIGFOOT_ENGINE_ASSET_ASSETCONTAINER_HPP
|
||||||
|
#include <Engine/Asset/Asset.hpp>
|
||||||
|
#include <Engine/Asset/AssetConcepts.hpp>
|
||||||
|
#include <Engine/EngineAssertHandler.hpp>
|
||||||
|
|
||||||
|
#include <Utils/Containers/SlotMap.hpp>
|
||||||
|
|
||||||
|
#include <ankerl/unordered_dense.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* An indirection that allows References to immediately get the asset, without fetching the actual container
|
||||||
|
*/
|
||||||
|
class ContainerHandle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ContainerHandle() = default;
|
||||||
|
|
||||||
|
ContainerHandle(const ContainerHandle& p_handle) = default;
|
||||||
|
ContainerHandle(ContainerHandle&& p_handle) = default;
|
||||||
|
|
||||||
|
~ContainerHandle() = default;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the HardRef count
|
||||||
|
*
|
||||||
|
* \return The HardRef count.
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetHardRefCount() const
|
||||||
|
{
|
||||||
|
return m_hardRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increment the HardRef count
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void IncrementHardRefCount()
|
||||||
|
{
|
||||||
|
++m_hardRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Decrement the HardRef count
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void DecrementHardRefCount()
|
||||||
|
{
|
||||||
|
--m_hardRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the SoftRef count
|
||||||
|
*
|
||||||
|
* \return The SoftRef count.
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetSoftRefCount() const
|
||||||
|
{
|
||||||
|
return m_softRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Increment the SoftRef count
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void IncrementSoftRefCount()
|
||||||
|
{
|
||||||
|
++m_softRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Decrement the SoftRef count
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void DecrementSoftRefCount()
|
||||||
|
{
|
||||||
|
--m_softRefCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Asset
|
||||||
|
*
|
||||||
|
* \return The asset, can be nullptr
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
AssetBase* GetAsset()
|
||||||
|
{
|
||||||
|
return m_asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Asset
|
||||||
|
*
|
||||||
|
* \return The asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const AssetBase* GetAsset() const
|
||||||
|
{
|
||||||
|
return m_asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the asset
|
||||||
|
*
|
||||||
|
* \param p_asset The asset
|
||||||
|
*/
|
||||||
|
void SetAsset(AssetBase* p_asset)
|
||||||
|
{
|
||||||
|
m_asset = p_asset;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContainerHandle& operator=(const ContainerHandle& p_handle) = default;
|
||||||
|
ContainerHandle& operator=(ContainerHandle&& p_handle) = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*
|
||||||
|
* The HardRef count
|
||||||
|
*/
|
||||||
|
std::uint32_t m_hardRefCount = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The SoftRef count
|
||||||
|
*/
|
||||||
|
std::uint32_t m_softRefCount = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The asset
|
||||||
|
*/
|
||||||
|
AssetBase* m_asset = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
class AssetContainerBase
|
||||||
|
{
|
||||||
|
using SlotMap = StableSlotMap<ContainerHandle>;
|
||||||
|
using SlotMapKey = SlotMap::SlotMapKey;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~AssetContainerBase() = default;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if an Asset is in the AssetContainer or not
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to check
|
||||||
|
* \return True if in AssetContainer, false otherwise
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
bool Has(const UUID& p_uuid) const
|
||||||
|
{
|
||||||
|
const Entry* entry = FindEntry(p_uuid);
|
||||||
|
return entry != nullptr && entry->m_assetSlotKey.Valid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Acquires a ContainerHandle for a given UUID
|
||||||
|
* Will create it if it does not exists
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to get ContainerHandle for
|
||||||
|
* \return A ContainerHandle for the UUID
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
ContainerHandle* AcquireContainerHandle(const UUID& p_uuid)
|
||||||
|
{
|
||||||
|
return m_handles.Get(GetOrCreateEntry(p_uuid).m_handleSlotKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove an Asset from the AssetContainer
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to remove
|
||||||
|
*/
|
||||||
|
virtual void Remove(const UUID& p_uuid)
|
||||||
|
{
|
||||||
|
if (Entry* entry = FindEntry(p_uuid); entry != nullptr && entry->m_handleSlotKey.Valid())
|
||||||
|
{
|
||||||
|
m_handles.Remove(entry->m_handleSlotKey);
|
||||||
|
m_uuidToEntry.erase(p_uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetContainerBase& operator=(const AssetContainerBase& p_container) = delete;
|
||||||
|
AssetContainerBase& operator=(AssetContainerBase&& p_container) = delete;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
struct Entry
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* SlotMapKey to the handle
|
||||||
|
*/
|
||||||
|
SlotMapKey m_handleSlotKey;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SlotMapKey to the asset
|
||||||
|
*/
|
||||||
|
SlotMapKey m_assetSlotKey;
|
||||||
|
};
|
||||||
|
|
||||||
|
AssetContainerBase() = default;
|
||||||
|
|
||||||
|
AssetContainerBase(const AssetContainerBase& p_container) = delete;
|
||||||
|
AssetContainerBase(AssetContainerBase&& p_container) = delete;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finds an entry matching the Asset
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to find
|
||||||
|
* \return Pointer to an Entry, nullptr otherwise
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
Entry* FindEntry(const UUID& p_uuid)
|
||||||
|
{
|
||||||
|
const auto it = m_uuidToEntry.find(p_uuid);
|
||||||
|
return it != m_uuidToEntry.end() ? &it->second : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finds an entry matching the Asset
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to find
|
||||||
|
* \return Pointer to an Entry, nullptr otherwise
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const Entry* FindEntry(const UUID& p_uuid) const
|
||||||
|
{
|
||||||
|
const auto it = m_uuidToEntry.find(p_uuid);
|
||||||
|
return it != m_uuidToEntry.end() ? &it->second : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finds an entry matching the Asset
|
||||||
|
* Creates it if it does not exist
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to find
|
||||||
|
* \return The entry matching the Asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
Entry& GetOrCreateEntry(const UUID& p_uuid)
|
||||||
|
{
|
||||||
|
auto [it, inserted] = m_uuidToEntry.try_emplace(p_uuid);
|
||||||
|
if (inserted)
|
||||||
|
{
|
||||||
|
it->second.m_handleSlotKey = m_handles.Insert();
|
||||||
|
}
|
||||||
|
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a ContainerHandle
|
||||||
|
*
|
||||||
|
* \param p_handleSlotKey The key to the container
|
||||||
|
* \return The container
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
ContainerHandle& FindContainerHandle(const SlotMapKey p_handleSlotKey)
|
||||||
|
{
|
||||||
|
return *m_handles.Get(p_handleSlotKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*
|
||||||
|
* HandleContainers
|
||||||
|
*/
|
||||||
|
SlotMap m_handles;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Every Asset added to the map
|
||||||
|
*/
|
||||||
|
ankerl::unordered_dense::segmented_map<UUID, Entry> m_uuidToEntry;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
template<class ASSET>
|
||||||
|
requires AssetType<ASSET>
|
||||||
|
class AssetContainer: public AssetContainerBase
|
||||||
|
{
|
||||||
|
using SlotMap = StableSlotMap<ASSET>;
|
||||||
|
using SlotMapKey = SlotMap::SlotMapKey;
|
||||||
|
|
||||||
|
public:
|
||||||
|
AssetContainer() = default;
|
||||||
|
|
||||||
|
AssetContainer(const AssetContainer& p_container) = delete;
|
||||||
|
AssetContainer(AssetContainer&& p_container) = delete;
|
||||||
|
|
||||||
|
~AssetContainer() = default;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inserts an Asset to the AssetContainer
|
||||||
|
*
|
||||||
|
* \tparam ARGS Arguments to construct the asset
|
||||||
|
* \param p_args The arguments
|
||||||
|
* \return The key to the inserted asset.
|
||||||
|
*/
|
||||||
|
template<class... ARGS>
|
||||||
|
[[nodiscard]]
|
||||||
|
SlotMapKey Insert(ARGS&&... p_args)
|
||||||
|
{
|
||||||
|
SlotMapKey slotKey = m_assets.Insert(std::forward<ARGS>(p_args)...);
|
||||||
|
ASSET* asset = m_assets.Get(slotKey);
|
||||||
|
|
||||||
|
Entry& entry = GetOrCreateEntry(asset->GetHeader().uuid);
|
||||||
|
if (entry.m_assetSlotKey.Valid())
|
||||||
|
{
|
||||||
|
m_assets.Remove(slotKey);
|
||||||
|
slotKey = entry.m_assetSlotKey;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entry.m_assetSlotKey = slotKey;
|
||||||
|
FindContainerHandle(entry.m_handleSlotKey).SetAsset(asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
return slotKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Asset
|
||||||
|
*
|
||||||
|
* \param p_key The key to the asset
|
||||||
|
* \return Pointer to the Asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
ASSET* Get(const SlotMapKey p_key)
|
||||||
|
{
|
||||||
|
return m_assets.Get(p_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Asset
|
||||||
|
*
|
||||||
|
* \param p_key The key to the asset
|
||||||
|
* \return Pointer to the Asset
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const ASSET* Get(const SlotMapKey p_key) const
|
||||||
|
{
|
||||||
|
return m_assets.Get(p_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove an Asset from the AssetContainer
|
||||||
|
*
|
||||||
|
* \param p_uuid The UUID to remove
|
||||||
|
*/
|
||||||
|
void Remove(const UUID& p_uuid) override
|
||||||
|
{
|
||||||
|
if (Entry* entry = FindEntry(p_uuid); entry != nullptr && entry->m_assetSlotKey.Valid())
|
||||||
|
{
|
||||||
|
FindContainerHandle(entry->m_handleSlotKey).SetAsset(nullptr);
|
||||||
|
m_assets.Remove(entry->m_assetSlotKey);
|
||||||
|
entry->m_assetSlotKey = SlotMapKey {};
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetContainerBase::Remove(p_uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetContainer& operator=(const AssetContainer& p_container) = delete;
|
||||||
|
AssetContainer& operator=(AssetContainer&& p_container) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*
|
||||||
|
* The assets
|
||||||
|
*/
|
||||||
|
SlotMap m_assets;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetHelper.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date April 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINE_ASSET_ASSETHELPER_HPP
|
||||||
|
#define BIGFOOT_ENGINE_ASSET_ASSETHELPER_HPP
|
||||||
|
#include <Engine/Asset/AssetContainer.hpp>
|
||||||
|
#include <Engine/Asset/AssetLibrary.hpp>
|
||||||
|
#include <Engine/Asset/Reference.hpp>
|
||||||
|
|
||||||
|
#define BIGFOOT_ASSET(AssetName, AssetType) \
|
||||||
|
namespace Bigfoot \
|
||||||
|
{ \
|
||||||
|
template<> \
|
||||||
|
AssetTypeID GetAssetTypeID<AssetType>() \
|
||||||
|
{ \
|
||||||
|
return AssetType::GetTypeID(); \
|
||||||
|
} \
|
||||||
|
AssetContainer<AssetType> g_containerFor##AssetName; \
|
||||||
|
const bool g_insertedContainerFor##AssetName = g_assetLibrary.Insert(&g_containerFor##AssetName); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetLibrary.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINE_ASSET_ASSETLIBRARY_HPP
|
||||||
|
#define BIGFOOT_ENGINE_ASSET_ASSETLIBRARY_HPP
|
||||||
|
#include <Engine/Asset/AssetConcepts.hpp>
|
||||||
|
#include <Engine/Asset/AssetContainer.hpp>
|
||||||
|
#include <Engine/Asset/AssetTypeID.hpp>
|
||||||
|
|
||||||
|
#include <ankerl/unordered_dense.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class AssetLibrary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AssetLibrary() = default;
|
||||||
|
|
||||||
|
AssetLibrary(const AssetLibrary& p_library) = default;
|
||||||
|
AssetLibrary(AssetLibrary&& p_library) = delete;
|
||||||
|
|
||||||
|
~AssetLibrary() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert an AssetContainer pointer to the library
|
||||||
|
*
|
||||||
|
* \tparam ASSET The Asset type
|
||||||
|
* \param p_assetContainer The asset container
|
||||||
|
* \return The AssetContainer for the Asset type. Nullptr if not found
|
||||||
|
*/
|
||||||
|
template<class ASSET>
|
||||||
|
requires AssetType<ASSET>
|
||||||
|
[[nodiscard]]
|
||||||
|
bool Insert(AssetContainer<ASSET>* p_assetContainer)
|
||||||
|
{
|
||||||
|
static const AssetTypeID typeID = ASSET::GetTypeID();
|
||||||
|
if (m_assetContainers.contains(typeID))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto inserted = m_assetContainers.emplace(typeID, p_assetContainer);
|
||||||
|
|
||||||
|
return inserted.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AssetContainer for a given AssetType
|
||||||
|
*
|
||||||
|
* \param p_typeID The asset type ID
|
||||||
|
* \return The AssetContainer for the AssetType. Nullptr if not found
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
AssetContainerBase* GetAssetContainer(const AssetTypeID p_typeID)
|
||||||
|
{
|
||||||
|
if (const auto container = m_assetContainers.find(p_typeID); container != m_assetContainers.end())
|
||||||
|
{
|
||||||
|
return container->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the AssetContainer for a given AssetType
|
||||||
|
*
|
||||||
|
* \param p_typeID The asset type ID
|
||||||
|
* \return The AssetContainer for the AssetType. Nullptr if not found
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const AssetContainerBase* GetAssetContainer(const AssetTypeID p_typeID) const
|
||||||
|
{
|
||||||
|
if (const auto container = m_assetContainers.find(p_typeID); container != m_assetContainers.end())
|
||||||
|
{
|
||||||
|
return container->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetLibrary& operator=(const AssetLibrary& p_library) = default;
|
||||||
|
AssetLibrary& operator=(AssetLibrary&& p_library) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// All the asset containers
|
||||||
|
ankerl::unordered_dense::segmented_map<AssetTypeID, AssetContainerBase*> m_assetContainers;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
// The global asset library for Bigfoot
|
||||||
|
inline AssetLibrary g_assetLibrary;
|
||||||
|
inline AssetLibrary* g_activeAssetLibrary = &g_assetLibrary;
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the active asset library
|
||||||
|
*
|
||||||
|
* \param p_assetLibrary The asset library to set g_activeAssetLibrary to.
|
||||||
|
*/
|
||||||
|
void SetActiveAssetLibrary(AssetLibrary* p_assetLibrary);
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
class ScopedActiveAssetLibrary
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ScopedActiveAssetLibrary(AssetLibrary* p_assetLibrary):
|
||||||
|
m_previous(g_activeAssetLibrary)
|
||||||
|
{
|
||||||
|
SetActiveAssetLibrary(p_assetLibrary);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedActiveAssetLibrary(const ScopedActiveAssetLibrary& p_scopedActiveAssetLibrary) = delete;
|
||||||
|
ScopedActiveAssetLibrary(ScopedActiveAssetLibrary&& p_scopedActiveAssetLibrary) = delete;
|
||||||
|
|
||||||
|
~ScopedActiveAssetLibrary()
|
||||||
|
{
|
||||||
|
SetActiveAssetLibrary(m_previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedActiveAssetLibrary& operator=(const ScopedActiveAssetLibrary& p_scopedActiveAssetLibrary) = delete;
|
||||||
|
ScopedActiveAssetLibrary& operator=(ScopedActiveAssetLibrary&& p_scopedActiveAssetLibrary) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*
|
||||||
|
* The previously active asset library.
|
||||||
|
*/
|
||||||
|
AssetLibrary* m_previous = nullptr;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
native_include "Engine/Asset/AssetTypeID.hpp";
|
||||||
|
|
||||||
|
namespace Flat.Bigfoot;
|
||||||
|
|
||||||
|
struct AssetTypeID (native_type: "::Bigfoot::AssetTypeID")
|
||||||
|
{
|
||||||
|
value: ulong;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetTypeID.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date February 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINE_ASSET_ASSETTYPEID_HPP
|
||||||
|
#define BIGFOOT_ENGINE_ASSET_ASSETTYPEID_HPP
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
using AssetTypeID = std::uint64_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
namespace Flat
|
||||||
|
{
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
struct AssetTypeID;
|
||||||
|
}
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
namespace flatbuffers
|
||||||
|
{
|
||||||
|
Flat::Bigfoot::AssetTypeID Pack(const Bigfoot::AssetTypeID& p_assetTypeID);
|
||||||
|
Bigfoot::AssetTypeID UnPack(const Flat::Bigfoot::AssetTypeID& p_flatAssetTypeID);
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_ASSETTYPEID_FLAT_BIGFOOT_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_ASSETTYPEID_FLAT_BIGFOOT_H_
|
||||||
|
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
|
#include "Engine/Asset/AssetTypeID.hpp"
|
||||||
|
|
||||||
|
#include "EASTL/unique_ptr.h"
|
||||||
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
struct AssetTypeID;
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetTypeIDTypeTable();
|
||||||
|
|
||||||
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) AssetTypeID FLATBUFFERS_FINAL_CLASS {
|
||||||
|
private:
|
||||||
|
uint64_t value_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetTypeIDTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetTypeID";
|
||||||
|
}
|
||||||
|
AssetTypeID()
|
||||||
|
: value_(0) {
|
||||||
|
}
|
||||||
|
AssetTypeID(uint64_t _value)
|
||||||
|
: value_(::flatbuffers::EndianScalar(_value)) {
|
||||||
|
}
|
||||||
|
uint64_t value() const {
|
||||||
|
return ::flatbuffers::EndianScalar(value_);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FLATBUFFERS_STRUCT_END(AssetTypeID, 8);
|
||||||
|
|
||||||
|
struct AssetTypeID::Traits {
|
||||||
|
using type = AssetTypeID;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetTypeIDTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_ULONG, 0, -1 }
|
||||||
|
};
|
||||||
|
static const int64_t values[] = { 0, 8 };
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_STRUCT, 1, type_codes, nullptr, nullptr, values, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_ASSETTYPEID_FLAT_BIGFOOT_H_
|
||||||
@@ -0,0 +1,413 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_ASSET_FLAT_BIGFOOT_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_ASSET_FLAT_BIGFOOT_H_
|
||||||
|
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
|
#include "Engine/Asset/AssetTypeID.hpp"
|
||||||
|
#include "System/UUID/UUID.hpp"
|
||||||
|
#include "Engine/Asset/AssetTypeID_generated.hpp"
|
||||||
|
#include "System/UUID/UUID_generated.hpp"
|
||||||
|
|
||||||
|
#include "EASTL/unique_ptr.h"
|
||||||
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
struct AssetHeader;
|
||||||
|
struct AssetHeaderBuilder;
|
||||||
|
struct AssetHeaderT;
|
||||||
|
|
||||||
|
struct Asset;
|
||||||
|
struct AssetBuilder;
|
||||||
|
struct AssetT;
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetHeaderTypeTable();
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetTypeTable();
|
||||||
|
|
||||||
|
struct AssetHeaderT : public ::flatbuffers::NativeTable {
|
||||||
|
typedef AssetHeader TableType;
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetHeaderT";
|
||||||
|
}
|
||||||
|
::Bigfoot::UUID uuid{};
|
||||||
|
eastl::string name{};
|
||||||
|
::Bigfoot::AssetTypeID type_id{};
|
||||||
|
eastl::string type_name{};
|
||||||
|
uint32_t version = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetHeader FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef AssetHeaderT NativeTableType;
|
||||||
|
typedef AssetHeaderBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetHeaderTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetHeader";
|
||||||
|
}
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_UUID = 4,
|
||||||
|
VT_NAME = 6,
|
||||||
|
VT_TYPE_ID = 8,
|
||||||
|
VT_TYPE_NAME = 10,
|
||||||
|
VT_VERSION = 12
|
||||||
|
};
|
||||||
|
const Flat::Bigfoot::UUID *uuid() const {
|
||||||
|
return GetStruct<const Flat::Bigfoot::UUID *>(VT_UUID);
|
||||||
|
}
|
||||||
|
const ::flatbuffers::String *name() const {
|
||||||
|
return GetPointer<const ::flatbuffers::String *>(VT_NAME);
|
||||||
|
}
|
||||||
|
const Flat::Bigfoot::AssetTypeID *type_id() const {
|
||||||
|
return GetStruct<const Flat::Bigfoot::AssetTypeID *>(VT_TYPE_ID);
|
||||||
|
}
|
||||||
|
const ::flatbuffers::String *type_name() const {
|
||||||
|
return GetPointer<const ::flatbuffers::String *>(VT_TYPE_NAME);
|
||||||
|
}
|
||||||
|
uint32_t version() const {
|
||||||
|
return GetField<uint32_t>(VT_VERSION, 0);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyFieldRequired<Flat::Bigfoot::UUID>(verifier, VT_UUID, 1) &&
|
||||||
|
VerifyOffsetRequired(verifier, VT_NAME) &&
|
||||||
|
verifier.VerifyString(name()) &&
|
||||||
|
VerifyFieldRequired<Flat::Bigfoot::AssetTypeID>(verifier, VT_TYPE_ID, 8) &&
|
||||||
|
VerifyOffsetRequired(verifier, VT_TYPE_NAME) &&
|
||||||
|
verifier.VerifyString(type_name()) &&
|
||||||
|
VerifyField<uint32_t>(verifier, VT_VERSION, 4) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
AssetHeaderT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
void UnPackTo(AssetHeaderT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
static ::flatbuffers::Offset<AssetHeader> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetHeaderT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetHeaderBuilder {
|
||||||
|
typedef AssetHeader Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_uuid(const Flat::Bigfoot::UUID *uuid) {
|
||||||
|
fbb_.AddStruct(AssetHeader::VT_UUID, uuid);
|
||||||
|
}
|
||||||
|
void add_name(::flatbuffers::Offset<::flatbuffers::String> name) {
|
||||||
|
fbb_.AddOffset(AssetHeader::VT_NAME, name);
|
||||||
|
}
|
||||||
|
void add_type_id(const Flat::Bigfoot::AssetTypeID *type_id) {
|
||||||
|
fbb_.AddStruct(AssetHeader::VT_TYPE_ID, type_id);
|
||||||
|
}
|
||||||
|
void add_type_name(::flatbuffers::Offset<::flatbuffers::String> type_name) {
|
||||||
|
fbb_.AddOffset(AssetHeader::VT_TYPE_NAME, type_name);
|
||||||
|
}
|
||||||
|
void add_version(uint32_t version) {
|
||||||
|
fbb_.AddElement<uint32_t>(AssetHeader::VT_VERSION, version, 0);
|
||||||
|
}
|
||||||
|
explicit AssetHeaderBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<AssetHeader> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<AssetHeader>(end);
|
||||||
|
fbb_.Required(o, AssetHeader::VT_UUID);
|
||||||
|
fbb_.Required(o, AssetHeader::VT_NAME);
|
||||||
|
fbb_.Required(o, AssetHeader::VT_TYPE_ID);
|
||||||
|
fbb_.Required(o, AssetHeader::VT_TYPE_NAME);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetHeader> CreateAssetHeader(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
const Flat::Bigfoot::UUID *uuid = nullptr,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::String> name = 0,
|
||||||
|
const Flat::Bigfoot::AssetTypeID *type_id = nullptr,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::String> type_name = 0,
|
||||||
|
uint32_t version = 0) {
|
||||||
|
AssetHeaderBuilder builder_(_fbb);
|
||||||
|
builder_.add_version(version);
|
||||||
|
builder_.add_type_name(type_name);
|
||||||
|
builder_.add_type_id(type_id);
|
||||||
|
builder_.add_name(name);
|
||||||
|
builder_.add_uuid(uuid);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetHeader::Traits {
|
||||||
|
using type = AssetHeader;
|
||||||
|
static auto constexpr Create = CreateAssetHeader;
|
||||||
|
};
|
||||||
|
|
||||||
|
::flatbuffers::Offset<AssetHeader> CreateAssetHeader(::flatbuffers::FlatBufferBuilder &_fbb, const AssetHeaderT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
|
||||||
|
struct AssetT : public ::flatbuffers::NativeTable {
|
||||||
|
typedef Asset TableType;
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetT";
|
||||||
|
}
|
||||||
|
eastl::unique_ptr<Flat::Bigfoot::AssetHeaderT> header{new Flat::Bigfoot::AssetHeaderT()};
|
||||||
|
eastl::vector<uint8_t> inner_asset{};
|
||||||
|
AssetT() = default;
|
||||||
|
AssetT(const AssetT &o);
|
||||||
|
AssetT(AssetT&&) FLATBUFFERS_NOEXCEPT = default;
|
||||||
|
AssetT &operator=(AssetT o) FLATBUFFERS_NOEXCEPT;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Asset FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef AssetT NativeTableType;
|
||||||
|
typedef AssetBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.Asset";
|
||||||
|
}
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_HEADER = 4,
|
||||||
|
VT_INNER_ASSET = 6
|
||||||
|
};
|
||||||
|
const Flat::Bigfoot::AssetHeader *header() const {
|
||||||
|
return GetPointer<const Flat::Bigfoot::AssetHeader *>(VT_HEADER);
|
||||||
|
}
|
||||||
|
const ::flatbuffers::Vector<uint8_t> *inner_asset() const {
|
||||||
|
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_INNER_ASSET);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyOffsetRequired(verifier, VT_HEADER) &&
|
||||||
|
verifier.VerifyTable(header()) &&
|
||||||
|
VerifyOffsetRequired(verifier, VT_INNER_ASSET) &&
|
||||||
|
verifier.VerifyVector(inner_asset()) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
AssetT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
void UnPackTo(AssetT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
static ::flatbuffers::Offset<Asset> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetBuilder {
|
||||||
|
typedef Asset Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_header(::flatbuffers::Offset<Flat::Bigfoot::AssetHeader> header) {
|
||||||
|
fbb_.AddOffset(Asset::VT_HEADER, header);
|
||||||
|
}
|
||||||
|
void add_inner_asset(::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> inner_asset) {
|
||||||
|
fbb_.AddOffset(Asset::VT_INNER_ASSET, inner_asset);
|
||||||
|
}
|
||||||
|
explicit AssetBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<Asset> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<Asset>(end);
|
||||||
|
fbb_.Required(o, Asset::VT_HEADER);
|
||||||
|
fbb_.Required(o, Asset::VT_INNER_ASSET);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<Asset> CreateAsset(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::AssetHeader> header = 0,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> inner_asset = 0) {
|
||||||
|
AssetBuilder builder_(_fbb);
|
||||||
|
builder_.add_inner_asset(inner_asset);
|
||||||
|
builder_.add_header(header);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Asset::Traits {
|
||||||
|
using type = Asset;
|
||||||
|
static auto constexpr Create = CreateAsset;
|
||||||
|
};
|
||||||
|
|
||||||
|
::flatbuffers::Offset<Asset> CreateAsset(::flatbuffers::FlatBufferBuilder &_fbb, const AssetT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
|
||||||
|
inline AssetHeaderT *AssetHeader::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
auto _o = std::make_unique<AssetHeaderT>();
|
||||||
|
UnPackTo(_o.get(), _resolver);
|
||||||
|
return _o.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AssetHeader::UnPackTo(AssetHeaderT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
(void)_o;
|
||||||
|
(void)_resolver;
|
||||||
|
{ auto _e = uuid(); if (_e) _o->uuid = ::flatbuffers::UnPack(*_e); }
|
||||||
|
{ auto _e = name(); if (_e) _o->name = eastl::string(_e->c_str(), _e->size()); }
|
||||||
|
{ auto _e = type_id(); if (_e) _o->type_id = ::flatbuffers::UnPack(*_e); }
|
||||||
|
{ auto _e = type_name(); if (_e) _o->type_name = eastl::string(_e->c_str(), _e->size()); }
|
||||||
|
{ auto _e = version(); _o->version = _e; }
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetHeader> CreateAssetHeader(::flatbuffers::FlatBufferBuilder &_fbb, const AssetHeaderT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
return AssetHeader::Pack(_fbb, _o, _rehasher);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetHeader> AssetHeader::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetHeaderT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
(void)_rehasher;
|
||||||
|
(void)_o;
|
||||||
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const AssetHeaderT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
|
auto _uuid = ::flatbuffers::Pack(_o->uuid);
|
||||||
|
auto _name = _fbb.CreateString(_o->name);
|
||||||
|
auto _type_id = ::flatbuffers::Pack(_o->type_id);
|
||||||
|
auto _type_name = _fbb.CreateString(_o->type_name);
|
||||||
|
auto _version = _o->version;
|
||||||
|
return Flat::Bigfoot::CreateAssetHeader(
|
||||||
|
_fbb,
|
||||||
|
&_uuid,
|
||||||
|
_name,
|
||||||
|
&_type_id,
|
||||||
|
_type_name,
|
||||||
|
_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AssetT::AssetT(const AssetT &o)
|
||||||
|
: header((o.header) ? new Flat::Bigfoot::AssetHeaderT(*o.header) : nullptr),
|
||||||
|
inner_asset(o.inner_asset) {
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AssetT &AssetT::operator=(AssetT o) FLATBUFFERS_NOEXCEPT {
|
||||||
|
std::swap(header, o.header);
|
||||||
|
std::swap(inner_asset, o.inner_asset);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AssetT *Asset::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
auto _o = std::make_unique<AssetT>();
|
||||||
|
UnPackTo(_o.get(), _resolver);
|
||||||
|
return _o.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Asset::UnPackTo(AssetT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
(void)_o;
|
||||||
|
(void)_resolver;
|
||||||
|
{ auto _e = header(); if (_e) { if(_o->header) { _e->UnPackTo(_o->header.get(), _resolver); } else { _o->header = eastl::unique_ptr<Flat::Bigfoot::AssetHeaderT>(_e->UnPack(_resolver)); } } else if (_o->header) { _o->header.reset(); } }
|
||||||
|
{ auto _e = inner_asset(); if (_e) { _o->inner_asset.resize(_e->size()); std::copy(_e->begin(), _e->end(), _o->inner_asset.begin()); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<Asset> CreateAsset(::flatbuffers::FlatBufferBuilder &_fbb, const AssetT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
return Asset::Pack(_fbb, _o, _rehasher);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<Asset> Asset::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
(void)_rehasher;
|
||||||
|
(void)_o;
|
||||||
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const AssetT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
|
auto _header = _o->header ? CreateAssetHeader(_fbb, _o->header.get(), _rehasher) : 0;
|
||||||
|
auto _inner_asset = _fbb.CreateVector(_o->inner_asset.data(), _o->inner_asset.size());
|
||||||
|
return Flat::Bigfoot::CreateAsset(
|
||||||
|
_fbb,
|
||||||
|
_header,
|
||||||
|
_inner_asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetHeaderTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
|
{ ::flatbuffers::ET_STRING, 0, -1 },
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 1 },
|
||||||
|
{ ::flatbuffers::ET_STRING, 0, -1 },
|
||||||
|
{ ::flatbuffers::ET_UINT, 0, -1 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Flat::Bigfoot::UUIDTypeTable,
|
||||||
|
Flat::Bigfoot::AssetTypeIDTypeTable
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_TABLE, 5, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
|
{ ::flatbuffers::ET_UCHAR, 1, -1 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Flat::Bigfoot::AssetHeaderTypeTable
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_TABLE, 2, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Flat::Bigfoot::Asset *GetAsset(const void *buf) {
|
||||||
|
return ::flatbuffers::GetRoot<Flat::Bigfoot::Asset>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Flat::Bigfoot::Asset *GetSizePrefixedAsset(const void *buf) {
|
||||||
|
return ::flatbuffers::GetSizePrefixedRoot<Flat::Bigfoot::Asset>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifyAssetBuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifyBuffer<Flat::Bigfoot::Asset>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifySizePrefixedAssetBuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifySizePrefixedBuffer<Flat::Bigfoot::Asset>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *AssetExtension() {
|
||||||
|
return "bfbs";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishAssetBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::Asset> root) {
|
||||||
|
fbb.Finish(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishSizePrefixedAssetBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::Asset> root) {
|
||||||
|
fbb.FinishSizePrefixed(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Flat::Bigfoot::AssetT> UnPackAsset(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Flat::Bigfoot::AssetT>(GetAsset(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Flat::Bigfoot::AssetT> UnPackSizePrefixedAsset(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Flat::Bigfoot::AssetT>(GetSizePrefixedAsset(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_ASSET_FLAT_BIGFOOT_H_
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
include "System/UUID/UUID.fbs";
|
||||||
|
|
||||||
|
native_include "Engine/Asset/Reference.hpp";
|
||||||
|
|
||||||
|
namespace Flat.Bigfoot;
|
||||||
|
|
||||||
|
struct HardReference (bigfoot_ref_wrapper: "::Bigfoot::HardReference")
|
||||||
|
{
|
||||||
|
uuid: UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SoftReference (bigfoot_ref_wrapper: "::Bigfoot::SoftReference")
|
||||||
|
{
|
||||||
|
uuid: UUID;
|
||||||
|
}
|
||||||
@@ -0,0 +1,245 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file Reference.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date April 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINE_ASSET_REFERENCE_HPP
|
||||||
|
#define BIGFOOT_ENGINE_ASSET_REFERENCE_HPP
|
||||||
|
#include <Engine/Asset/AssetConcepts.hpp>
|
||||||
|
#include <Engine/Asset/AssetLibrary.hpp>
|
||||||
|
|
||||||
|
#include <System/UUID/UUID.hpp>
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
template<class ASSET>
|
||||||
|
AssetTypeID GetAssetTypeID();
|
||||||
|
|
||||||
|
template<>
|
||||||
|
AssetTypeID GetAssetTypeID<AssetBase>() = delete;
|
||||||
|
|
||||||
|
template<class DERIVED, class ASSET>
|
||||||
|
class ReferenceBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Get the UUID of the reference
|
||||||
|
*
|
||||||
|
* \return The UUID of the reference
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const UUID& GetUUID() const
|
||||||
|
{
|
||||||
|
return m_uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the asset
|
||||||
|
*
|
||||||
|
* \return The asset, nullptr if it is not loaded
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
const ASSET* Get() const
|
||||||
|
{
|
||||||
|
static_assert(AssetType<ASSET>, "ASSET must derive from AssetBase (and not be AssetBase itself)");
|
||||||
|
return m_handle ? static_cast<const ASSET*>(m_handle->GetAsset()) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the asset
|
||||||
|
*
|
||||||
|
* \return The asset, nullptr if it is not loaded
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
ASSET* Get()
|
||||||
|
{
|
||||||
|
static_assert(AssetType<ASSET>, "ASSET must derive from AssetBase (and not be AssetBase itself)");
|
||||||
|
return m_handle ? static_cast<ASSET*>(m_handle->GetAsset()) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
~ReferenceBase()
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReferenceBase& operator=(const ReferenceBase& p_reference)
|
||||||
|
{
|
||||||
|
if (this != &p_reference)
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
m_uuid = p_reference.m_uuid;
|
||||||
|
m_handle = p_reference.m_handle;
|
||||||
|
Acquire();
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReferenceBase& operator=(ReferenceBase&& p_reference) noexcept
|
||||||
|
{
|
||||||
|
if (this != &p_reference)
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
m_uuid = std::exchange(p_reference.m_uuid, UUID::NULL_UUID);
|
||||||
|
m_handle = std::exchange(p_reference.m_handle, nullptr);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
bool operator==(const ReferenceBase& p_reference) const
|
||||||
|
{
|
||||||
|
return m_uuid == p_reference.m_uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ReferenceBase() = default;
|
||||||
|
|
||||||
|
ReferenceBase(const UUID& p_uuid):
|
||||||
|
m_uuid(p_uuid)
|
||||||
|
{
|
||||||
|
Acquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReferenceBase(const ReferenceBase& p_reference):
|
||||||
|
m_uuid(p_reference.m_uuid),
|
||||||
|
m_handle(p_reference.m_handle)
|
||||||
|
{
|
||||||
|
Acquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReferenceBase(ReferenceBase&& p_reference) noexcept:
|
||||||
|
m_uuid(std::exchange(p_reference.m_uuid, UUID::NULL_UUID)),
|
||||||
|
m_handle(std::exchange(p_reference.m_handle, nullptr))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* Get the associated handle container for the asset
|
||||||
|
* Register the reference inside the handle
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Acquire()
|
||||||
|
{
|
||||||
|
if (!m_uuid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AssetContainerBase* assetContainer = g_activeAssetLibrary->GetAssetContainer(GetAssetTypeID<ASSET>()))
|
||||||
|
{
|
||||||
|
if (!m_handle)
|
||||||
|
{
|
||||||
|
m_handle = assetContainer->AcquireContainerHandle(m_uuid);
|
||||||
|
}
|
||||||
|
DERIVED::IncrementCount(*m_handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister the reference from the handle
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Release()
|
||||||
|
{
|
||||||
|
if (m_handle)
|
||||||
|
{
|
||||||
|
DERIVED::DecrementCount(*m_handle);
|
||||||
|
m_handle = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* The UUID
|
||||||
|
*/
|
||||||
|
UUID m_uuid = UUID::NULL_UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle for the asset
|
||||||
|
*/
|
||||||
|
ContainerHandle* m_handle = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Owning reference
|
||||||
|
* Keeps the asset alive
|
||||||
|
*/
|
||||||
|
template<class ASSET>
|
||||||
|
class HardReference: public ReferenceBase<HardReference<ASSET>, ASSET>
|
||||||
|
{
|
||||||
|
using Base = ReferenceBase<HardReference<ASSET>, ASSET>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
HardReference() = default;
|
||||||
|
|
||||||
|
HardReference(const UUID& p_uuid):
|
||||||
|
Base(p_uuid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* Increment the hard ref count of the handle
|
||||||
|
*
|
||||||
|
* \param p_handle The handle for the asset
|
||||||
|
*/
|
||||||
|
static void IncrementCount(ContainerHandle& p_handle)
|
||||||
|
{
|
||||||
|
p_handle.IncrementHardRefCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrement the hard ref count of the handle
|
||||||
|
*
|
||||||
|
* \param p_handle The handle for the asset
|
||||||
|
*/
|
||||||
|
static void DecrementCount(ContainerHandle& p_handle)
|
||||||
|
{
|
||||||
|
p_handle.DecrementHardRefCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend Base;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class ASSET>
|
||||||
|
class SoftReference: public ReferenceBase<SoftReference<ASSET>, ASSET>
|
||||||
|
{
|
||||||
|
using Base = ReferenceBase<SoftReference<ASSET>, ASSET>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SoftReference() = default;
|
||||||
|
|
||||||
|
SoftReference(const UUID& p_uuid):
|
||||||
|
Base(p_uuid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* Increment the soft ref count of the handle
|
||||||
|
*
|
||||||
|
* \param p_handle The handle for the asset
|
||||||
|
*/
|
||||||
|
static void IncrementCount(ContainerHandle& p_handle)
|
||||||
|
{
|
||||||
|
p_handle.IncrementSoftRefCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrement the hard ref count of the handle
|
||||||
|
*
|
||||||
|
* \param p_handle The handle for the asset
|
||||||
|
*/
|
||||||
|
static void DecrementCount(ContainerHandle& p_handle)
|
||||||
|
{
|
||||||
|
p_handle.DecrementSoftRefCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend Base;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_REFERENCE_FLAT_BIGFOOT_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_REFERENCE_FLAT_BIGFOOT_H_
|
||||||
|
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
|
#include "System/UUID/UUID.hpp"
|
||||||
|
#include "Engine/Asset/Reference.hpp"
|
||||||
|
#include "System/UUID/UUID_generated.hpp"
|
||||||
|
|
||||||
|
#include "EASTL/unique_ptr.h"
|
||||||
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
struct HardReference;
|
||||||
|
|
||||||
|
struct SoftReference;
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *HardReferenceTypeTable();
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *SoftReferenceTypeTable();
|
||||||
|
|
||||||
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) HardReference FLATBUFFERS_FINAL_CLASS {
|
||||||
|
private:
|
||||||
|
Flat::Bigfoot::UUID uuid_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return HardReferenceTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.HardReference";
|
||||||
|
}
|
||||||
|
HardReference()
|
||||||
|
: uuid_() {
|
||||||
|
}
|
||||||
|
HardReference(const Flat::Bigfoot::UUID &_uuid)
|
||||||
|
: uuid_(_uuid) {
|
||||||
|
}
|
||||||
|
const Flat::Bigfoot::UUID &uuid() const {
|
||||||
|
return uuid_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FLATBUFFERS_STRUCT_END(HardReference, 16);
|
||||||
|
|
||||||
|
struct HardReference::Traits {
|
||||||
|
using type = HardReference;
|
||||||
|
};
|
||||||
|
|
||||||
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) SoftReference FLATBUFFERS_FINAL_CLASS {
|
||||||
|
private:
|
||||||
|
Flat::Bigfoot::UUID uuid_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return SoftReferenceTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.SoftReference";
|
||||||
|
}
|
||||||
|
SoftReference()
|
||||||
|
: uuid_() {
|
||||||
|
}
|
||||||
|
SoftReference(const Flat::Bigfoot::UUID &_uuid)
|
||||||
|
: uuid_(_uuid) {
|
||||||
|
}
|
||||||
|
const Flat::Bigfoot::UUID &uuid() const {
|
||||||
|
return uuid_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FLATBUFFERS_STRUCT_END(SoftReference, 16);
|
||||||
|
|
||||||
|
struct SoftReference::Traits {
|
||||||
|
using type = SoftReference;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *HardReferenceTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Flat::Bigfoot::UUIDTypeTable
|
||||||
|
};
|
||||||
|
static const int64_t values[] = { 0, 16 };
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *SoftReferenceTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Flat::Bigfoot::UUIDTypeTable
|
||||||
|
};
|
||||||
|
static const int64_t values[] = { 0, 16 };
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_STRUCT, 1, type_codes, type_refs, nullptr, values, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_REFERENCE_FLAT_BIGFOOT_H_
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file BigFile.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date October 2025
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ENGINE_BIGFILE_BIGFILE_HPP
|
||||||
|
#define BIGFOOT_ENGINE_BIGFILE_BIGFILE_HPP
|
||||||
|
#include <System/File.hpp>
|
||||||
|
|
||||||
|
#include <Utils/TaggedType.hpp>
|
||||||
|
|
||||||
|
#include <EASTL/span.h>
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class BigFile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* \param p_file The file targetting the BigFile DB
|
||||||
|
*/
|
||||||
|
BigFile(const File& p_file);
|
||||||
|
|
||||||
|
BigFile(const BigFile& p_bigFile) = delete;
|
||||||
|
BigFile(BigFile&& p_bigFile) = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin a transaction
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void BeginTransaction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit a transaction
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void CommitTransaction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollback a transaction
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void RollbackTransaction();
|
||||||
|
|
||||||
|
~BigFile();
|
||||||
|
|
||||||
|
BigFile& operator=(const BigFile& p_bigFile) = delete;
|
||||||
|
BigFile& operator=(BigFile&& p_bigFile) = delete;
|
||||||
|
|
||||||
|
class Request
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* \param p_bigFile The bigfile
|
||||||
|
* \param p_request The SQL request
|
||||||
|
*/
|
||||||
|
Request(const BigFile& p_bigFile, const eastl::string_view p_request);
|
||||||
|
|
||||||
|
Request(const Request& p_request) = delete;
|
||||||
|
Request(Request&& p_request) = delete;
|
||||||
|
|
||||||
|
using CopyValue = TaggedType<bool>;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind a int32 value to the Request at index
|
||||||
|
*
|
||||||
|
* \param p_index The index to bind to
|
||||||
|
* \param p_value The value
|
||||||
|
*/
|
||||||
|
void Bind(const std::uint32_t p_index, const std::int32_t p_value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind a uint32 value to the Request at index
|
||||||
|
*
|
||||||
|
* \param p_index The index to bind to
|
||||||
|
* \param p_value The value
|
||||||
|
*/
|
||||||
|
void Bind(const std::uint32_t p_index, const std::uint32_t p_value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind a int64 value to the Request at index
|
||||||
|
*
|
||||||
|
* \param p_index The index to bind to
|
||||||
|
* \param p_value The value
|
||||||
|
*/
|
||||||
|
void Bind(const std::uint32_t p_index, const std::int64_t p_value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind a uint64 value to the Request at index
|
||||||
|
*
|
||||||
|
* \param p_index The index to bind to
|
||||||
|
* \param p_value The value
|
||||||
|
*/
|
||||||
|
void Bind(const std::uint32_t p_index, const std::uint64_t p_value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind a float value to the Request at index
|
||||||
|
*
|
||||||
|
* \param p_index The index to bind to
|
||||||
|
* \param p_value The value
|
||||||
|
*/
|
||||||
|
void Bind(const std::uint32_t p_index, const float p_value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind a double value to the Request at index
|
||||||
|
*
|
||||||
|
* \param p_index The index to bind to
|
||||||
|
* \param p_value The value
|
||||||
|
*/
|
||||||
|
void Bind(const std::uint32_t p_index, const double p_value);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind a string value to the Request at index
|
||||||
|
*
|
||||||
|
* \param p_index The index to bind to
|
||||||
|
* \param p_value The value
|
||||||
|
* \param p_copy Should the memory be copied so that caller does not have to retain it
|
||||||
|
*/
|
||||||
|
void Bind(const std::uint32_t p_index,
|
||||||
|
const eastl::string_view p_value,
|
||||||
|
const CopyValue p_copy = CopyValue {false});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bind a blob value to the Request at index
|
||||||
|
*
|
||||||
|
* \param p_index The index to bind to
|
||||||
|
* \param p_value The value
|
||||||
|
* \param p_copy Should the memory be copied so that caller does not have to retain it
|
||||||
|
*/
|
||||||
|
void Bind(const std::uint32_t p_index,
|
||||||
|
const eastl::span<const std::byte> p_value,
|
||||||
|
const CopyValue p_copy = CopyValue {false});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Step through the request
|
||||||
|
*
|
||||||
|
* \return True if the request can continue (get next row), false otherwise
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
bool Step();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Execute the request once
|
||||||
|
*
|
||||||
|
* The number of modified rows
|
||||||
|
*/
|
||||||
|
[[maybe_unused]]
|
||||||
|
std::uint32_t Execute();
|
||||||
|
|
||||||
|
class Column
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* \param p_request The request to get the column of
|
||||||
|
* \param p_index Column index
|
||||||
|
*/
|
||||||
|
Column(const Request& p_request, const std::uint32_t p_index);
|
||||||
|
|
||||||
|
Column(const Column& p_column) = default;
|
||||||
|
Column(Column&& p_column) = default;
|
||||||
|
|
||||||
|
~Column() = default;
|
||||||
|
|
||||||
|
Column& operator=(const Column& p_column) = default;
|
||||||
|
Column& operator=(Column&& p_column) = default;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a int32
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator std::int32_t() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a uint32
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator std::uint32_t() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a int64
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator std::int64_t() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a uint64
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator std::uint64_t() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a float
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator float() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a double
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator double() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a string
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator eastl::string_view() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get value as a blob
|
||||||
|
*
|
||||||
|
* \return The value
|
||||||
|
*/
|
||||||
|
operator eastl::span<const std::byte>() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*
|
||||||
|
* The statement
|
||||||
|
*/
|
||||||
|
sqlite3_stmt* m_statement;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The column index
|
||||||
|
*/
|
||||||
|
std::uint32_t m_index;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a column
|
||||||
|
*
|
||||||
|
* \param p_index Column index
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
Column Get(const std::uint32_t p_index) const;
|
||||||
|
|
||||||
|
~Request();
|
||||||
|
|
||||||
|
Request& operator=(const Request& p_request) = delete;
|
||||||
|
Request& operator=(Request&& p_request) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/*
|
||||||
|
* The database
|
||||||
|
*/
|
||||||
|
sqlite3* m_db;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The statement
|
||||||
|
*/
|
||||||
|
sqlite3_stmt* m_statement;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* The BigFile DB
|
||||||
|
*/
|
||||||
|
sqlite3* m_db;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -6,55 +6,15 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_ENGINE_ENGINEASSERTHANDLER_HPP
|
#ifndef BIGFOOT_ENGINE_ENGINEASSERTHANDLER_HPP
|
||||||
#define BIGFOOT_ENGINE_ENGINEASSERTHANDLER_HPP
|
#define BIGFOOT_ENGINE_ENGINEASSERTHANDLER_HPP
|
||||||
#include <Utils/Assert.hpp>
|
|
||||||
|
|
||||||
#include <Engine/EngineLogger_generated.hpp>
|
#include <Engine/EngineLogger_generated.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#include <Utils/Assert/AssertHandler.hpp>
|
||||||
#include <EASTL/utility.h>
|
|
||||||
|
|
||||||
#include <format>
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
#include <source_location>
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
class EngineAssertHandler
|
using EngineAssertHandler = AssertHandler<ENGINE_LOGGER>;
|
||||||
{
|
|
||||||
public:
|
|
||||||
EngineAssertHandler() = delete;
|
|
||||||
|
|
||||||
EngineAssertHandler(const EngineAssertHandler& p_handler) = delete;
|
|
||||||
EngineAssertHandler(EngineAssertHandler&& p_handler) = delete;
|
|
||||||
|
|
||||||
~EngineAssertHandler() = delete;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle an assertion.
|
|
||||||
*
|
|
||||||
* \param p_location Location of the assertion.
|
|
||||||
* \param p_stacktrace The stack trace
|
|
||||||
* \param p_format Format string for the assertion message.
|
|
||||||
* \param p_args Arguments for the format string.
|
|
||||||
*/
|
|
||||||
template<typename... ARGS>
|
|
||||||
static void Handle(const std::source_location& p_location,
|
|
||||||
const std::string_view p_stacktrace,
|
|
||||||
std::format_string<ARGS...> p_format,
|
|
||||||
ARGS&&... p_args)
|
|
||||||
{
|
|
||||||
BIGFOOT_LOG_FATAL(ENGINE_LOGGER,
|
|
||||||
"Assert: {} (File:{}, Line:{}, Function:{}\n{}",
|
|
||||||
std::format(p_format, eastl::forward<ARGS>(p_args)...),
|
|
||||||
p_location.file_name(),
|
|
||||||
p_location.line(),
|
|
||||||
p_location.function_name(),
|
|
||||||
p_stacktrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
EngineAssertHandler& operator=(const EngineAssertHandler& p_handler) = delete;
|
|
||||||
EngineAssertHandler& operator=(EngineAssertHandler&& p_handler) = delete;
|
|
||||||
};
|
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_ENGINELOGGER_GENERATED_HPP
|
#ifndef BIGFOOT_ENGINELOGGER_GENERATED_HPP
|
||||||
#define BIGFOOT_ENGINELOGGER_GENERATED_HPP
|
#define BIGFOOT_ENGINELOGGER_GENERATED_HPP
|
||||||
#include <System/Log/Log.hpp>
|
#include <Utils/Log/LogMacros.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
// to delete when an actual source is in Engine
|
|
||||||
@@ -2,8 +2,6 @@ get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
|||||||
project(${PackageName})
|
project(${PackageName})
|
||||||
|
|
||||||
set(PublicDependencies
|
set(PublicDependencies
|
||||||
$<$<CONFIG:Debug,RelWithDebInfo>:quill::quill>
|
|
||||||
mimalloc
|
|
||||||
stduuid::stduuid)
|
stduuid::stduuid)
|
||||||
set(PrivateDependencies)
|
set(PrivateDependencies)
|
||||||
set(BigfootPublicDependencies
|
set(BigfootPublicDependencies
|
||||||
@@ -18,11 +16,3 @@ bigfoot_create_package_lib(
|
|||||||
"")
|
"")
|
||||||
|
|
||||||
bigfoot_create_logger()
|
bigfoot_create_logger()
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME}
|
|
||||||
PUBLIC $<$<CONFIG:Debug,RelWithDebInfo>:QUILL_NO_EXCEPTIONS>
|
|
||||||
PUBLIC $<$<CONFIG:Debug,RelWithDebInfo>:QUILL_DISABLE_NON_PREFIXED_MACROS>
|
|
||||||
|
|
||||||
PUBLIC MI_SHARED_LIB)
|
|
||||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/MimallocImpl.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,21 +37,21 @@ bool File::Exists() const
|
|||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
eastl::string_view File::Path() const
|
eastl::string_view File::GetPath() const
|
||||||
{
|
{
|
||||||
return m_pathString;
|
return m_pathString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
File File::Absolute() const
|
File File::ToAbsolute() const
|
||||||
{
|
{
|
||||||
return File {std::filesystem::absolute(m_path)};
|
return File {std::filesystem::absolute(m_path)};
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
File File::Relative() const
|
File File::ToRelative() const
|
||||||
{
|
{
|
||||||
return File {std::filesystem::relative(m_path)};
|
return File {std::filesystem::relative(m_path)};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class File
|
|||||||
* \return The path
|
* \return The path
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
eastl::string_view Path() const;
|
eastl::string_view GetPath() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the same file, relative to the current executable
|
* Get the same file, relative to the current executable
|
||||||
@@ -65,7 +65,7 @@ class File
|
|||||||
* \return The relative file
|
* \return The relative file
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
File Relative() const;
|
File ToRelative() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the same file, with an absolute path
|
* Get the same file, with an absolute path
|
||||||
@@ -73,7 +73,7 @@ class File
|
|||||||
* \return The absolute file
|
* \return The absolute file
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
File Absolute() const;
|
File ToAbsolute() const;
|
||||||
|
|
||||||
~File() = default;
|
~File() = default;
|
||||||
|
|
||||||
|
|||||||
@@ -6,55 +6,15 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_SYSTEM_SYSTEMASSERTHANDLER_HPP
|
#ifndef BIGFOOT_SYSTEM_SYSTEMASSERTHANDLER_HPP
|
||||||
#define BIGFOOT_SYSTEM_SYSTEMASSERTHANDLER_HPP
|
#define BIGFOOT_SYSTEM_SYSTEMASSERTHANDLER_HPP
|
||||||
#include <Utils/Assert.hpp>
|
|
||||||
|
|
||||||
#include <System/SystemLogger_generated.hpp>
|
#include <System/SystemLogger_generated.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#include <Utils/Assert/AssertHandler.hpp>
|
||||||
#include <EASTL/utility.h>
|
|
||||||
|
|
||||||
#include <format>
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
#include <source_location>
|
|
||||||
#include <string_view>
|
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
class SystemAssertHandler
|
using SystemAssertHandler = AssertHandler<SYSTEM_LOGGER>;
|
||||||
{
|
|
||||||
public:
|
|
||||||
SystemAssertHandler() = delete;
|
|
||||||
|
|
||||||
SystemAssertHandler(const SystemAssertHandler& p_handler) = delete;
|
|
||||||
SystemAssertHandler(SystemAssertHandler&& p_handler) = delete;
|
|
||||||
|
|
||||||
~SystemAssertHandler() = delete;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle an assertion.
|
|
||||||
*
|
|
||||||
* \param p_location Location of the assertion.
|
|
||||||
* \param p_stacktrace The stack trace
|
|
||||||
* \param p_format Format string for the assertion message.
|
|
||||||
* \param p_args Arguments for the format string.
|
|
||||||
*/
|
|
||||||
template<typename... ARGS>
|
|
||||||
static void Handle(const std::source_location& p_location,
|
|
||||||
const std::string_view p_stacktrace,
|
|
||||||
std::format_string<ARGS...> p_format,
|
|
||||||
ARGS&&... p_args)
|
|
||||||
{
|
|
||||||
BIGFOOT_LOG_FATAL(SYSTEM_LOGGER,
|
|
||||||
"Assert: {} (File:{}, Line:{}, Function:{}\n{}",
|
|
||||||
std::format(p_format, eastl::forward<ARGS>(p_args)...),
|
|
||||||
p_location.file_name(),
|
|
||||||
p_location.line(),
|
|
||||||
p_location.function_name(),
|
|
||||||
p_stacktrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemAssertHandler& operator=(const SystemAssertHandler& p_handler) = delete;
|
|
||||||
SystemAssertHandler& operator=(SystemAssertHandler&& p_handler) = delete;
|
|
||||||
};
|
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
|
#ifndef BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
|
||||||
#define BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
|
#define BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
|
||||||
#include <System/Log/Log.hpp>
|
#include <Utils/Log/LogMacros.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
native_include "System/Time/Time.hpp";
|
||||||
|
|
||||||
|
namespace Flat.Bigfoot;
|
||||||
|
|
||||||
|
struct Time (native_type: "::Bigfoot::Time")
|
||||||
|
{
|
||||||
|
epoch:ulong;
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file Time.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date December 2025
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_SYSTEM_TIME_TIME_HPP
|
||||||
|
#define BIGFOOT_SYSTEM_TIME_TIME_HPP
|
||||||
|
#include <chrono>
|
||||||
|
#include <compare>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class Time
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Time(const std::uint64_t p_epoch);
|
||||||
|
|
||||||
|
Time(const Time& p_time) = default;
|
||||||
|
Time(Time&& p_time) = default;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetYear() const;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetMonth() const;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetDay() const;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetHour() const;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetMinute() const;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetSecond() const;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint32_t GetMicrosecond() const;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
std::uint64_t GetEpoch() const;
|
||||||
|
|
||||||
|
~Time() = default;
|
||||||
|
|
||||||
|
Time& operator=(const Time& p_time) = default;
|
||||||
|
Time& operator=(Time&& p_time) = default;
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
auto operator<=>(const Time& p_other) const
|
||||||
|
{
|
||||||
|
return m_epoch <=> p_other.m_epoch;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
static Time Now();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::uint64_t m_epoch;
|
||||||
|
std::tm m_timeInfo;
|
||||||
|
std::chrono::microseconds m_microseconds;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
namespace Flat
|
||||||
|
{
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
struct Time;
|
||||||
|
}
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
namespace flatbuffers
|
||||||
|
{
|
||||||
|
Flat::Bigfoot::Time Pack(const Bigfoot::Time& p_time);
|
||||||
|
Bigfoot::Time UnPack(const Flat::Bigfoot::Time& p_flatTime);
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_TIME_FLAT_BIGFOOT_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_TIME_FLAT_BIGFOOT_H_
|
||||||
|
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
|
#include "System/Time/Time.hpp"
|
||||||
|
|
||||||
|
#include "EASTL/unique_ptr.h"
|
||||||
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
struct Time;
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *TimeTypeTable();
|
||||||
|
|
||||||
|
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Time FLATBUFFERS_FINAL_CLASS {
|
||||||
|
private:
|
||||||
|
uint64_t epoch_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return TimeTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.Time";
|
||||||
|
}
|
||||||
|
Time()
|
||||||
|
: epoch_(0) {
|
||||||
|
}
|
||||||
|
Time(uint64_t _epoch)
|
||||||
|
: epoch_(::flatbuffers::EndianScalar(_epoch)) {
|
||||||
|
}
|
||||||
|
uint64_t epoch() const {
|
||||||
|
return ::flatbuffers::EndianScalar(epoch_);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
FLATBUFFERS_STRUCT_END(Time, 8);
|
||||||
|
|
||||||
|
struct Time::Traits {
|
||||||
|
using type = Time;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *TimeTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_ULONG, 0, -1 }
|
||||||
|
};
|
||||||
|
static const int64_t values[] = { 0, 8 };
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_STRUCT, 1, type_codes, nullptr, nullptr, values, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_TIME_FLAT_BIGFOOT_H_
|
||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace flatbuffers
|
namespace flatbuffers
|
||||||
{
|
{
|
||||||
Bigfoot::Flat::UUID Pack(const Bigfoot::UUID& p_uuid);
|
Flat::Bigfoot::UUID Pack(const Bigfoot::UUID& p_uuid);
|
||||||
Bigfoot::UUID UnPack(const Bigfoot::Flat::UUID& p_flatUUID);
|
Bigfoot::UUID UnPack(const Flat::Bigfoot::UUID& p_flatUUID);
|
||||||
} // namespace flatbuffers
|
} // namespace flatbuffers
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
native_include "System/UUID/FlatUUID.hpp";
|
native_include "System/UUID/UUID.hpp";
|
||||||
|
|
||||||
namespace Bigfoot.Flat;
|
namespace Flat.Bigfoot;
|
||||||
|
|
||||||
struct UUID (native_type: "::Bigfoot::UUID")
|
struct UUID (native_type: "::Bigfoot::UUID")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,9 +4,8 @@
|
|||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date October 2025
|
* \date October 2025
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_SYSTEM_UUID_HPP
|
#ifndef BIGFOOT_SYSTEM_UUID_UUID_HPP
|
||||||
#define BIGFOOT_SYSTEM_UUID_HPP
|
#define BIGFOOT_SYSTEM_UUID_UUID_HPP
|
||||||
|
|
||||||
#include <uuid.h>
|
#include <uuid.h>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
@@ -16,6 +15,11 @@ class UUID
|
|||||||
public:
|
public:
|
||||||
static constexpr std::uint32_t UUID_BYTE_SIZE = 16;
|
static constexpr std::uint32_t UUID_BYTE_SIZE = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* Will default initialize an UUID to a valid value
|
||||||
|
*
|
||||||
|
*/
|
||||||
UUID();
|
UUID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,19 +39,31 @@ class UUID
|
|||||||
UUID(const UUID& p_uuid) = default;
|
UUID(const UUID& p_uuid) = default;
|
||||||
UUID(UUID&& p_uuid) noexcept = 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;
|
~UUID() = default;
|
||||||
|
|
||||||
operator std::span<const std::byte, UUID_BYTE_SIZE>() const;
|
|
||||||
operator std::string() const;
|
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
|
|
||||||
UUID& operator=(const UUID& p_uuid) = default;
|
UUID& operator=(const UUID& p_uuid) = default;
|
||||||
UUID& operator=(UUID&& p_uuid) noexcept = default;
|
UUID& operator=(UUID&& p_uuid) noexcept = default;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool operator==(const UUID& p_uuid) const = default;
|
bool operator==(const UUID& p_uuid) const;
|
||||||
[[nodiscard]]
|
|
||||||
bool operator!=(const UUID& p_uuid) const = default;
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool operator<(const UUID& p_uuid) const;
|
bool operator<(const UUID& p_uuid) const;
|
||||||
|
|
||||||
@@ -114,10 +130,12 @@ struct std::formatter<Bigfoot::UUID, char>
|
|||||||
template<typename FormatContext>
|
template<typename FormatContext>
|
||||||
auto format(const Bigfoot::UUID& p_uuid, FormatContext& ctx) const
|
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());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
#include <quill/DeferredFormatCodec.h>
|
#include <quill/DeferredFormatCodec.h>
|
||||||
|
|
||||||
@@ -131,7 +149,7 @@ struct fmtquill::formatter<Bigfoot::UUID>
|
|||||||
|
|
||||||
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
|
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());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -141,4 +159,22 @@ struct quill::Codec<Bigfoot::UUID>: quill::DeferredFormatCodec<Bigfoot::UUID>
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
namespace Flat
|
||||||
|
{
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
struct UUID;
|
||||||
|
}
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
namespace flatbuffers
|
||||||
|
{
|
||||||
|
Flat::Bigfoot::UUID Pack(const Bigfoot::UUID& p_uuid);
|
||||||
|
Bigfoot::UUID UnPack(const Flat::Bigfoot::UUID& p_flatUUID);
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// automatically generated by the FlatBuffers compiler, do not modify
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
#ifndef FLATBUFFERS_GENERATED_UUID_BIGFOOT_FLAT_H_
|
#ifndef FLATBUFFERS_GENERATED_UUID_FLAT_BIGFOOT_H_
|
||||||
#define FLATBUFFERS_GENERATED_UUID_BIGFOOT_FLAT_H_
|
#define FLATBUFFERS_GENERATED_UUID_FLAT_BIGFOOT_H_
|
||||||
|
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
@@ -12,14 +12,22 @@ static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
|||||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
FLATBUFFERS_VERSION_REVISION == 19,
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
"Non-compatible flatbuffers version included");
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
#include "System/UUID/FlatUUID.hpp"
|
#include "System/UUID/UUID.hpp"
|
||||||
|
|
||||||
#include "EASTL/unique_ptr.h"
|
#include "EASTL/unique_ptr.h"
|
||||||
#include "EASTL/string.h"
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
namespace Bigfoot {
|
|
||||||
namespace Flat {
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
struct UUID;
|
struct UUID;
|
||||||
|
|
||||||
@@ -35,7 +43,7 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) UUID FLATBUFFERS_FINAL_CLASS {
|
|||||||
return UUIDTypeTable();
|
return UUIDTypeTable();
|
||||||
}
|
}
|
||||||
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
return "Bigfoot.Flat.UUID";
|
return "Flat.Bigfoot.UUID";
|
||||||
}
|
}
|
||||||
UUID()
|
UUID()
|
||||||
: bytes_() {
|
: bytes_() {
|
||||||
@@ -59,16 +67,13 @@ inline const ::flatbuffers::TypeTable *UUIDTypeTable() {
|
|||||||
};
|
};
|
||||||
static const int16_t array_sizes[] = { 16, };
|
static const int16_t array_sizes[] = { 16, };
|
||||||
static const int64_t values[] = { 0, 16 };
|
static const int64_t values[] = { 0, 16 };
|
||||||
static const char * const names[] = {
|
|
||||||
"bytes"
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
::flatbuffers::ST_STRUCT, 1, type_codes, nullptr, array_sizes, values, names
|
::flatbuffers::ST_STRUCT, 1, type_codes, nullptr, array_sizes, values, nullptr
|
||||||
};
|
};
|
||||||
return &tt;
|
return &tt;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Flat
|
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
#endif // FLATBUFFERS_GENERATED_UUID_BIGFOOT_FLAT_H_
|
#endif // FLATBUFFERS_GENERATED_UUID_FLAT_BIGFOOT_H_
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date December 2025
|
* \date December 2025
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include <System/Time.hpp>
|
#include <System/Time/Time.hpp>
|
||||||
|
|
||||||
#include <System/SystemAssertHandler.hpp>
|
#include <System/SystemAssertHandler.hpp>
|
||||||
|
#include <System/Time/Time_generated.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -54,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;
|
return m_timeInfo.tm_year + 1900;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
std::uint32_t Time::Month() const
|
std::uint32_t Time::GetMonth() const
|
||||||
{
|
{
|
||||||
return m_timeInfo.tm_mon + 1;
|
return m_timeInfo.tm_mon + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
std::uint32_t Time::Day() const
|
std::uint32_t Time::GetDay() const
|
||||||
{
|
{
|
||||||
return m_timeInfo.tm_mday;
|
return m_timeInfo.tm_mday;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
std::uint32_t Time::Hour() const
|
std::uint32_t Time::GetHour() const
|
||||||
{
|
{
|
||||||
return m_timeInfo.tm_hour;
|
return m_timeInfo.tm_hour;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
std::uint32_t Time::Minute() const
|
std::uint32_t Time::GetMinute() const
|
||||||
{
|
{
|
||||||
return m_timeInfo.tm_min;
|
return m_timeInfo.tm_min;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
std::uint32_t Time::Second() const
|
std::uint32_t Time::GetSecond() const
|
||||||
{
|
{
|
||||||
return m_timeInfo.tm_sec;
|
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());
|
return static_cast<std::uint32_t>(m_microseconds.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
std::uint64_t Time::Epoch() const
|
std::uint64_t Time::GetEpoch() const
|
||||||
{
|
{
|
||||||
return m_epoch;
|
return m_epoch;
|
||||||
}
|
}
|
||||||
@@ -119,3 +120,20 @@ Time Time::Now()
|
|||||||
return Time {epochInMicroSeconds};
|
return Time {epochInMicroSeconds};
|
||||||
}
|
}
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
namespace flatbuffers
|
||||||
|
{
|
||||||
|
Flat::Bigfoot::Time Pack(const Bigfoot::Time& p_time)
|
||||||
|
{
|
||||||
|
return Flat::Bigfoot::Time {p_time.GetEpoch()};
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
Bigfoot::Time UnPack(const Flat::Bigfoot::Time& p_flatTime)
|
||||||
|
{
|
||||||
|
return Bigfoot::Time {p_flatTime.epoch()};
|
||||||
|
}
|
||||||
|
} // namespace flatbuffers
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/*********************************************************************
|
|
||||||
* \file FlatUUID.cpp
|
|
||||||
*
|
|
||||||
* \author Romain BOULLARD
|
|
||||||
* \date December 2025
|
|
||||||
*********************************************************************/
|
|
||||||
#include <System/UUID/FlatUUID.hpp>
|
|
||||||
|
|
||||||
namespace flatbuffers
|
|
||||||
{
|
|
||||||
Bigfoot::Flat::UUID Pack(const Bigfoot::UUID& p_uuid)
|
|
||||||
{
|
|
||||||
const std::span<const std::byte, Bigfoot::UUID::UUID_BYTE_SIZE> bytes = p_uuid;
|
|
||||||
return Bigfoot::Flat::UUID {
|
|
||||||
std::span<const std::uint8_t, Bigfoot::UUID::UUID_BYTE_SIZE> {reinterpret_cast<const std::uint8_t*>(bytes.data()),
|
|
||||||
bytes.size()}};
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
Bigfoot::UUID UnPack(const Bigfoot::Flat::UUID& p_flatUUID)
|
|
||||||
{
|
|
||||||
const std::span<const std::uint8_t, Bigfoot::UUID::UUID_BYTE_SIZE> bytesView {p_flatUUID.bytes()->data(),
|
|
||||||
p_flatUUID.bytes()->size()};
|
|
||||||
return Bigfoot::UUID {std::as_bytes(bytesView)};
|
|
||||||
}
|
|
||||||
} // namespace flatbuffers
|
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include <System/UUID/UUID.hpp>
|
#include <System/UUID/UUID.hpp>
|
||||||
|
|
||||||
|
#include <System/UUID/UUID_generated.hpp>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
UUID UUID::NULL_UUID {"00000000-0000-0000-0000-000000000000"};
|
UUID UUID::NULL_UUID {"00000000-0000-0000-0000-000000000000"};
|
||||||
@@ -41,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();
|
return m_uuid.as_bytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
UUID::operator std::string() const
|
std::string UUID::ToString() const
|
||||||
{
|
{
|
||||||
return uuids::to_string(m_uuid);
|
return uuids::to_string(m_uuid);
|
||||||
}
|
}
|
||||||
@@ -60,6 +62,11 @@ UUID::operator bool() const
|
|||||||
return *this != NULL_UUID;
|
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
|
bool UUID::operator<(const UUID& p_uuid) const
|
||||||
@@ -85,3 +92,25 @@ uuids::uuid_random_generator UUID::GetUUIDGenerator()
|
|||||||
return uuids::uuid_random_generator {ms_randomGenerator};
|
return uuids::uuid_random_generator {ms_randomGenerator};
|
||||||
}
|
}
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
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.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()}};
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
Bigfoot::UUID UnPack(const Flat::Bigfoot::UUID& p_flatUUID)
|
||||||
|
{
|
||||||
|
const std::span<const std::uint8_t, Bigfoot::UUID::UUID_BYTE_SIZE> bytesView {p_flatUUID.bytes()->data(),
|
||||||
|
p_flatUUID.bytes()->size()};
|
||||||
|
return Bigfoot::UUID {std::as_bytes(bytesView)};
|
||||||
|
}
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
|||||||
project(${PackageName})
|
project(${PackageName})
|
||||||
|
|
||||||
set(PublicDependencies
|
set(PublicDependencies
|
||||||
$<$<CONFIG:Debug,RelWithDebInfo>:cpptrace::cpptrace>)
|
$<$<CONFIG:Debug,RelWithDebInfo>:quill::quill>
|
||||||
|
$<IF:$<BOOL:${ASAN}>,mimalloc-asan,mimalloc-static>
|
||||||
|
unordered_dense::unordered_dense
|
||||||
|
EASTL::EASTL
|
||||||
|
flatbuffers::flatbuffers
|
||||||
|
rapidhash::rapidhash)
|
||||||
set(PrivateDependencies)
|
set(PrivateDependencies)
|
||||||
set(BigfootPublicDependencies)
|
set(BigfootPublicDependencies)
|
||||||
set(BigfootPrivateDependencies)
|
set(BigfootPrivateDependencies)
|
||||||
@@ -12,4 +17,12 @@ bigfoot_create_package_lib(
|
|||||||
"${PrivateLibraries}"
|
"${PrivateLibraries}"
|
||||||
"${BigfootPublicDependencies}"
|
"${BigfootPublicDependencies}"
|
||||||
"${BigfootPrivateDependencies}"
|
"${BigfootPrivateDependencies}"
|
||||||
"")
|
"")
|
||||||
|
set_source_files_properties(../Utils/MimallocImpl.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||||
|
|
||||||
|
bigfoot_create_logger()
|
||||||
|
|
||||||
|
target_compile_definitions(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
$<$<CONFIG:Debug,RelWithDebInfo>:QUILL_NO_EXCEPTIONS>
|
||||||
|
$<$<CONFIG:Debug,RelWithDebInfo>:QUILL_DISABLE_NON_PREFIXED_MACROS>)
|
||||||
+15
-23
@@ -6,11 +6,10 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_UTILS_ASSERT_HPP
|
#ifndef BIGFOOT_UTILS_ASSERT_HPP
|
||||||
#define BIGFOOT_UTILS_ASSERT_HPP
|
#define BIGFOOT_UTILS_ASSERT_HPP
|
||||||
|
#include <Utils/Log/LogMacros.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
#include <cpptrace/cpptrace.hpp>
|
|
||||||
|
|
||||||
#include <source_location>
|
#include <source_location>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -18,16 +17,27 @@
|
|||||||
#include <csignal>
|
#include <csignal>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BIGFOOT_FLUSH_LOG \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (Bigfoot::Singleton<Bigfoot::Log>::HasInstance()) \
|
||||||
|
{ \
|
||||||
|
Bigfoot::Singleton<Bigfoot::Log>::GetInstance().Flush(); \
|
||||||
|
} \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
#if defined BIGFOOT_WINDOWS
|
#if defined BIGFOOT_WINDOWS
|
||||||
#define BREAK \
|
#define BREAK \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
BIGFOOT_FLUSH_LOG; \
|
||||||
__debugbreak(); \
|
__debugbreak(); \
|
||||||
} while (false)
|
} while (false)
|
||||||
#elif defined BIGFOOT_LINUX
|
#elif defined BIGFOOT_LINUX
|
||||||
#define BREAK \
|
#define BREAK \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
|
BIGFOOT_FLUSH_LOG; \
|
||||||
std::raise(SIGTRAP); \
|
std::raise(SIGTRAP); \
|
||||||
} while (false)
|
} while (false)
|
||||||
#endif
|
#endif
|
||||||
@@ -38,13 +48,7 @@
|
|||||||
constexpr std::source_location location = std::source_location::current(); \
|
constexpr std::source_location location = std::source_location::current(); \
|
||||||
if (!(p_assert)) [[unlikely]] \
|
if (!(p_assert)) [[unlikely]] \
|
||||||
{ \
|
{ \
|
||||||
constexpr auto stacktrace = []() -> std::string \
|
HANDLER::Handle(location, p_message __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
{ \
|
|
||||||
const cpptrace::stacktrace stacktrace = cpptrace::generate_trace(); \
|
|
||||||
return stacktrace.to_string(); \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
HANDLER::Handle(location, stacktrace(), p_message __VA_OPT__(, ) __VA_ARGS__); \
|
|
||||||
BREAK; \
|
BREAK; \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
@@ -55,13 +59,7 @@
|
|||||||
constexpr std::source_location location = std::source_location::current(); \
|
constexpr std::source_location location = std::source_location::current(); \
|
||||||
if (!(p_assert)) [[unlikely]] \
|
if (!(p_assert)) [[unlikely]] \
|
||||||
{ \
|
{ \
|
||||||
constexpr auto stacktrace = []() -> std::string \
|
HANDLER::Handle(location, p_message __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
{ \
|
|
||||||
const cpptrace::stacktrace stacktrace = cpptrace::generate_trace(); \
|
|
||||||
return stacktrace.to_string(); \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
HANDLER::Handle(location, stacktrace(), p_message __VA_OPT__(, ) __VA_ARGS__); \
|
|
||||||
BREAK; \
|
BREAK; \
|
||||||
} \
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
@@ -72,13 +70,7 @@
|
|||||||
constexpr std::source_location location = std::source_location::current(); \
|
constexpr std::source_location location = std::source_location::current(); \
|
||||||
if (!(p_assert)) [[unlikely]] \
|
if (!(p_assert)) [[unlikely]] \
|
||||||
{ \
|
{ \
|
||||||
constexpr auto stacktrace = []() -> std::string \
|
HANDLER::Handle(location, p_message __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
{ \
|
|
||||||
const cpptrace::stacktrace stacktrace = cpptrace::generate_trace(); \
|
|
||||||
return stacktrace.to_string(); \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
HANDLER::Handle(location, stacktrace(), p_message __VA_OPT__(, ) __VA_ARGS__); \
|
|
||||||
BREAK; \
|
BREAK; \
|
||||||
std::abort(); \
|
std::abort(); \
|
||||||
} \
|
} \
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssertHandler.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date August 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_UTILS_ASSERTHANDLER_HPP
|
||||||
|
#define BIGFOOT_UTILS_ASSERTHANDLER_HPP
|
||||||
|
#include <Utils/Assert/Assert.hpp>
|
||||||
|
#include <Utils/Log/Log.hpp>
|
||||||
|
|
||||||
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
#include <source_location>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
template<Log::LoggerInfo& LOGGER>
|
||||||
|
class AssertHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AssertHandler() = delete;
|
||||||
|
|
||||||
|
AssertHandler(const AssertHandler& p_handler) = delete;
|
||||||
|
AssertHandler(AssertHandler&& p_handler) = delete;
|
||||||
|
|
||||||
|
~AssertHandler() = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an assertion.
|
||||||
|
*
|
||||||
|
* \param p_location Location of the assertion.
|
||||||
|
* \param p_format Format string for the assertion message.
|
||||||
|
* \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)
|
||||||
|
{
|
||||||
|
BIGFOOT_LOG_FATAL(LOGGER,
|
||||||
|
"Assert: {} (File:{}, Line:{}, Function:{}\n",
|
||||||
|
std::format(p_format, std::forward<ARGS>(p_args)...),
|
||||||
|
p_location.file_name(),
|
||||||
|
p_location.line(),
|
||||||
|
p_location.function_name());
|
||||||
|
}
|
||||||
|
|
||||||
|
AssertHandler& operator=(const AssertHandler& p_handler) = delete;
|
||||||
|
AssertHandler& operator=(AssertHandler&& p_handler) = delete;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -4,19 +4,19 @@
|
|||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date December 2025
|
* \date December 2025
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_SYSTEM_EASTLFORMATTERS_HPP
|
#ifndef BIGFOOT_UTILS_LOG_EASTLFORMATTERS_HPP
|
||||||
#define BIGFOOT_SYSTEM_EASTLFORMATTERS_HPP
|
#define BIGFOOT_UTILS_LOG_EASTLFORMATTERS_HPP
|
||||||
#include <Utils/TargetMacros.h>
|
#include <Utils/TargetMacros.h>
|
||||||
|
|
||||||
#if defined(BIGFOOT_NOT_OPTIMIZED)
|
#if defined(BIGFOOT_NOT_OPTIMIZED)
|
||||||
#include <quill/DeferredFormatCodec.h>
|
#include <quill/DeferredFormatCodec.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <format>
|
|
||||||
|
|
||||||
#include <EASTL/string.h>
|
#include <EASTL/string.h>
|
||||||
#include <EASTL/string_view.h>
|
#include <EASTL/string_view.h>
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
// STRING
|
// STRING
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file Log.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date October 2025
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_UTILS_LOG_LOG_HPP
|
||||||
|
#define BIGFOOT_UTILS_LOG_LOG_HPP
|
||||||
|
#include <Utils/Log/EASTLFormatters.hpp>
|
||||||
|
|
||||||
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
#include <Utils/Log/Log_generated.hpp>
|
||||||
|
|
||||||
|
#include <EASTL/array.h>
|
||||||
|
|
||||||
|
#ifdef BIGFOOT_WINDOWS
|
||||||
|
#pragma warning(disable: 4702)
|
||||||
|
#endif
|
||||||
|
#include <quill/Backend.h>
|
||||||
|
#include <quill/Frontend.h>
|
||||||
|
#include <quill/LogMacros.h>
|
||||||
|
#include <quill/Logger.h>
|
||||||
|
#include <quill/sinks/ConsoleSink.h>
|
||||||
|
#if defined BIGFOOT_WINDOWS
|
||||||
|
#pragma warning(default: 4702)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class Log
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct LoggerInfo
|
||||||
|
{
|
||||||
|
std::string m_name;
|
||||||
|
Flat::LogLevel m_level;
|
||||||
|
};
|
||||||
|
|
||||||
|
Log();
|
||||||
|
|
||||||
|
Log(const Log& p_logger) = delete;
|
||||||
|
Log(Log&& p_logger) = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a logger.
|
||||||
|
*
|
||||||
|
* \param p_loggerInfo The logger to register
|
||||||
|
*/
|
||||||
|
[[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.
|
||||||
|
*
|
||||||
|
* \param p_loggerInfo The logger to get
|
||||||
|
* \return The logger, nullptr if it does not exist
|
||||||
|
*/
|
||||||
|
[[nodiscard]]
|
||||||
|
quill::Logger* GetLogger(const LoggerInfo& p_loggerInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the loglevel of a Logger.
|
||||||
|
*
|
||||||
|
* \param p_loggerInfo The logger to change
|
||||||
|
* \param p_level The new level
|
||||||
|
*/
|
||||||
|
void ChangeLoggerLogLevel(LoggerInfo& p_loggerInfo, const Flat::LogLevel p_level);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flush all the loggers
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Flush();
|
||||||
|
|
||||||
|
~Log();
|
||||||
|
|
||||||
|
Log& operator=(const Log& p_logger) = delete;
|
||||||
|
Log& operator=(Log&& p_logger) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* Set the LogLevel of a logger
|
||||||
|
*
|
||||||
|
* \param p_loggerInfo The logger to set
|
||||||
|
*/
|
||||||
|
void SetLoggerLevel(const LoggerInfo& p_loggerInfo);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The sinks
|
||||||
|
*/
|
||||||
|
eastl::array<std::shared_ptr<quill::Sink>, 1> m_sinks;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
+18
-96
@@ -1,103 +1,25 @@
|
|||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* \file Log.hpp
|
* \file LogMacros.hpp
|
||||||
*
|
*
|
||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date October 2025
|
* \date May 2026
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_SYSTEM_LOG_HPP
|
#ifndef BIGFOOT_UTILS_LOG_LOGMACROS_HPP
|
||||||
#define BIGFOOT_SYSTEM_LOG_HPP
|
#define BIGFOOT_UTILS_LOG_LOGMACROS_HPP
|
||||||
#include <System/Log/EASTLFormatters.hpp>
|
#include <Utils/Log/Log.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
|
||||||
#include <System/Log/Log_generated.hpp>
|
|
||||||
|
|
||||||
#include <Utils/Singleton.hpp>
|
#include <Utils/Singleton.hpp>
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
#ifdef BIGFOOT_WINDOWS
|
|
||||||
#pragma warning(disable: 4702)
|
|
||||||
#endif
|
|
||||||
#include <quill/Backend.h>
|
|
||||||
#include <quill/Frontend.h>
|
|
||||||
#include <quill/LogMacros.h>
|
|
||||||
#include <quill/Logger.h>
|
|
||||||
#include <quill/sinks/ConsoleSink.h>
|
|
||||||
#if defined BIGFOOT_WINDOWS
|
|
||||||
#pragma warning(default: 4702)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Bigfoot
|
|
||||||
{
|
|
||||||
class Log
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct LoggerInfo
|
|
||||||
{
|
|
||||||
std::string m_name;
|
|
||||||
Flat::LogLevel m_level;
|
|
||||||
};
|
|
||||||
|
|
||||||
Log();
|
|
||||||
|
|
||||||
Log(const Log& p_logger) = delete;
|
|
||||||
Log(Log&& p_logger) = delete;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a logger.
|
|
||||||
*
|
|
||||||
* \param p_loggerInfo The logger to register
|
|
||||||
*/
|
|
||||||
[[nodiscard]]
|
|
||||||
quill::Logger* RegisterLogger(const LoggerInfo& p_loggerInfo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a logger.
|
|
||||||
*
|
|
||||||
* \param p_loggerInfo The logger to get
|
|
||||||
* \return The logger, nullptr if it does not exist
|
|
||||||
*/
|
|
||||||
[[nodiscard]]
|
|
||||||
quill::Logger* GetLogger(const LoggerInfo& p_loggerInfo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes the loglevel of a Logger.
|
|
||||||
*
|
|
||||||
* \param p_loggerInfo The logger to change
|
|
||||||
* \param p_level The new level
|
|
||||||
*/
|
|
||||||
void ChangeLoggerLogLevel(LoggerInfo& p_loggerInfo, const Flat::LogLevel p_level);
|
|
||||||
|
|
||||||
~Log();
|
|
||||||
|
|
||||||
Log& operator=(const Log& p_logger) = delete;
|
|
||||||
Log& operator=(Log&& p_logger) = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* Set the LogLevel of a logger
|
|
||||||
*
|
|
||||||
* \param p_loggerInfo The logger to set
|
|
||||||
*/
|
|
||||||
void SetLoggerLevel(const LoggerInfo& p_loggerInfo);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The sinks
|
|
||||||
*/
|
|
||||||
eastl::array<std::shared_ptr<quill::Sink>, 1> m_sinks;
|
|
||||||
};
|
|
||||||
} // namespace Bigfoot
|
|
||||||
|
|
||||||
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...) \
|
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_DEBUG(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
QUILL_LOG_DEBUG(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -105,13 +27,13 @@ class Log
|
|||||||
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...) \
|
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_TRACE_L3(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
QUILL_LOG_TRACE_L3(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -119,13 +41,13 @@ class Log
|
|||||||
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...) \
|
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_INFO(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
QUILL_LOG_INFO(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -133,13 +55,13 @@ class Log
|
|||||||
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...) \
|
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_WARNING(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
QUILL_LOG_WARNING(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -147,13 +69,13 @@ class Log
|
|||||||
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...) \
|
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_ERROR(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
QUILL_LOG_ERROR(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -161,13 +83,13 @@ class Log
|
|||||||
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...) \
|
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
|
if (::quill::Logger* logger = ::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().GetLogger(loggerName)) \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
QUILL_LOG_CRITICAL(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
|
QUILL_LOG_CRITICAL(::Bigfoot::Singleton<::Bigfoot::Log>::GetInstance().RegisterLogger(loggerName), \
|
||||||
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
+10
-13
@@ -12,9 +12,17 @@ static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
|||||||
FLATBUFFERS_VERSION_MINOR == 12 &&
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
FLATBUFFERS_VERSION_REVISION == 19,
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
"Non-compatible flatbuffers version included");
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
#include "EASTL/unique_ptr.h"
|
#include "EASTL/unique_ptr.h"
|
||||||
#include "EASTL/string.h"
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
namespace Bigfoot {
|
namespace Bigfoot {
|
||||||
namespace Flat {
|
namespace Flat {
|
||||||
@@ -95,11 +103,8 @@ inline const ::flatbuffers::TypeTable *LogSinkTypeTypeTable() {
|
|||||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
Bigfoot::Flat::LogSinkTypeTypeTable
|
Bigfoot::Flat::LogSinkTypeTypeTable
|
||||||
};
|
};
|
||||||
static const char * const names[] = {
|
|
||||||
"Console"
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
::flatbuffers::ST_ENUM, 1, type_codes, type_refs, nullptr, nullptr, names
|
::flatbuffers::ST_ENUM, 1, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
};
|
};
|
||||||
return &tt;
|
return &tt;
|
||||||
}
|
}
|
||||||
@@ -116,16 +121,8 @@ inline const ::flatbuffers::TypeTable *LogLevelTypeTable() {
|
|||||||
static const ::flatbuffers::TypeFunction type_refs[] = {
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
Bigfoot::Flat::LogLevelTypeTable
|
Bigfoot::Flat::LogLevelTypeTable
|
||||||
};
|
};
|
||||||
static const char * const names[] = {
|
|
||||||
"Debug",
|
|
||||||
"Trace",
|
|
||||||
"Info",
|
|
||||||
"Warn",
|
|
||||||
"Error",
|
|
||||||
"Critical"
|
|
||||||
};
|
|
||||||
static const ::flatbuffers::TypeTable tt = {
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
::flatbuffers::ST_ENUM, 6, type_codes, type_refs, nullptr, nullptr, names
|
::flatbuffers::ST_ENUM, 6, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
};
|
};
|
||||||
return &tt;
|
return &tt;
|
||||||
}
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
|
#ifndef BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
|
||||||
#define BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
|
#define BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
|
||||||
#include <System/Log/Log.hpp>
|
#include <Utils/Log/LogMacros.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
+2
-2
@@ -4,8 +4,8 @@
|
|||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date October 2025
|
* \date October 2025
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_CONCAT_PROFILER_HPP
|
#ifndef BIGFOOT_UTILS_PROFILER_HPP
|
||||||
#define BIGFOOT_CONCAT_PROFILER_HPP
|
#define BIGFOOT_UTILS_PROFILER_HPP
|
||||||
|
|
||||||
#ifdef TRACY
|
#ifdef TRACY
|
||||||
#include <tracy/Tracy.hpp>
|
#include <tracy/Tracy.hpp>
|
||||||
@@ -6,11 +6,7 @@
|
|||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_UTILS_SINGLETON_HPP
|
#ifndef BIGFOOT_UTILS_SINGLETON_HPP
|
||||||
#define BIGFOOT_UTILS_SINGLETON_HPP
|
#define BIGFOOT_UTILS_SINGLETON_HPP
|
||||||
|
#include <EASTL/optional.h>
|
||||||
#include <EASTL/array.h>
|
|
||||||
#include <EASTL/bit.h>
|
|
||||||
#include <EASTL/type_traits.h>
|
|
||||||
#include <EASTL/utility.h>
|
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
{
|
{
|
||||||
@@ -30,9 +26,19 @@ class Singleton
|
|||||||
*
|
*
|
||||||
* \return The instance
|
* \return The instance
|
||||||
*/
|
*/
|
||||||
static constexpr TYPE& Instance()
|
static constexpr TYPE& GetInstance()
|
||||||
{
|
{
|
||||||
return *eastl::bit_cast<TYPE*>(ms_instance.data());
|
return ms_instance.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the instance initialized
|
||||||
|
*
|
||||||
|
* \return True if initialized, false otherwise
|
||||||
|
*/
|
||||||
|
static constexpr bool HasInstance()
|
||||||
|
{
|
||||||
|
return ms_instance.has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Lifetime
|
class Lifetime
|
||||||
@@ -43,11 +49,10 @@ class Singleton
|
|||||||
*
|
*
|
||||||
* \param p_args Arguments for the singleton
|
* \param p_args Arguments for the singleton
|
||||||
*/
|
*/
|
||||||
template<typename... ARGS,
|
template<typename... ARGS>
|
||||||
typename = eastl::enable_if_t<!(eastl::is_same_v<Lifetime, eastl::decay_t<ARGS>> || ...)>>
|
|
||||||
explicit Lifetime(ARGS&&... p_args)
|
explicit Lifetime(ARGS&&... p_args)
|
||||||
{
|
{
|
||||||
Initialize(eastl::forward<ARGS>(p_args)...);
|
Initialize(std::forward<ARGS>(p_args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
Lifetime(const Lifetime& p_lifetime) = delete;
|
Lifetime(const Lifetime& p_lifetime) = delete;
|
||||||
@@ -58,15 +63,11 @@ class Singleton
|
|||||||
Finalize();
|
Finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
Lifetime& operator=(const Lifetime& p_lifetime) = delete;
|
Lifetime& operator=(const Lifetime& p_lifetime) = delete;
|
||||||
[[nodiscard]]
|
Lifetime& operator=(Lifetime&& p_lifetime) noexcept = delete;
|
||||||
Lifetime& operator=(Lifetime&& p_lifetime) = delete;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
Singleton& operator=(const Singleton& p_singleton) = delete;
|
Singleton& operator=(const Singleton& p_singleton) = delete;
|
||||||
[[nodiscard]]
|
|
||||||
Singleton& operator=(Singleton&& p_singleton) = delete;
|
Singleton& operator=(Singleton&& p_singleton) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -78,9 +79,7 @@ class Singleton
|
|||||||
template<typename... ARGS>
|
template<typename... ARGS>
|
||||||
static void Initialize(ARGS&&... p_args)
|
static void Initialize(ARGS&&... p_args)
|
||||||
{
|
{
|
||||||
new (ms_instance.data()) TYPE(eastl::forward<ARGS>(p_args)...);
|
ms_instance.emplace(std::forward<ARGS>(p_args)...);
|
||||||
|
|
||||||
ms_initialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,20 +88,13 @@ class Singleton
|
|||||||
*/
|
*/
|
||||||
static void Finalize()
|
static void Finalize()
|
||||||
{
|
{
|
||||||
eastl::bit_cast<TYPE*>(ms_instance.data())->~TYPE();
|
ms_instance.reset();
|
||||||
|
|
||||||
ms_initialized = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The singleton.
|
* The singleton.
|
||||||
*/
|
*/
|
||||||
alignas(alignof(TYPE)) inline static eastl::array<std::byte, sizeof(TYPE)> ms_instance;
|
inline static eastl::optional<TYPE> ms_instance;
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the singleton initialized?
|
|
||||||
*/
|
|
||||||
inline static bool ms_initialized = false;
|
|
||||||
};
|
};
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date December 2025
|
* \date December 2025
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_UTILS_TAGGEDTYPE_H
|
#ifndef BIGFOOT_UTILS_TAGGEDTYPE_HPP
|
||||||
#define BIGFOOT_UTILS_TAGGEDTYPE_H
|
#define BIGFOOT_UTILS_TAGGEDTYPE_HPP
|
||||||
|
|
||||||
#include <compare>
|
#include <compare>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,14 @@
|
|||||||
#ifndef BIGFOOT_UTILS_TARGETMACROS_H
|
#ifndef BIGFOOT_UTILS_TARGETMACROS_H
|
||||||
#define BIGFOOT_UTILS_TARGETMACROS_H
|
#define BIGFOOT_UTILS_TARGETMACROS_H
|
||||||
|
|
||||||
|
#if defined BIGFOOT_WINDOWS
|
||||||
|
#define BIGFOOT_WINDOWS_OR_LINUX(p_windows, p_linux) p_windows
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined BIGFOOT_LINUX
|
||||||
|
#define BIGFOOT_WINDOWS_OR_LINUX(p_windows, p_linux) p_linux
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined BIGFOOT_OPTIMIZED
|
#if defined BIGFOOT_OPTIMIZED
|
||||||
#define BIGFOOT_OPTIMIZED_ONLY(...) __VA_ARGS__
|
#define BIGFOOT_OPTIMIZED_ONLY(...) __VA_ARGS__
|
||||||
#define BIGFOOT_NOT_OPTIMIZED_ONLY(...)
|
#define BIGFOOT_NOT_OPTIMIZED_ONLY(...)
|
||||||
@@ -18,4 +26,16 @@
|
|||||||
#define BIGFOOT_NOT_OPTIMIZED_ONLY(...) __VA_ARGS__
|
#define BIGFOOT_NOT_OPTIMIZED_ONLY(...) __VA_ARGS__
|
||||||
#define BIGFOOT_OPTIMIZED_OR_NOT(p_optimized, p_notOptimized) p_notOptimized
|
#define BIGFOOT_OPTIMIZED_OR_NOT(p_optimized, p_notOptimized) p_notOptimized
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined BIGFOOT_TOOLMODE
|
||||||
|
#define BIGFOOT_TOOLMODE_ONLY(...) __VA_ARGS__
|
||||||
|
#define BIGFOOT_GAME_ONLY(...)
|
||||||
|
#define BIGFOOT_GAME_OR_TOOLMODE(p_game, p_toolmode) p_toolmode
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined BIGFOOT_GAME
|
||||||
|
#define BIGFOOT_TOOLMODE_ONLY(...)
|
||||||
|
#define BIGFOOT_GAME_ONLY(...) __VA_ARGS__
|
||||||
|
#define BIGFOOT_GAME_OR_TOOLMODE(p_game, p_toolmode) p_game
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file UtilsAssertHandler.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date May 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
|
||||||
|
#define BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
|
||||||
|
#include <Utils/Assert/AssertHandler.hpp>
|
||||||
|
#include <Utils/UtilsLogger_generated.hpp>
|
||||||
|
|
||||||
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
using UtilsAssertHandler = AssertHandler<UTILS_LOGGER>;
|
||||||
|
} // namespace Bigfoot
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
+5
-5
@@ -1,12 +1,12 @@
|
|||||||
// AUTO-GENERATED DO NOT TOUCH
|
// AUTO-GENERATED DO NOT TOUCH
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* \file SystemTestsLogger.generated.hpp
|
* \file UtilsLogger.generated.hpp
|
||||||
*
|
*
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#ifndef BIGFOOT_SYSTEMTESTSLOGGER_GENERATED_HPP
|
#ifndef BIGFOOT_UTILSLOGGER_GENERATED_HPP
|
||||||
#define BIGFOOT_SYSTEMTESTSLOGGER_GENERATED_HPP
|
#define BIGFOOT_UTILSLOGGER_GENERATED_HPP
|
||||||
#include <System/Log/Log.hpp>
|
#include <Utils/Log/LogMacros.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ namespace Bigfoot
|
|||||||
/*
|
/*
|
||||||
* Logger
|
* Logger
|
||||||
*/
|
*/
|
||||||
inline Log::LoggerInfo SYSTEMTESTS_LOGGER {"SYSTEMTESTS_LOGGER", Flat::LogLevel::Trace};
|
inline Log::LoggerInfo UTILS_LOGGER {"UTILS_LOGGER", Flat::LogLevel::Trace};
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -53,7 +53,7 @@ class Version
|
|||||||
* \return The major part of the version.
|
* \return The major part of the version.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::uint8_t Major() const
|
constexpr std::uint8_t GetMajor() const
|
||||||
{
|
{
|
||||||
constexpr std::uint32_t mask = 0b00000000111111110000000000000000;
|
constexpr std::uint32_t mask = 0b00000000111111110000000000000000;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ class Version
|
|||||||
* \return The minor part of the version.
|
* \return The minor part of the version.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::uint8_t Minor() const
|
constexpr std::uint8_t GetMinor() const
|
||||||
{
|
{
|
||||||
constexpr std::uint32_t mask = 0b00000000000000001111111100000000;
|
constexpr std::uint32_t mask = 0b00000000000000001111111100000000;
|
||||||
|
|
||||||
@@ -79,54 +79,37 @@ class Version
|
|||||||
* \return The patch part of the version.
|
* \return The patch part of the version.
|
||||||
*/
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::uint8_t Patch() const
|
constexpr std::uint8_t GetPatch() const
|
||||||
{
|
{
|
||||||
constexpr std::uint32_t mask = 0b00000000000000000000000011111111;
|
constexpr std::uint32_t mask = 0b00000000000000000000000011111111;
|
||||||
|
|
||||||
return static_cast<std::uint8_t>(m_combined & mask);
|
return static_cast<std::uint8_t>(m_combined & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the raw Version
|
||||||
|
*
|
||||||
|
* \return the raw version
|
||||||
|
*/
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr operator std::uint32_t() const
|
constexpr std::uint32_t Raw() const
|
||||||
{
|
{
|
||||||
return m_combined;
|
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=(const Version& p_version) = default;
|
||||||
|
|
||||||
constexpr Version& operator=(Version&& p_version) = default;
|
constexpr Version& operator=(Version&& p_version) = default;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr bool operator>(const Version& p_version) const
|
constexpr auto operator<=>(const Version& p_version) const = default;
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@@ -151,7 +134,7 @@ struct std::formatter<Bigfoot::Version>
|
|||||||
template<typename FormatContext>
|
template<typename FormatContext>
|
||||||
auto format(const Bigfoot::Version& p_version, FormatContext& p_context) const
|
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
|
#endif
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date October 2025
|
* \date October 2025
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include <System/Log/Log.hpp>
|
#include <Utils/Log/Log.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
@@ -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)
|
quill::Logger* Log::GetLogger(const LoggerInfo& p_loggerInfo)
|
||||||
{
|
{
|
||||||
return quill::Frontend::get_logger(p_loggerInfo.m_name);
|
return quill::Frontend::get_logger(p_loggerInfo.m_name);
|
||||||
@@ -79,13 +89,23 @@ void Log::SetLoggerLevel(const LoggerInfo& p_loggerInfo)
|
|||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
Log::~Log()
|
void Log::Flush()
|
||||||
{
|
{
|
||||||
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
|
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
|
||||||
{
|
{
|
||||||
quill::Frontend::remove_logger(logger);
|
logger->flush_log();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
Log::~Log()
|
||||||
|
{
|
||||||
|
Flush();
|
||||||
|
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
|
||||||
|
{
|
||||||
|
quill::Frontend::remove_logger_blocking(logger);
|
||||||
|
}
|
||||||
quill::Backend::stop();
|
quill::Backend::stop();
|
||||||
}
|
}
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date October 2025
|
* \date October 2025
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include <System/Profiler.hpp>
|
#include <Utils/Profiler.hpp>
|
||||||
|
|
||||||
#if defined BIGFOOT_WINDOWS
|
#if defined BIGFOOT_WINDOWS
|
||||||
#pragma comment(linker, "/include:mi_version")
|
#pragma comment(linker, "/include:mi_version")
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
namespace Bigfoot
|
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
|
} // namespace Bigfoot
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/System)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Misc)
|
||||||
|
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Utils)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Utils)
|
||||||
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/System)
|
||||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Engine)
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Engine)
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file Asset.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date August 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/Asset/Asset.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetA.hpp>
|
||||||
|
#include <AssetsForTesting/Asset/AssetB.hpp>
|
||||||
|
#include <AssetsForTesting/Asset/AssetC.hpp>
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class AssetFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Packs a header and an asset the same way Asset<ASSET>::Pack() does. Pack() is intentionally
|
||||||
|
* BIGFOOT_TOOLMODE-only: game code must never be able to build asset buffers.
|
||||||
|
*/
|
||||||
|
template<class ASSET>
|
||||||
|
static eastl::vector<std::byte> PackAssetBuffer(const ::Flat::Bigfoot::AssetHeaderT& p_header,
|
||||||
|
const typename ASSET::FLAT_ASSET::NativeTableType& p_asset)
|
||||||
|
{
|
||||||
|
flatbuffers::FlatBufferBuilder innerAssetFbb;
|
||||||
|
innerAssetFbb.Finish(ASSET::FLAT_ASSET::Pack(innerAssetFbb, &p_asset));
|
||||||
|
|
||||||
|
flatbuffers::FlatBufferBuilder assetFbb;
|
||||||
|
const auto header = ::Flat::Bigfoot::AssetHeader::Pack(assetFbb, &p_header);
|
||||||
|
const auto innerAsset = assetFbb.CreateVector(innerAssetFbb.GetBufferPointer(), innerAssetFbb.GetSize());
|
||||||
|
assetFbb.Finish(::Flat::Bigfoot::CreateAsset(assetFbb, header, innerAsset));
|
||||||
|
|
||||||
|
return eastl::vector<std::byte> {std::bit_cast<std::byte*>(assetFbb.GetBufferPointer()),
|
||||||
|
std::bit_cast<std::byte*>(assetFbb.GetBufferPointer() + assetFbb.GetSize())};
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetA m_asset;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetFixture, Constructor_ShouldInitializeHeaderTypeIdAndTypeName)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(m_asset.GetHeader().type_id, AssetA::GetTypeID());
|
||||||
|
EXPECT_EQ(m_asset.GetHeader().type_name, eastl::string {AssetA::GetTypeName()});
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetFixture, SetName_ShouldSetTheName)
|
||||||
|
{
|
||||||
|
m_asset.SetName("MyAsset");
|
||||||
|
|
||||||
|
EXPECT_STREQ(m_asset.GetHeader().name.c_str(), "MyAsset");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetFixture, SetVersion_ShouldSetTheVersion)
|
||||||
|
{
|
||||||
|
m_asset.SetVersion(5);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_asset.GetHeader().version, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetFixture, GetAsset_ShouldReturnAMutableReferenceToTheUnderlyingAsset)
|
||||||
|
{
|
||||||
|
m_asset.GetAsset().health = 10;
|
||||||
|
|
||||||
|
EXPECT_EQ(m_asset.GetAsset().health, 10);
|
||||||
|
EXPECT_EQ(std::as_const(m_asset).GetAsset().health, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetFixture, GetTypeID_ShouldBeStableAcrossCalls)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(AssetA::GetTypeID(), AssetA::GetTypeID());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetFixture, GetTypeID_ShouldBeDifferentForDifferentAssetTypes)
|
||||||
|
{
|
||||||
|
EXPECT_NE(AssetA::GetTypeID(), AssetB::GetTypeID());
|
||||||
|
EXPECT_NE(AssetA::GetTypeID(), AssetC::GetTypeID());
|
||||||
|
EXPECT_NE(AssetB::GetTypeID(), AssetC::GetTypeID());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetFixture, GetTypeName_ShouldReturnTheFlatbufferFullyQualifiedName)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(AssetA::GetTypeName(), eastl::string_view {AssetA::FLAT_ASSET::GetFullyQualifiedName()});
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetFixture, Unpack_ShouldPopulateTheHeaderAndTheAsset)
|
||||||
|
{
|
||||||
|
::Flat::Bigfoot::AssetHeaderT header;
|
||||||
|
header.name = "MyAsset";
|
||||||
|
header.version = 3;
|
||||||
|
header.type_id = AssetA::GetTypeID();
|
||||||
|
header.type_name = eastl::string {AssetA::GetTypeName()};
|
||||||
|
|
||||||
|
AssetA::FLAT_ASSET::NativeTableType inner;
|
||||||
|
inner.health = 42;
|
||||||
|
inner.mana = 7;
|
||||||
|
|
||||||
|
m_asset.Unpack(PackAssetBuffer<AssetA>(header, inner));
|
||||||
|
|
||||||
|
EXPECT_EQ(m_asset.GetHeader().uuid, header.uuid);
|
||||||
|
EXPECT_STREQ(m_asset.GetHeader().name.c_str(), header.name.c_str());
|
||||||
|
EXPECT_EQ(m_asset.GetHeader().version, header.version);
|
||||||
|
EXPECT_EQ(m_asset.GetHeader().type_id, header.type_id);
|
||||||
|
EXPECT_STREQ(m_asset.GetHeader().type_name.c_str(), header.type_name.c_str());
|
||||||
|
EXPECT_EQ(m_asset.GetAsset().health, 42);
|
||||||
|
EXPECT_EQ(m_asset.GetAsset().mana, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
#ifdef BIGFOOT_TOOLMODE
|
||||||
|
TEST_F(AssetFixture, PackThenUnpack_ShouldRoundTripTheHeaderAndTheAsset)
|
||||||
|
{
|
||||||
|
m_asset.SetName("MyAsset");
|
||||||
|
m_asset.SetVersion(3);
|
||||||
|
m_asset.GetAsset().health = 42;
|
||||||
|
m_asset.GetAsset().mana = 7;
|
||||||
|
|
||||||
|
AssetA unpacked;
|
||||||
|
unpacked.Unpack(m_asset.Pack());
|
||||||
|
|
||||||
|
EXPECT_EQ(unpacked.GetHeader().uuid, m_asset.GetHeader().uuid);
|
||||||
|
EXPECT_STREQ(unpacked.GetHeader().name.c_str(), m_asset.GetHeader().name.c_str());
|
||||||
|
EXPECT_EQ(unpacked.GetHeader().version, m_asset.GetHeader().version);
|
||||||
|
EXPECT_EQ(unpacked.GetHeader().type_id, m_asset.GetHeader().type_id);
|
||||||
|
EXPECT_STREQ(unpacked.GetHeader().type_name.c_str(), m_asset.GetHeader().type_name.c_str());
|
||||||
|
EXPECT_EQ(unpacked.GetAsset().health, m_asset.GetAsset().health);
|
||||||
|
EXPECT_EQ(unpacked.GetAsset().mana, m_asset.GetAsset().mana);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetContainer.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/Asset/AssetContainer.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetA.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class ContainerHandleFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void SetUp() override
|
||||||
|
{
|
||||||
|
std::ignore = m_containerA.Insert(m_asset);
|
||||||
|
m_handle = m_containerA.AcquireContainerHandle(m_asset.GetHeader().uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetA m_asset;
|
||||||
|
AssetContainer<AssetA> m_containerA;
|
||||||
|
|
||||||
|
ContainerHandle* m_handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(ContainerHandleFixture, GetAsset_ShouldReturnTheAsset)
|
||||||
|
{
|
||||||
|
EXPECT_NE(m_handle->GetAsset(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(ContainerHandleFixture, GetAsset_ShouldReturnNullptrIfTheAssetHasBeenRemoved)
|
||||||
|
{
|
||||||
|
m_containerA.Remove(m_asset.GetHeader().uuid);
|
||||||
|
EXPECT_EQ(m_handle->GetAsset(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(ContainerHandleFixture, IncrementHardRefCount_ShouldIncrementTheHardRefCount)
|
||||||
|
{
|
||||||
|
const std::uint32_t original = m_handle->GetHardRefCount();
|
||||||
|
m_handle->IncrementHardRefCount();
|
||||||
|
EXPECT_EQ(original + 1, m_handle->GetHardRefCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(ContainerHandleFixture, IncrementSoftRefCount_ShouldIncrementTheSoftRefCount)
|
||||||
|
{
|
||||||
|
const std::uint32_t original = m_handle->GetSoftRefCount();
|
||||||
|
m_handle->IncrementSoftRefCount();
|
||||||
|
EXPECT_EQ(original + 1, m_handle->GetSoftRefCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(ContainerHandleFixture, DecrementHardRefCount_ShouldDecrementTheHardRefCount)
|
||||||
|
{
|
||||||
|
m_handle->IncrementHardRefCount();
|
||||||
|
|
||||||
|
const std::uint32_t original = m_handle->GetHardRefCount();
|
||||||
|
m_handle->DecrementHardRefCount();
|
||||||
|
EXPECT_EQ(original - 1, m_handle->GetHardRefCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(ContainerHandleFixture, DecrementSoftRefCount_ShouldDecrementTheSoftRefCount)
|
||||||
|
{
|
||||||
|
m_handle->IncrementSoftRefCount();
|
||||||
|
|
||||||
|
const std::uint32_t original = m_handle->GetSoftRefCount();
|
||||||
|
m_handle->DecrementSoftRefCount();
|
||||||
|
EXPECT_EQ(original - 1, m_handle->GetSoftRefCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
class AssetContainerFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
AssetContainer<AssetA> m_containerA;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Has_ShouldReturnTrueIfTheContainerHasTheAsset)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
std::ignore = m_containerA.Insert(asset1);
|
||||||
|
EXPECT_TRUE(m_containerA.Has(asset1.GetHeader().uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Has_ShouldReturnFalseIfTheContainerDoesNotHaveTheAsset)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
EXPECT_FALSE(m_containerA.Has(asset1.GetHeader().uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, AcquireHandle_ShouldReturnTheAssociatedContainerHandle)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
std::ignore = m_containerA.Insert(asset1);
|
||||||
|
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(asset1.GetHeader().uuid);
|
||||||
|
EXPECT_EQ(static_cast<const AssetA*>(handle->GetAsset())->GetHeader().uuid, asset1.GetHeader().uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, AcquireHandle_ShouldCreateTheAssociatedContainerHandleIfItDoesNotExists)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(asset1.GetHeader().uuid);
|
||||||
|
EXPECT_EQ(handle->GetAsset(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Insert_ShouldReturnValidAndUniqueSlotKeyOnInsert)
|
||||||
|
{
|
||||||
|
AssetA asset1;
|
||||||
|
const SlotMapKey slotKey = m_containerA.Insert(asset1);
|
||||||
|
EXPECT_TRUE(slotKey.Valid());
|
||||||
|
EXPECT_NE(slotKey, m_containerA.Insert());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Insert_ShouldReturnTheSameSlotKeyInCaseOfDuplicatedUUID)
|
||||||
|
{
|
||||||
|
AssetA asset;
|
||||||
|
const SlotMapKey slotKey = m_containerA.Insert(asset);
|
||||||
|
EXPECT_EQ(slotKey, m_containerA.Insert(asset));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Get_ShouldReturnTheAssetWithTheSlotKey)
|
||||||
|
{
|
||||||
|
AssetA asset;
|
||||||
|
const SlotMapKey slotKey = m_containerA.Insert(asset);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_containerA.Get(slotKey)->GetHeader().uuid, asset.GetHeader().uuid);
|
||||||
|
EXPECT_EQ(std::as_const(m_containerA).Get(slotKey)->GetHeader().uuid, asset.GetHeader().uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Get_ShouldReturnNullptrIfSlotKeyNotInContainer)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(m_containerA.Get(SlotMapKey<> {1, 0}), nullptr);
|
||||||
|
EXPECT_EQ(std::as_const(m_containerA).Get(SlotMapKey<> {1, 0}), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetContainerFixture, Remove_ShouldRemoveTheAsset)
|
||||||
|
{
|
||||||
|
AssetA asset;
|
||||||
|
const SlotMapKey slotKey = m_containerA.Insert(asset);
|
||||||
|
|
||||||
|
m_containerA.Remove(asset.GetHeader().uuid);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_containerA.Get(slotKey), nullptr);
|
||||||
|
EXPECT_FALSE(m_containerA.Has(asset.GetHeader().uuid));
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetLibrary.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/Asset/AssetLibrary.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetA.hpp>
|
||||||
|
#include <AssetsForTesting/Asset/AssetB.hpp>
|
||||||
|
#include <AssetsForTesting/Asset/AssetC.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class AssetLibraryFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
AssetContainer<AssetA> m_containerA;
|
||||||
|
AssetContainer<AssetB> m_containerB;
|
||||||
|
AssetContainer<AssetC> m_containerC;
|
||||||
|
|
||||||
|
AssetLibrary m_library;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, Insert_ShouldReturnTrueOnSuccess)
|
||||||
|
{
|
||||||
|
EXPECT_TRUE(m_library.Insert(&m_containerA));
|
||||||
|
EXPECT_TRUE(m_library.Insert(&m_containerB));
|
||||||
|
EXPECT_TRUE(m_library.Insert(&m_containerC));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, Insert_ShouldReturnFalseOnDuplicate)
|
||||||
|
{
|
||||||
|
std::ignore = m_library.Insert(&m_containerA);
|
||||||
|
EXPECT_FALSE(m_library.Insert(&m_containerA));
|
||||||
|
|
||||||
|
AssetContainer<AssetA> m_containerAA;
|
||||||
|
EXPECT_FALSE(m_library.Insert(&m_containerAA));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, GetAssetContainer_ShouldReturnTheAssetContainerIfAvailable)
|
||||||
|
{
|
||||||
|
std::ignore = m_library.Insert(&m_containerA);
|
||||||
|
std::ignore = m_library.Insert(&m_containerB);
|
||||||
|
std::ignore = m_library.Insert(&m_containerC);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetA>()), &m_containerA);
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetB>()), &m_containerB);
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetC>()), &m_containerC);
|
||||||
|
|
||||||
|
EXPECT_EQ(std::as_const(m_library).GetAssetContainer(GetAssetTypeID<AssetA>()), &m_containerA);
|
||||||
|
EXPECT_EQ(std::as_const(m_library).GetAssetContainer(GetAssetTypeID<AssetB>()), &m_containerB);
|
||||||
|
EXPECT_EQ(std::as_const(m_library).GetAssetContainer(GetAssetTypeID<AssetC>()), &m_containerC);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, GetAssetContainer_ShouldReturnNullptrIfTheContainerDoesNotExist)
|
||||||
|
{
|
||||||
|
std::ignore = m_library.Insert(&m_containerB);
|
||||||
|
|
||||||
|
EXPECT_EQ(m_library.GetAssetContainer(GetAssetTypeID<AssetA>()), nullptr);
|
||||||
|
EXPECT_EQ(std::as_const(m_library).GetAssetContainer(GetAssetTypeID<AssetA>()), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, SetActiveAssetLibrary_ShouldSetTheActiveAssetLibraryToTheGivenLibrary)
|
||||||
|
{
|
||||||
|
SetActiveAssetLibrary(&m_library);
|
||||||
|
EXPECT_EQ(g_activeAssetLibrary, &m_library);
|
||||||
|
SetActiveAssetLibrary(&g_assetLibrary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(AssetLibraryFixture, ScopedActiveAssetLibrary_ShouldChangeTheActiveAssetLibraryInAScopedWay)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(g_activeAssetLibrary, &g_assetLibrary);
|
||||||
|
{
|
||||||
|
ScopedActiveAssetLibrary activeAssetLibraryScoped {&m_library};
|
||||||
|
EXPECT_EQ(g_activeAssetLibrary, &m_library);
|
||||||
|
}
|
||||||
|
EXPECT_EQ(g_activeAssetLibrary, &g_assetLibrary);
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -0,0 +1,479 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetLibrary.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Engine/Asset/AssetLibrary.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetA.hpp>
|
||||||
|
#include <AssetsForTesting/Asset/AssetB.hpp>
|
||||||
|
#include <AssetsForTesting/Asset/AssetC.hpp>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class HardReferenceFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void SetUp() override
|
||||||
|
{
|
||||||
|
SetActiveAssetLibrary(&m_library);
|
||||||
|
|
||||||
|
std::ignore = m_library.Insert(&m_containerA);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override
|
||||||
|
{
|
||||||
|
SetActiveAssetLibrary(&g_assetLibrary);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetContainer<AssetA> m_containerA;
|
||||||
|
|
||||||
|
AssetLibrary m_library;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, GetUUID_ShouldReturnTheUUID)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
HardReference<AssetA> hardRef {uuid};
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef.GetUUID(), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, Get_ShouldReturnTheAsset)
|
||||||
|
{
|
||||||
|
const auto key = m_containerA.Insert();
|
||||||
|
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRef {uuid};
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef.Get(), m_containerA.Get(key));
|
||||||
|
EXPECT_EQ(std::as_const(hardRef).Get(), std::as_const(m_containerA).Get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, Get_ShouldReturnNullptrIfTheAssetDoesNotExist)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
HardReference<AssetA> hardRef {uuid};
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef.Get(), nullptr);
|
||||||
|
EXPECT_EQ(std::as_const(hardRef).Get(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, Get_ShouldReturnNullptrAfterTheAssetIsRemovedFromTheContainer)
|
||||||
|
{
|
||||||
|
const auto key = m_containerA.Insert();
|
||||||
|
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRef {uuid};
|
||||||
|
|
||||||
|
m_containerA.Remove(uuid);
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef.Get(), nullptr);
|
||||||
|
EXPECT_EQ(std::as_const(hardRef).Get(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, ShouldTouchTheHardRefCountOfTheHandle)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
HardReference<AssetA> hardRef1 {uuid};
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
{
|
||||||
|
HardReference<AssetA> hardRef2 {uuid};
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 2);
|
||||||
|
}
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, CopyConstructor_ShouldIncrementTheHardRefCountAndCopyTheState)
|
||||||
|
{
|
||||||
|
const auto key = m_containerA.Insert();
|
||||||
|
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRef1 {uuid};
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRef2 {hardRef1};
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 2);
|
||||||
|
EXPECT_EQ(hardRef2.GetUUID(), uuid);
|
||||||
|
EXPECT_EQ(hardRef2.Get(), m_containerA.Get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, MoveConstructor_ShouldTransferTheStateWithoutChangingTheHardRefCount)
|
||||||
|
{
|
||||||
|
const auto key = m_containerA.Insert();
|
||||||
|
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRef1 {uuid};
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRef2 {std::move(hardRef1)};
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
EXPECT_EQ(hardRef2.GetUUID(), uuid);
|
||||||
|
EXPECT_EQ(hardRef2.Get(), m_containerA.Get(key));
|
||||||
|
EXPECT_EQ(hardRef1.GetUUID(), UUID::NULL_UUID);
|
||||||
|
EXPECT_EQ(hardRef1.Get(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, CopyAssignment_ShouldReleaseThePreviousHandleAndAcquireTheNewOne)
|
||||||
|
{
|
||||||
|
UUID uuidA;
|
||||||
|
UUID uuidB;
|
||||||
|
const ContainerHandle* handleA = m_containerA.AcquireContainerHandle(uuidA);
|
||||||
|
const ContainerHandle* handleB = m_containerA.AcquireContainerHandle(uuidB);
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRefA {uuidA};
|
||||||
|
HardReference<AssetA> hardRefB {uuidB};
|
||||||
|
EXPECT_EQ(handleA->GetHardRefCount(), 1);
|
||||||
|
EXPECT_EQ(handleB->GetHardRefCount(), 1);
|
||||||
|
|
||||||
|
hardRefB = hardRefA;
|
||||||
|
|
||||||
|
EXPECT_EQ(handleA->GetHardRefCount(), 2);
|
||||||
|
EXPECT_EQ(handleB->GetHardRefCount(), 0);
|
||||||
|
EXPECT_EQ(hardRefB.GetUUID(), uuidA);
|
||||||
|
EXPECT_EQ(hardRefB.Get(), hardRefA.Get());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, CopyAssignment_SelfAssignment_ShouldNotChangeTheHardRefCount)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRef {uuid};
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
|
||||||
|
HardReference<AssetA>* selfPtr = &hardRef;
|
||||||
|
hardRef = *selfPtr;
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
EXPECT_EQ(hardRef.GetUUID(), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, MoveAssignment_ShouldReleaseThePreviousHandleAndTransferTheNewOne)
|
||||||
|
{
|
||||||
|
UUID uuidA;
|
||||||
|
UUID uuidB;
|
||||||
|
const ContainerHandle* handleA = m_containerA.AcquireContainerHandle(uuidA);
|
||||||
|
const ContainerHandle* handleB = m_containerA.AcquireContainerHandle(uuidB);
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRefA {uuidA};
|
||||||
|
HardReference<AssetA> hardRefB {uuidB};
|
||||||
|
EXPECT_EQ(handleA->GetHardRefCount(), 1);
|
||||||
|
EXPECT_EQ(handleB->GetHardRefCount(), 1);
|
||||||
|
|
||||||
|
hardRefB = std::move(hardRefA);
|
||||||
|
|
||||||
|
EXPECT_EQ(handleA->GetHardRefCount(), 1);
|
||||||
|
EXPECT_EQ(handleB->GetHardRefCount(), 0);
|
||||||
|
EXPECT_EQ(hardRefB.GetUUID(), uuidA);
|
||||||
|
EXPECT_EQ(hardRefA.GetUUID(), UUID::NULL_UUID);
|
||||||
|
EXPECT_EQ(hardRefA.Get(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, MoveAssignment_SelfAssignment_ShouldNotChangeTheHardRefCount)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
HardReference<AssetA> hardRef {uuid};
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
|
||||||
|
HardReference<AssetA>* selfPtr = &hardRef;
|
||||||
|
hardRef = std::move(*selfPtr);
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetHardRefCount(), 1);
|
||||||
|
EXPECT_EQ(hardRef.GetUUID(), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, EqualityOperator_ShouldReturnTrueForReferencesWithTheSameUUID)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
HardReference<AssetA> hardRef1 {uuid};
|
||||||
|
HardReference<AssetA> hardRef2 {uuid};
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef1, hardRef2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(HardReferenceFixture, EqualityOperator_ShouldReturnFalseForReferencesWithDifferentUUIDs)
|
||||||
|
{
|
||||||
|
UUID uuid1;
|
||||||
|
UUID uuid2;
|
||||||
|
HardReference<AssetA> hardRef1 {uuid1};
|
||||||
|
HardReference<AssetA> hardRef2 {uuid2};
|
||||||
|
|
||||||
|
EXPECT_NE(hardRef1, hardRef2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
class SoftReferenceFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void SetUp() override
|
||||||
|
{
|
||||||
|
SetActiveAssetLibrary(&m_library);
|
||||||
|
|
||||||
|
std::ignore = m_library.Insert(&m_containerA);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override
|
||||||
|
{
|
||||||
|
SetActiveAssetLibrary(&g_assetLibrary);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetContainer<AssetA> m_containerA;
|
||||||
|
|
||||||
|
AssetLibrary m_library;
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, GetUUID_ShouldReturnTheUUID)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
SoftReference<AssetA> hardRef {uuid};
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef.GetUUID(), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, Get_ShouldReturnTheAsset)
|
||||||
|
{
|
||||||
|
const auto key = m_containerA.Insert();
|
||||||
|
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||||
|
|
||||||
|
SoftReference<AssetA> hardRef {uuid};
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef.Get(), m_containerA.Get(key));
|
||||||
|
EXPECT_EQ(std::as_const(hardRef).Get(), std::as_const(m_containerA).Get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, Get_ShouldReturnNullptrIfTheAssetDoesNotExist)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
SoftReference<AssetA> hardRef {uuid};
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef.Get(), nullptr);
|
||||||
|
EXPECT_EQ(std::as_const(hardRef).Get(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, Get_ShouldReturnNullptrAfterTheAssetIsRemovedFromTheContainer)
|
||||||
|
{
|
||||||
|
const auto key = m_containerA.Insert();
|
||||||
|
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||||
|
|
||||||
|
SoftReference<AssetA> hardRef {uuid};
|
||||||
|
|
||||||
|
m_containerA.Remove(uuid);
|
||||||
|
|
||||||
|
EXPECT_EQ(hardRef.Get(), nullptr);
|
||||||
|
EXPECT_EQ(std::as_const(hardRef).Get(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, ShouldTouchTheSoftRefCountOfTheHandle)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
SoftReference<AssetA> softRef1 {uuid};
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
{
|
||||||
|
SoftReference<AssetA> softRef2 {uuid};
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 2);
|
||||||
|
}
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, CopyConstructor_ShouldIncrementTheSoftRefCountAndCopyTheState)
|
||||||
|
{
|
||||||
|
const auto key = m_containerA.Insert();
|
||||||
|
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
SoftReference<AssetA> softRef1 {uuid};
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
|
||||||
|
SoftReference<AssetA> softRef2 {softRef1};
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 2);
|
||||||
|
EXPECT_EQ(softRef2.GetUUID(), uuid);
|
||||||
|
EXPECT_EQ(softRef2.Get(), m_containerA.Get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, MoveConstructor_ShouldTransferTheStateWithoutChangingTheSoftRefCount)
|
||||||
|
{
|
||||||
|
const auto key = m_containerA.Insert();
|
||||||
|
const UUID uuid = m_containerA.Get(key)->GetHeader().uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
SoftReference<AssetA> softRef1 {uuid};
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
|
||||||
|
SoftReference<AssetA> softRef2 {std::move(softRef1)};
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
EXPECT_EQ(softRef2.GetUUID(), uuid);
|
||||||
|
EXPECT_EQ(softRef2.Get(), m_containerA.Get(key));
|
||||||
|
EXPECT_EQ(softRef1.GetUUID(), UUID::NULL_UUID);
|
||||||
|
EXPECT_EQ(softRef1.Get(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, CopyAssignment_ShouldReleaseThePreviousHandleAndAcquireTheNewOne)
|
||||||
|
{
|
||||||
|
UUID uuidA;
|
||||||
|
UUID uuidB;
|
||||||
|
const ContainerHandle* handleA = m_containerA.AcquireContainerHandle(uuidA);
|
||||||
|
const ContainerHandle* handleB = m_containerA.AcquireContainerHandle(uuidB);
|
||||||
|
|
||||||
|
SoftReference<AssetA> softRefA {uuidA};
|
||||||
|
SoftReference<AssetA> softRefB {uuidB};
|
||||||
|
EXPECT_EQ(handleA->GetSoftRefCount(), 1);
|
||||||
|
EXPECT_EQ(handleB->GetSoftRefCount(), 1);
|
||||||
|
|
||||||
|
softRefB = softRefA;
|
||||||
|
|
||||||
|
EXPECT_EQ(handleA->GetSoftRefCount(), 2);
|
||||||
|
EXPECT_EQ(handleB->GetSoftRefCount(), 0);
|
||||||
|
EXPECT_EQ(softRefB.GetUUID(), uuidA);
|
||||||
|
EXPECT_EQ(softRefB.Get(), softRefA.Get());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, CopyAssignment_SelfAssignment_ShouldNotChangeTheSoftRefCount)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
SoftReference<AssetA> softRef {uuid};
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
|
||||||
|
SoftReference<AssetA>* selfPtr = &softRef;
|
||||||
|
softRef = *selfPtr;
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
EXPECT_EQ(softRef.GetUUID(), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, MoveAssignment_ShouldReleaseThePreviousHandleAndTransferTheNewOne)
|
||||||
|
{
|
||||||
|
UUID uuidA;
|
||||||
|
UUID uuidB;
|
||||||
|
const ContainerHandle* handleA = m_containerA.AcquireContainerHandle(uuidA);
|
||||||
|
const ContainerHandle* handleB = m_containerA.AcquireContainerHandle(uuidB);
|
||||||
|
|
||||||
|
SoftReference<AssetA> softRefA {uuidA};
|
||||||
|
SoftReference<AssetA> softRefB {uuidB};
|
||||||
|
EXPECT_EQ(handleA->GetSoftRefCount(), 1);
|
||||||
|
EXPECT_EQ(handleB->GetSoftRefCount(), 1);
|
||||||
|
|
||||||
|
softRefB = std::move(softRefA);
|
||||||
|
|
||||||
|
EXPECT_EQ(handleA->GetSoftRefCount(), 1);
|
||||||
|
EXPECT_EQ(handleB->GetSoftRefCount(), 0);
|
||||||
|
EXPECT_EQ(softRefB.GetUUID(), uuidA);
|
||||||
|
EXPECT_EQ(softRefA.GetUUID(), UUID::NULL_UUID);
|
||||||
|
EXPECT_EQ(softRefA.Get(), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, MoveAssignment_SelfAssignment_ShouldNotChangeTheSoftRefCount)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
const ContainerHandle* handle = m_containerA.AcquireContainerHandle(uuid);
|
||||||
|
|
||||||
|
SoftReference<AssetA> softRef {uuid};
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
|
||||||
|
SoftReference<AssetA>* selfPtr = &softRef;
|
||||||
|
softRef = std::move(*selfPtr);
|
||||||
|
|
||||||
|
EXPECT_EQ(handle->GetSoftRefCount(), 1);
|
||||||
|
EXPECT_EQ(softRef.GetUUID(), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, EqualityOperator_ShouldReturnTrueForReferencesWithTheSameUUID)
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
SoftReference<AssetA> softRef1 {uuid};
|
||||||
|
SoftReference<AssetA> softRef2 {uuid};
|
||||||
|
|
||||||
|
EXPECT_EQ(softRef1, softRef2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(SoftReferenceFixture, EqualityOperator_ShouldReturnFalseForReferencesWithDifferentUUIDs)
|
||||||
|
{
|
||||||
|
UUID uuid1;
|
||||||
|
UUID uuid2;
|
||||||
|
SoftReference<AssetA> softRef1 {uuid1};
|
||||||
|
SoftReference<AssetA> softRef2 {uuid2};
|
||||||
|
|
||||||
|
EXPECT_NE(softRef1, softRef2);
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
project(${PackageName}Tests)
|
project(${PackageName}Tests)
|
||||||
|
|
||||||
|
set(Dependencies)
|
||||||
set(BigfootDependencies
|
set(BigfootDependencies
|
||||||
Engine
|
AssetsForTesting)
|
||||||
System
|
|
||||||
Utils)
|
|
||||||
|
|
||||||
bigfoot_create_bigfile("Tests/Bigfoot")
|
|
||||||
|
|
||||||
bigfoot_create_package_tests(
|
bigfoot_create_package_tests(
|
||||||
""
|
"${Dependencies}"
|
||||||
"${BigfootDependencies}")
|
"${BigfootDependencies}"
|
||||||
|
"")
|
||||||
|
|
||||||
bigfoot_setup_dependencies("Tests/Bigfoot")
|
bigfoot_create_bigfile("Tests/Bigfoot")
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
// to delete when an actual test is in EngineTests
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetA.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <AssetsForTesting/Asset/AssetA.hpp>
|
||||||
|
|
||||||
|
#include <Engine/Asset/AssetHelper.hpp>
|
||||||
|
|
||||||
|
BIGFOOT_ASSET(AssetA, ::Bigfoot::AssetA)
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetB.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <AssetsForTesting/Asset/AssetB.hpp>
|
||||||
|
|
||||||
|
#include <Engine/Asset/AssetHelper.hpp>
|
||||||
|
|
||||||
|
BIGFOOT_ASSET(AssetB, ::Bigfoot::AssetB)
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetC.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date July 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#include <AssetsForTesting/Asset/AssetC.hpp>
|
||||||
|
|
||||||
|
#include <Engine/Asset/AssetHelper.hpp>
|
||||||
|
|
||||||
|
BIGFOOT_ASSET(AssetC, ::Bigfoot::AssetC)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
|
project(${PackageName})
|
||||||
|
|
||||||
|
set(PublicDependencies)
|
||||||
|
set(PrivateDependencies)
|
||||||
|
set(BigfootPublicDependencies)
|
||||||
|
set(BigfootPrivateDependencies
|
||||||
|
Engine)
|
||||||
|
|
||||||
|
bigfoot_create_package_tests_helper_lib(
|
||||||
|
"${PublicDependencies}"
|
||||||
|
"${PrivateDependencies}"
|
||||||
|
"${BigfootPublicDependencies}"
|
||||||
|
"${BigfootPrivateDependencies}"
|
||||||
|
"")
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
include "Engine/Asset/Reference.fbs";
|
||||||
|
|
||||||
|
namespace Flat.Bigfoot;
|
||||||
|
|
||||||
|
table AssetA
|
||||||
|
{
|
||||||
|
health: uint = 0;
|
||||||
|
mana: uint = 0;
|
||||||
|
|
||||||
|
ref_a: SoftReference (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
||||||
|
}
|
||||||
|
|
||||||
|
root_type AssetA;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetA.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date April 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ASSETSFORTESTING_ASSET_ASSETA_HPP
|
||||||
|
#define BIGFOOT_ASSETSFORTESTING_ASSET_ASSETA_HPP
|
||||||
|
#include <Engine/Asset/Asset.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetA_generated.hpp>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
struct AssetATraits
|
||||||
|
{
|
||||||
|
using FLAT = ::Flat::Bigfoot::AssetA;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AssetA: public Asset<AssetATraits>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AssetA() = default;
|
||||||
|
|
||||||
|
AssetA(const AssetA& p_asset) = default;
|
||||||
|
AssetA(AssetA&& p_asset) = default;
|
||||||
|
|
||||||
|
~AssetA() = default;
|
||||||
|
|
||||||
|
AssetA& operator=(const AssetA& p_asset) = default;
|
||||||
|
AssetA& operator=(AssetA&& p_asset) = default;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif
|
||||||
+251
@@ -0,0 +1,251 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_ASSETA_FLAT_BIGFOOT_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_ASSETA_FLAT_BIGFOOT_H_
|
||||||
|
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
|
#include "System/UUID/UUID.hpp"
|
||||||
|
#include "Engine/Asset/Reference.hpp"
|
||||||
|
#include "Engine/Asset/Reference_generated.hpp"
|
||||||
|
|
||||||
|
#include "EASTL/unique_ptr.h"
|
||||||
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
struct AssetA;
|
||||||
|
struct AssetABuilder;
|
||||||
|
struct AssetAT;
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
namespace Bigfoot {
|
||||||
|
class AssetA;
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
Flat::Bigfoot::SoftReference PackSoftReferenceAssetA(const ::Bigfoot::SoftReference<::Bigfoot::AssetA>& p_asset);
|
||||||
|
::Bigfoot::SoftReference<::Bigfoot::AssetA> UnPackSoftReferenceAssetA(const Flat::Bigfoot::SoftReference& p_asset);
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetATypeTable();
|
||||||
|
|
||||||
|
struct AssetAT : public ::flatbuffers::NativeTable {
|
||||||
|
typedef AssetA TableType;
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetAT";
|
||||||
|
}
|
||||||
|
uint32_t health = 0;
|
||||||
|
uint32_t mana = 0;
|
||||||
|
::Bigfoot::SoftReference<::Bigfoot::AssetA> ref_a{};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetA FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef AssetAT NativeTableType;
|
||||||
|
typedef AssetABuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetATypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetA";
|
||||||
|
}
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_HEALTH = 4,
|
||||||
|
VT_MANA = 6,
|
||||||
|
VT_REF_A = 8
|
||||||
|
};
|
||||||
|
uint32_t health() const {
|
||||||
|
return GetField<uint32_t>(VT_HEALTH, 0);
|
||||||
|
}
|
||||||
|
uint32_t mana() const {
|
||||||
|
return GetField<uint32_t>(VT_MANA, 0);
|
||||||
|
}
|
||||||
|
const Flat::Bigfoot::SoftReference *ref_a() const {
|
||||||
|
return GetStruct<const Flat::Bigfoot::SoftReference *>(VT_REF_A);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<uint32_t>(verifier, VT_HEALTH, 4) &&
|
||||||
|
VerifyField<uint32_t>(verifier, VT_MANA, 4) &&
|
||||||
|
VerifyField<Flat::Bigfoot::SoftReference>(verifier, VT_REF_A, 1) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
AssetAT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
void UnPackTo(AssetAT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
static ::flatbuffers::Offset<AssetA> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetAT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetABuilder {
|
||||||
|
typedef AssetA Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_health(uint32_t health) {
|
||||||
|
fbb_.AddElement<uint32_t>(AssetA::VT_HEALTH, health, 0);
|
||||||
|
}
|
||||||
|
void add_mana(uint32_t mana) {
|
||||||
|
fbb_.AddElement<uint32_t>(AssetA::VT_MANA, mana, 0);
|
||||||
|
}
|
||||||
|
void add_ref_a(const Flat::Bigfoot::SoftReference *ref_a) {
|
||||||
|
fbb_.AddStruct(AssetA::VT_REF_A, ref_a);
|
||||||
|
}
|
||||||
|
explicit AssetABuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<AssetA> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<AssetA>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetA> CreateAssetA(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
uint32_t health = 0,
|
||||||
|
uint32_t mana = 0,
|
||||||
|
const Flat::Bigfoot::SoftReference *ref_a = nullptr) {
|
||||||
|
AssetABuilder builder_(_fbb);
|
||||||
|
builder_.add_ref_a(ref_a);
|
||||||
|
builder_.add_mana(mana);
|
||||||
|
builder_.add_health(health);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetA::Traits {
|
||||||
|
using type = AssetA;
|
||||||
|
static auto constexpr Create = CreateAssetA;
|
||||||
|
};
|
||||||
|
|
||||||
|
::flatbuffers::Offset<AssetA> CreateAssetA(::flatbuffers::FlatBufferBuilder &_fbb, const AssetAT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
|
||||||
|
inline AssetAT *AssetA::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
auto _o = std::make_unique<AssetAT>();
|
||||||
|
UnPackTo(_o.get(), _resolver);
|
||||||
|
return _o.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AssetA::UnPackTo(AssetAT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
(void)_o;
|
||||||
|
(void)_resolver;
|
||||||
|
{ auto _e = health(); _o->health = _e; }
|
||||||
|
{ auto _e = mana(); _o->mana = _e; }
|
||||||
|
{ auto _e = ref_a(); if (_e) _o->ref_a = ::flatbuffers::UnPackSoftReferenceAssetA(*_e); }
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetA> CreateAssetA(::flatbuffers::FlatBufferBuilder &_fbb, const AssetAT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
return AssetA::Pack(_fbb, _o, _rehasher);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetA> AssetA::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetAT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
(void)_rehasher;
|
||||||
|
(void)_o;
|
||||||
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const AssetAT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
|
auto _health = _o->health;
|
||||||
|
auto _mana = _o->mana;
|
||||||
|
auto _ref_a = ::flatbuffers::PackSoftReferenceAssetA(_o->ref_a);
|
||||||
|
return Flat::Bigfoot::CreateAssetA(
|
||||||
|
_fbb,
|
||||||
|
_health,
|
||||||
|
_mana,
|
||||||
|
&_ref_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetATypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_UINT, 0, -1 },
|
||||||
|
{ ::flatbuffers::ET_UINT, 0, -1 },
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Flat::Bigfoot::SoftReferenceTypeTable
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_TABLE, 3, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Flat::Bigfoot::AssetA *GetAssetA(const void *buf) {
|
||||||
|
return ::flatbuffers::GetRoot<Flat::Bigfoot::AssetA>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Flat::Bigfoot::AssetA *GetSizePrefixedAssetA(const void *buf) {
|
||||||
|
return ::flatbuffers::GetSizePrefixedRoot<Flat::Bigfoot::AssetA>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifyAssetABuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifyBuffer<Flat::Bigfoot::AssetA>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifySizePrefixedAssetABuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifySizePrefixedBuffer<Flat::Bigfoot::AssetA>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *AssetAExtension() {
|
||||||
|
return "bfbs";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishAssetABuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::AssetA> root) {
|
||||||
|
fbb.Finish(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishSizePrefixedAssetABuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::AssetA> root) {
|
||||||
|
fbb.FinishSizePrefixed(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Flat::Bigfoot::AssetAT> UnPackAssetA(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Flat::Bigfoot::AssetAT>(GetAssetA(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Flat::Bigfoot::AssetAT> UnPackSizePrefixedAssetA(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Flat::Bigfoot::AssetAT>(GetSizePrefixedAssetA(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETA
|
||||||
|
#define FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETA
|
||||||
|
inline Flat::Bigfoot::SoftReference PackSoftReferenceAssetA(const ::Bigfoot::SoftReference<::Bigfoot::AssetA>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
inline ::Bigfoot::SoftReference<::Bigfoot::AssetA> UnPackSoftReferenceAssetA(const Flat::Bigfoot::SoftReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
|
#endif // FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETA
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_ASSETA_FLAT_BIGFOOT_H_
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
include "Engine/Asset/Reference.fbs";
|
||||||
|
|
||||||
|
namespace Flat.Bigfoot;
|
||||||
|
|
||||||
|
table AssetB
|
||||||
|
{
|
||||||
|
ref_a: HardReference (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
||||||
|
refs_a: [SoftReference] (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
||||||
|
}
|
||||||
|
|
||||||
|
root_type AssetB;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetB.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date April 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ASSETSFORTESTING_ASSET_ASSETB_HPP
|
||||||
|
#define BIGFOOT_ASSETSFORTESTING_ASSET_ASSETB_HPP
|
||||||
|
#include <Engine/Asset/Asset.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetB_generated.hpp>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
struct AssetBTraits
|
||||||
|
{
|
||||||
|
using FLAT = ::Flat::Bigfoot::AssetB;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AssetB: public Asset<AssetBTraits>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AssetB() = default;
|
||||||
|
|
||||||
|
AssetB(const AssetB& p_asset) = delete;
|
||||||
|
AssetB(AssetB&& p_asset) = default;
|
||||||
|
|
||||||
|
~AssetB() = default;
|
||||||
|
|
||||||
|
AssetB& operator=(const AssetB& p_asset) = delete;
|
||||||
|
AssetB& operator=(AssetB&& p_asset) = default;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif
|
||||||
+245
@@ -0,0 +1,245 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_ASSETB_FLAT_BIGFOOT_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_ASSETB_FLAT_BIGFOOT_H_
|
||||||
|
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
|
#include "System/UUID/UUID.hpp"
|
||||||
|
#include "Engine/Asset/Reference.hpp"
|
||||||
|
#include "Engine/Asset/Reference_generated.hpp"
|
||||||
|
|
||||||
|
#include "EASTL/unique_ptr.h"
|
||||||
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
struct AssetB;
|
||||||
|
struct AssetBBuilder;
|
||||||
|
struct AssetBT;
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
namespace Bigfoot {
|
||||||
|
class AssetA;
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
Flat::Bigfoot::HardReference PackHardReferenceAssetA(const ::Bigfoot::HardReference<::Bigfoot::AssetA>& p_asset);
|
||||||
|
::Bigfoot::HardReference<::Bigfoot::AssetA> UnPackHardReferenceAssetA(const Flat::Bigfoot::HardReference& p_asset);
|
||||||
|
Flat::Bigfoot::SoftReference PackSoftReferenceAssetA(const ::Bigfoot::SoftReference<::Bigfoot::AssetA>& p_asset);
|
||||||
|
::Bigfoot::SoftReference<::Bigfoot::AssetA> UnPackSoftReferenceAssetA(const Flat::Bigfoot::SoftReference& p_asset);
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetBTypeTable();
|
||||||
|
|
||||||
|
struct AssetBT : public ::flatbuffers::NativeTable {
|
||||||
|
typedef AssetB TableType;
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetBT";
|
||||||
|
}
|
||||||
|
::Bigfoot::HardReference<::Bigfoot::AssetA> ref_a{};
|
||||||
|
eastl::vector<::Bigfoot::SoftReference<::Bigfoot::AssetA>> refs_a{};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetB FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef AssetBT NativeTableType;
|
||||||
|
typedef AssetBBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetBTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetB";
|
||||||
|
}
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_REF_A = 4,
|
||||||
|
VT_REFS_A = 6
|
||||||
|
};
|
||||||
|
const Flat::Bigfoot::HardReference *ref_a() const {
|
||||||
|
return GetStruct<const Flat::Bigfoot::HardReference *>(VT_REF_A);
|
||||||
|
}
|
||||||
|
const ::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *> *refs_a() const {
|
||||||
|
return GetPointer<const ::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *> *>(VT_REFS_A);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<Flat::Bigfoot::HardReference>(verifier, VT_REF_A, 1) &&
|
||||||
|
VerifyOffset(verifier, VT_REFS_A) &&
|
||||||
|
verifier.VerifyVector(refs_a()) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
AssetBT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
void UnPackTo(AssetBT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
static ::flatbuffers::Offset<AssetB> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetBBuilder {
|
||||||
|
typedef AssetB Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_ref_a(const Flat::Bigfoot::HardReference *ref_a) {
|
||||||
|
fbb_.AddStruct(AssetB::VT_REF_A, ref_a);
|
||||||
|
}
|
||||||
|
void add_refs_a(::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *>> refs_a) {
|
||||||
|
fbb_.AddOffset(AssetB::VT_REFS_A, refs_a);
|
||||||
|
}
|
||||||
|
explicit AssetBBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<AssetB> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<AssetB>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetB> CreateAssetB(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
const Flat::Bigfoot::HardReference *ref_a = nullptr,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *>> refs_a = 0) {
|
||||||
|
AssetBBuilder builder_(_fbb);
|
||||||
|
builder_.add_refs_a(refs_a);
|
||||||
|
builder_.add_ref_a(ref_a);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetB::Traits {
|
||||||
|
using type = AssetB;
|
||||||
|
static auto constexpr Create = CreateAssetB;
|
||||||
|
};
|
||||||
|
|
||||||
|
::flatbuffers::Offset<AssetB> CreateAssetB(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
|
||||||
|
inline AssetBT *AssetB::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
auto _o = std::make_unique<AssetBT>();
|
||||||
|
UnPackTo(_o.get(), _resolver);
|
||||||
|
return _o.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AssetB::UnPackTo(AssetBT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
(void)_o;
|
||||||
|
(void)_resolver;
|
||||||
|
{ auto _e = ref_a(); if (_e) _o->ref_a = ::flatbuffers::UnPackHardReferenceAssetA(*_e); }
|
||||||
|
{ auto _e = refs_a(); if (_e) { _o->refs_a.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->refs_a[_i] = ::flatbuffers::UnPackSoftReferenceAssetA(*_e->Get(_i)); } } else { _o->refs_a.resize(0); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetB> CreateAssetB(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
return AssetB::Pack(_fbb, _o, _rehasher);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetB> AssetB::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetBT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
(void)_rehasher;
|
||||||
|
(void)_o;
|
||||||
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const AssetBT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
|
auto _ref_a = ::flatbuffers::PackHardReferenceAssetA(_o->ref_a);
|
||||||
|
auto _refs_a = _fbb.CreateVectorOfNativeStructs<Flat::Bigfoot::SoftReference, ::Bigfoot::SoftReference<::Bigfoot::AssetA>>(_o->refs_a.data(), _o->refs_a.size(), ::flatbuffers::PackSoftReferenceAssetA);
|
||||||
|
return Flat::Bigfoot::CreateAssetB(
|
||||||
|
_fbb,
|
||||||
|
&_ref_a,
|
||||||
|
_refs_a);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetBTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 1, 1 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Flat::Bigfoot::HardReferenceTypeTable,
|
||||||
|
Flat::Bigfoot::SoftReferenceTypeTable
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_TABLE, 2, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Flat::Bigfoot::AssetB *GetAssetB(const void *buf) {
|
||||||
|
return ::flatbuffers::GetRoot<Flat::Bigfoot::AssetB>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Flat::Bigfoot::AssetB *GetSizePrefixedAssetB(const void *buf) {
|
||||||
|
return ::flatbuffers::GetSizePrefixedRoot<Flat::Bigfoot::AssetB>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifyAssetBBuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifyBuffer<Flat::Bigfoot::AssetB>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifySizePrefixedAssetBBuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifySizePrefixedBuffer<Flat::Bigfoot::AssetB>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *AssetBExtension() {
|
||||||
|
return "bfbs";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishAssetBBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::AssetB> root) {
|
||||||
|
fbb.Finish(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishSizePrefixedAssetBBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::AssetB> root) {
|
||||||
|
fbb.FinishSizePrefixed(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Flat::Bigfoot::AssetBT> UnPackAssetB(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Flat::Bigfoot::AssetBT>(GetAssetB(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Flat::Bigfoot::AssetBT> UnPackSizePrefixedAssetB(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Flat::Bigfoot::AssetBT>(GetSizePrefixedAssetB(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETA
|
||||||
|
#define FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETA
|
||||||
|
inline Flat::Bigfoot::HardReference PackHardReferenceAssetA(const ::Bigfoot::HardReference<::Bigfoot::AssetA>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
inline ::Bigfoot::HardReference<::Bigfoot::AssetA> UnPackHardReferenceAssetA(const Flat::Bigfoot::HardReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
|
#endif // FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETA
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETA
|
||||||
|
#define FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETA
|
||||||
|
inline Flat::Bigfoot::SoftReference PackSoftReferenceAssetA(const ::Bigfoot::SoftReference<::Bigfoot::AssetA>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
inline ::Bigfoot::SoftReference<::Bigfoot::AssetA> UnPackSoftReferenceAssetA(const Flat::Bigfoot::SoftReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
|
#endif // FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETA
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_ASSETB_FLAT_BIGFOOT_H_
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
include "Engine/Asset/Reference.fbs";
|
||||||
|
|
||||||
|
namespace Flat.Bigfoot;
|
||||||
|
|
||||||
|
table InnerTable
|
||||||
|
{
|
||||||
|
asset_a_ref: HardReference (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
||||||
|
asset_a_refs: [HardReference] (native_inline, bigfoot_ref: "::Bigfoot::AssetA");
|
||||||
|
}
|
||||||
|
|
||||||
|
table AssetC
|
||||||
|
{
|
||||||
|
inner_table: InnerTable (required);
|
||||||
|
|
||||||
|
asset_b_ref: HardReference (native_inline, bigfoot_ref: "::Bigfoot::AssetB");
|
||||||
|
asset_b_refs: [SoftReference] (native_inline, bigfoot_ref: "::Bigfoot::AssetB");
|
||||||
|
}
|
||||||
|
|
||||||
|
root_type AssetC;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file AssetC.hpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date April 2026
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_ASSETSFORTESTING_ASSET_ASSETC_HPP
|
||||||
|
#define BIGFOOT_ASSETSFORTESTING_ASSET_ASSETC_HPP
|
||||||
|
#include <Engine/Asset/Asset.hpp>
|
||||||
|
|
||||||
|
#include <AssetsForTesting/Asset/AssetC_generated.hpp>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
struct AssetCTraits
|
||||||
|
{
|
||||||
|
using FLAT = ::Flat::Bigfoot::AssetC;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AssetC: public Asset<AssetCTraits>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AssetC() = default;
|
||||||
|
|
||||||
|
AssetC(const AssetC& p_asset) = delete;
|
||||||
|
AssetC(AssetC&& p_asset) = default;
|
||||||
|
|
||||||
|
~AssetC() = default;
|
||||||
|
|
||||||
|
AssetC& operator=(const AssetC& p_asset) = delete;
|
||||||
|
AssetC& operator=(AssetC&& p_asset) = default;
|
||||||
|
};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
#endif
|
||||||
+420
@@ -0,0 +1,420 @@
|
|||||||
|
// automatically generated by the FlatBuffers compiler, do not modify
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef FLATBUFFERS_GENERATED_ASSETC_FLAT_BIGFOOT_H_
|
||||||
|
#define FLATBUFFERS_GENERATED_ASSETC_FLAT_BIGFOOT_H_
|
||||||
|
|
||||||
|
#include "flatbuffers/flatbuffers.h"
|
||||||
|
|
||||||
|
// Ensure the included flatbuffers.h is the same version as when this file was
|
||||||
|
// generated, otherwise it may not be compatible.
|
||||||
|
static_assert(FLATBUFFERS_VERSION_MAJOR == 25 &&
|
||||||
|
FLATBUFFERS_VERSION_MINOR == 12 &&
|
||||||
|
FLATBUFFERS_VERSION_REVISION == 19,
|
||||||
|
"Non-compatible flatbuffers version included");
|
||||||
|
// Ensure the included flatbuffers.h is Bigfoot's fork - stock
|
||||||
|
// flatbuffers (or a differently versioned Bigfoot fork) is not compatible.
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_VERSION
|
||||||
|
#error "This file requires Bigfoot's flatbuffers fork - stock flatbuffers is not compatible"
|
||||||
|
#endif
|
||||||
|
static_assert(FLATBUFFERS_BIGFOOT_VERSION == 1,
|
||||||
|
"Non-compatible Bigfoot flatbuffers fork version included");
|
||||||
|
|
||||||
|
#include "System/UUID/UUID.hpp"
|
||||||
|
#include "Engine/Asset/Reference.hpp"
|
||||||
|
#include "Engine/Asset/Reference_generated.hpp"
|
||||||
|
|
||||||
|
#include "EASTL/unique_ptr.h"
|
||||||
|
#include "EASTL/string.h"
|
||||||
|
#include "EASTL/vector.h"
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
struct InnerTable;
|
||||||
|
struct InnerTableBuilder;
|
||||||
|
struct InnerTableT;
|
||||||
|
|
||||||
|
struct AssetC;
|
||||||
|
struct AssetCBuilder;
|
||||||
|
struct AssetCT;
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
namespace Bigfoot {
|
||||||
|
class AssetA;
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
namespace Bigfoot {
|
||||||
|
class AssetB;
|
||||||
|
} // namespace Bigfoot
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
Flat::Bigfoot::HardReference PackHardReferenceAssetA(const ::Bigfoot::HardReference<::Bigfoot::AssetA>& p_asset);
|
||||||
|
::Bigfoot::HardReference<::Bigfoot::AssetA> UnPackHardReferenceAssetA(const Flat::Bigfoot::HardReference& p_asset);
|
||||||
|
Flat::Bigfoot::HardReference PackHardReferenceAssetB(const ::Bigfoot::HardReference<::Bigfoot::AssetB>& p_asset);
|
||||||
|
::Bigfoot::HardReference<::Bigfoot::AssetB> UnPackHardReferenceAssetB(const Flat::Bigfoot::HardReference& p_asset);
|
||||||
|
Flat::Bigfoot::SoftReference PackSoftReferenceAssetB(const ::Bigfoot::SoftReference<::Bigfoot::AssetB>& p_asset);
|
||||||
|
::Bigfoot::SoftReference<::Bigfoot::AssetB> UnPackSoftReferenceAssetB(const Flat::Bigfoot::SoftReference& p_asset);
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
namespace Flat {
|
||||||
|
namespace Bigfoot {
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *InnerTableTypeTable();
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetCTypeTable();
|
||||||
|
|
||||||
|
struct InnerTableT : public ::flatbuffers::NativeTable {
|
||||||
|
typedef InnerTable TableType;
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.InnerTableT";
|
||||||
|
}
|
||||||
|
::Bigfoot::HardReference<::Bigfoot::AssetA> asset_a_ref{};
|
||||||
|
eastl::vector<::Bigfoot::HardReference<::Bigfoot::AssetA>> asset_a_refs{};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct InnerTable FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef InnerTableT NativeTableType;
|
||||||
|
typedef InnerTableBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return InnerTableTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.InnerTable";
|
||||||
|
}
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_ASSET_A_REF = 4,
|
||||||
|
VT_ASSET_A_REFS = 6
|
||||||
|
};
|
||||||
|
const Flat::Bigfoot::HardReference *asset_a_ref() const {
|
||||||
|
return GetStruct<const Flat::Bigfoot::HardReference *>(VT_ASSET_A_REF);
|
||||||
|
}
|
||||||
|
const ::flatbuffers::Vector<const Flat::Bigfoot::HardReference *> *asset_a_refs() const {
|
||||||
|
return GetPointer<const ::flatbuffers::Vector<const Flat::Bigfoot::HardReference *> *>(VT_ASSET_A_REFS);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyField<Flat::Bigfoot::HardReference>(verifier, VT_ASSET_A_REF, 1) &&
|
||||||
|
VerifyOffset(verifier, VT_ASSET_A_REFS) &&
|
||||||
|
verifier.VerifyVector(asset_a_refs()) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
InnerTableT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
void UnPackTo(InnerTableT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
static ::flatbuffers::Offset<InnerTable> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const InnerTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct InnerTableBuilder {
|
||||||
|
typedef InnerTable Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_asset_a_ref(const Flat::Bigfoot::HardReference *asset_a_ref) {
|
||||||
|
fbb_.AddStruct(InnerTable::VT_ASSET_A_REF, asset_a_ref);
|
||||||
|
}
|
||||||
|
void add_asset_a_refs(::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::HardReference *>> asset_a_refs) {
|
||||||
|
fbb_.AddOffset(InnerTable::VT_ASSET_A_REFS, asset_a_refs);
|
||||||
|
}
|
||||||
|
explicit InnerTableBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<InnerTable> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<InnerTable>(end);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<InnerTable> CreateInnerTable(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
const Flat::Bigfoot::HardReference *asset_a_ref = nullptr,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::HardReference *>> asset_a_refs = 0) {
|
||||||
|
InnerTableBuilder builder_(_fbb);
|
||||||
|
builder_.add_asset_a_refs(asset_a_refs);
|
||||||
|
builder_.add_asset_a_ref(asset_a_ref);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct InnerTable::Traits {
|
||||||
|
using type = InnerTable;
|
||||||
|
static auto constexpr Create = CreateInnerTable;
|
||||||
|
};
|
||||||
|
|
||||||
|
::flatbuffers::Offset<InnerTable> CreateInnerTable(::flatbuffers::FlatBufferBuilder &_fbb, const InnerTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
|
||||||
|
struct AssetCT : public ::flatbuffers::NativeTable {
|
||||||
|
typedef AssetC TableType;
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetCT";
|
||||||
|
}
|
||||||
|
eastl::unique_ptr<Flat::Bigfoot::InnerTableT> inner_table{new Flat::Bigfoot::InnerTableT()};
|
||||||
|
::Bigfoot::HardReference<::Bigfoot::AssetB> asset_b_ref{};
|
||||||
|
eastl::vector<::Bigfoot::SoftReference<::Bigfoot::AssetB>> asset_b_refs{};
|
||||||
|
AssetCT() = default;
|
||||||
|
AssetCT(const AssetCT &o);
|
||||||
|
AssetCT(AssetCT&&) FLATBUFFERS_NOEXCEPT = default;
|
||||||
|
AssetCT &operator=(AssetCT o) FLATBUFFERS_NOEXCEPT;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetC FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||||
|
typedef AssetCT NativeTableType;
|
||||||
|
typedef AssetCBuilder Builder;
|
||||||
|
struct Traits;
|
||||||
|
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
|
||||||
|
return AssetCTypeTable();
|
||||||
|
}
|
||||||
|
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
|
||||||
|
return "Flat.Bigfoot.AssetC";
|
||||||
|
}
|
||||||
|
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||||
|
VT_INNER_TABLE = 4,
|
||||||
|
VT_ASSET_B_REF = 6,
|
||||||
|
VT_ASSET_B_REFS = 8
|
||||||
|
};
|
||||||
|
const Flat::Bigfoot::InnerTable *inner_table() const {
|
||||||
|
return GetPointer<const Flat::Bigfoot::InnerTable *>(VT_INNER_TABLE);
|
||||||
|
}
|
||||||
|
const Flat::Bigfoot::HardReference *asset_b_ref() const {
|
||||||
|
return GetStruct<const Flat::Bigfoot::HardReference *>(VT_ASSET_B_REF);
|
||||||
|
}
|
||||||
|
const ::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *> *asset_b_refs() const {
|
||||||
|
return GetPointer<const ::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *> *>(VT_ASSET_B_REFS);
|
||||||
|
}
|
||||||
|
template <bool B = false>
|
||||||
|
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||||
|
return VerifyTableStart(verifier) &&
|
||||||
|
VerifyOffsetRequired(verifier, VT_INNER_TABLE) &&
|
||||||
|
verifier.VerifyTable(inner_table()) &&
|
||||||
|
VerifyField<Flat::Bigfoot::HardReference>(verifier, VT_ASSET_B_REF, 1) &&
|
||||||
|
VerifyOffset(verifier, VT_ASSET_B_REFS) &&
|
||||||
|
verifier.VerifyVector(asset_b_refs()) &&
|
||||||
|
verifier.EndTable();
|
||||||
|
}
|
||||||
|
AssetCT *UnPack(const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
void UnPackTo(AssetCT *_o, const ::flatbuffers::resolver_function_t *_resolver = nullptr) const;
|
||||||
|
static ::flatbuffers::Offset<AssetC> Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetCT* _o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AssetCBuilder {
|
||||||
|
typedef AssetC Table;
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||||
|
::flatbuffers::uoffset_t start_;
|
||||||
|
void add_inner_table(::flatbuffers::Offset<Flat::Bigfoot::InnerTable> inner_table) {
|
||||||
|
fbb_.AddOffset(AssetC::VT_INNER_TABLE, inner_table);
|
||||||
|
}
|
||||||
|
void add_asset_b_ref(const Flat::Bigfoot::HardReference *asset_b_ref) {
|
||||||
|
fbb_.AddStruct(AssetC::VT_ASSET_B_REF, asset_b_ref);
|
||||||
|
}
|
||||||
|
void add_asset_b_refs(::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *>> asset_b_refs) {
|
||||||
|
fbb_.AddOffset(AssetC::VT_ASSET_B_REFS, asset_b_refs);
|
||||||
|
}
|
||||||
|
explicit AssetCBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||||
|
: fbb_(_fbb) {
|
||||||
|
start_ = fbb_.StartTable();
|
||||||
|
}
|
||||||
|
::flatbuffers::Offset<AssetC> Finish() {
|
||||||
|
const auto end = fbb_.EndTable(start_);
|
||||||
|
auto o = ::flatbuffers::Offset<AssetC>(end);
|
||||||
|
fbb_.Required(o, AssetC::VT_INNER_TABLE);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetC> CreateAssetC(
|
||||||
|
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::InnerTable> inner_table = 0,
|
||||||
|
const Flat::Bigfoot::HardReference *asset_b_ref = nullptr,
|
||||||
|
::flatbuffers::Offset<::flatbuffers::Vector<const Flat::Bigfoot::SoftReference *>> asset_b_refs = 0) {
|
||||||
|
AssetCBuilder builder_(_fbb);
|
||||||
|
builder_.add_asset_b_refs(asset_b_refs);
|
||||||
|
builder_.add_asset_b_ref(asset_b_ref);
|
||||||
|
builder_.add_inner_table(inner_table);
|
||||||
|
return builder_.Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AssetC::Traits {
|
||||||
|
using type = AssetC;
|
||||||
|
static auto constexpr Create = CreateAssetC;
|
||||||
|
};
|
||||||
|
|
||||||
|
::flatbuffers::Offset<AssetC> CreateAssetC(::flatbuffers::FlatBufferBuilder &_fbb, const AssetCT *_o, const ::flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||||
|
|
||||||
|
inline InnerTableT *InnerTable::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
auto _o = std::make_unique<InnerTableT>();
|
||||||
|
UnPackTo(_o.get(), _resolver);
|
||||||
|
return _o.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void InnerTable::UnPackTo(InnerTableT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
(void)_o;
|
||||||
|
(void)_resolver;
|
||||||
|
{ auto _e = asset_a_ref(); if (_e) _o->asset_a_ref = ::flatbuffers::UnPackHardReferenceAssetA(*_e); }
|
||||||
|
{ auto _e = asset_a_refs(); if (_e) { _o->asset_a_refs.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->asset_a_refs[_i] = ::flatbuffers::UnPackHardReferenceAssetA(*_e->Get(_i)); } } else { _o->asset_a_refs.resize(0); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<InnerTable> CreateInnerTable(::flatbuffers::FlatBufferBuilder &_fbb, const InnerTableT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
return InnerTable::Pack(_fbb, _o, _rehasher);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<InnerTable> InnerTable::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const InnerTableT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
(void)_rehasher;
|
||||||
|
(void)_o;
|
||||||
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const InnerTableT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
|
auto _asset_a_ref = ::flatbuffers::PackHardReferenceAssetA(_o->asset_a_ref);
|
||||||
|
auto _asset_a_refs = _fbb.CreateVectorOfNativeStructs<Flat::Bigfoot::HardReference, ::Bigfoot::HardReference<::Bigfoot::AssetA>>(_o->asset_a_refs.data(), _o->asset_a_refs.size(), ::flatbuffers::PackHardReferenceAssetA);
|
||||||
|
return Flat::Bigfoot::CreateInnerTable(
|
||||||
|
_fbb,
|
||||||
|
&_asset_a_ref,
|
||||||
|
_asset_a_refs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AssetCT::AssetCT(const AssetCT &o)
|
||||||
|
: inner_table((o.inner_table) ? new Flat::Bigfoot::InnerTableT(*o.inner_table) : nullptr),
|
||||||
|
asset_b_ref(o.asset_b_ref),
|
||||||
|
asset_b_refs(o.asset_b_refs) {
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AssetCT &AssetCT::operator=(AssetCT o) FLATBUFFERS_NOEXCEPT {
|
||||||
|
std::swap(inner_table, o.inner_table);
|
||||||
|
std::swap(asset_b_ref, o.asset_b_ref);
|
||||||
|
std::swap(asset_b_refs, o.asset_b_refs);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline AssetCT *AssetC::UnPack(const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
auto _o = std::make_unique<AssetCT>();
|
||||||
|
UnPackTo(_o.get(), _resolver);
|
||||||
|
return _o.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AssetC::UnPackTo(AssetCT *_o, const ::flatbuffers::resolver_function_t *_resolver) const {
|
||||||
|
(void)_o;
|
||||||
|
(void)_resolver;
|
||||||
|
{ auto _e = inner_table(); if (_e) { if(_o->inner_table) { _e->UnPackTo(_o->inner_table.get(), _resolver); } else { _o->inner_table = eastl::unique_ptr<Flat::Bigfoot::InnerTableT>(_e->UnPack(_resolver)); } } else if (_o->inner_table) { _o->inner_table.reset(); } }
|
||||||
|
{ auto _e = asset_b_ref(); if (_e) _o->asset_b_ref = ::flatbuffers::UnPackHardReferenceAssetB(*_e); }
|
||||||
|
{ auto _e = asset_b_refs(); if (_e) { _o->asset_b_refs.resize(_e->size()); for (::flatbuffers::uoffset_t _i = 0; _i < _e->size(); _i++) { _o->asset_b_refs[_i] = ::flatbuffers::UnPackSoftReferenceAssetB(*_e->Get(_i)); } } else { _o->asset_b_refs.resize(0); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetC> CreateAssetC(::flatbuffers::FlatBufferBuilder &_fbb, const AssetCT *_o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
return AssetC::Pack(_fbb, _o, _rehasher);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ::flatbuffers::Offset<AssetC> AssetC::Pack(::flatbuffers::FlatBufferBuilder &_fbb, const AssetCT* _o, const ::flatbuffers::rehasher_function_t *_rehasher) {
|
||||||
|
(void)_rehasher;
|
||||||
|
(void)_o;
|
||||||
|
struct _VectorArgs { ::flatbuffers::FlatBufferBuilder *__fbb; const AssetCT* __o; const ::flatbuffers::rehasher_function_t *__rehasher; } _va = { &_fbb, _o, _rehasher}; (void)_va;
|
||||||
|
auto _inner_table = _o->inner_table ? CreateInnerTable(_fbb, _o->inner_table.get(), _rehasher) : 0;
|
||||||
|
auto _asset_b_ref = ::flatbuffers::PackHardReferenceAssetB(_o->asset_b_ref);
|
||||||
|
auto _asset_b_refs = _fbb.CreateVectorOfNativeStructs<Flat::Bigfoot::SoftReference, ::Bigfoot::SoftReference<::Bigfoot::AssetB>>(_o->asset_b_refs.data(), _o->asset_b_refs.size(), ::flatbuffers::PackSoftReferenceAssetB);
|
||||||
|
return Flat::Bigfoot::CreateAssetC(
|
||||||
|
_fbb,
|
||||||
|
_inner_table,
|
||||||
|
&_asset_b_ref,
|
||||||
|
_asset_b_refs);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *InnerTableTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 1, 0 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Flat::Bigfoot::HardReferenceTypeTable
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_TABLE, 2, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const ::flatbuffers::TypeTable *AssetCTypeTable() {
|
||||||
|
static const ::flatbuffers::TypeCode type_codes[] = {
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 0 },
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 0, 1 },
|
||||||
|
{ ::flatbuffers::ET_SEQUENCE, 1, 2 }
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeFunction type_refs[] = {
|
||||||
|
Flat::Bigfoot::InnerTableTypeTable,
|
||||||
|
Flat::Bigfoot::HardReferenceTypeTable,
|
||||||
|
Flat::Bigfoot::SoftReferenceTypeTable
|
||||||
|
};
|
||||||
|
static const ::flatbuffers::TypeTable tt = {
|
||||||
|
::flatbuffers::ST_TABLE, 3, type_codes, type_refs, nullptr, nullptr, nullptr
|
||||||
|
};
|
||||||
|
return &tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Flat::Bigfoot::AssetC *GetAssetC(const void *buf) {
|
||||||
|
return ::flatbuffers::GetRoot<Flat::Bigfoot::AssetC>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const Flat::Bigfoot::AssetC *GetSizePrefixedAssetC(const void *buf) {
|
||||||
|
return ::flatbuffers::GetSizePrefixedRoot<Flat::Bigfoot::AssetC>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifyAssetCBuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifyBuffer<Flat::Bigfoot::AssetC>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <bool B = false>
|
||||||
|
inline bool VerifySizePrefixedAssetCBuffer(
|
||||||
|
::flatbuffers::VerifierTemplate<B> &verifier) {
|
||||||
|
return verifier.template VerifySizePrefixedBuffer<Flat::Bigfoot::AssetC>(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char *AssetCExtension() {
|
||||||
|
return "bfbs";
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishAssetCBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::AssetC> root) {
|
||||||
|
fbb.Finish(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FinishSizePrefixedAssetCBuffer(
|
||||||
|
::flatbuffers::FlatBufferBuilder &fbb,
|
||||||
|
::flatbuffers::Offset<Flat::Bigfoot::AssetC> root) {
|
||||||
|
fbb.FinishSizePrefixed(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Flat::Bigfoot::AssetCT> UnPackAssetC(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Flat::Bigfoot::AssetCT>(GetAssetC(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline eastl::unique_ptr<Flat::Bigfoot::AssetCT> UnPackSizePrefixedAssetC(
|
||||||
|
const void *buf,
|
||||||
|
const ::flatbuffers::resolver_function_t *res = nullptr) {
|
||||||
|
return eastl::unique_ptr<Flat::Bigfoot::AssetCT>(GetSizePrefixedAssetC(buf)->UnPack(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Bigfoot
|
||||||
|
} // namespace Flat
|
||||||
|
|
||||||
|
namespace flatbuffers {
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETA
|
||||||
|
#define FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETA
|
||||||
|
inline Flat::Bigfoot::HardReference PackHardReferenceAssetA(const ::Bigfoot::HardReference<::Bigfoot::AssetA>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
inline ::Bigfoot::HardReference<::Bigfoot::AssetA> UnPackHardReferenceAssetA(const Flat::Bigfoot::HardReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
|
#endif // FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETA
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETB
|
||||||
|
#define FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETB
|
||||||
|
inline Flat::Bigfoot::HardReference PackHardReferenceAssetB(const ::Bigfoot::HardReference<::Bigfoot::AssetB>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
inline ::Bigfoot::HardReference<::Bigfoot::AssetB> UnPackHardReferenceAssetB(const Flat::Bigfoot::HardReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
|
#endif // FLATBUFFERS_BIGFOOT_REF_HARDREFERENCEASSETB
|
||||||
|
#ifndef FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETB
|
||||||
|
#define FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETB
|
||||||
|
inline Flat::Bigfoot::SoftReference PackSoftReferenceAssetB(const ::Bigfoot::SoftReference<::Bigfoot::AssetB>& p_asset) { return {Pack(p_asset.GetUUID())}; }
|
||||||
|
inline ::Bigfoot::SoftReference<::Bigfoot::AssetB> UnPackSoftReferenceAssetB(const Flat::Bigfoot::SoftReference& p_asset) { return {UnPack(p_asset.uuid())}; }
|
||||||
|
#endif // FLATBUFFERS_BIGFOOT_REF_SOFTREFERENCEASSETB
|
||||||
|
} // namespace flatbuffers
|
||||||
|
|
||||||
|
#endif // FLATBUFFERS_GENERATED_ASSETC_FLAT_BIGFOOT_H_
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/AssetsForTesting)
|
||||||
@@ -1,14 +1,10 @@
|
|||||||
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
project(${PackageName}Tests)
|
project(${PackageName}Tests)
|
||||||
|
|
||||||
set(BigfootDependencies
|
set(Dependencies)
|
||||||
System
|
set(BigfootDependencies)
|
||||||
Utils)
|
|
||||||
|
|
||||||
bigfoot_create_package_tests(
|
bigfoot_create_package_tests(
|
||||||
""
|
"${Dependencies}"
|
||||||
"${BigfootDependencies}")
|
"${BigfootDependencies}"
|
||||||
|
"")
|
||||||
bigfoot_create_logger()
|
|
||||||
|
|
||||||
bigfoot_setup_dependencies("Tests/Bigfoot")
|
|
||||||
@@ -28,14 +28,14 @@ TEST_F(FileFixture, IsRelative_ShouldReturnTrueOnRelativeFile)
|
|||||||
|
|
||||||
TEST_F(FileFixture, IsRelative_ShouldReturnFalseOnAbsoluteFile)
|
TEST_F(FileFixture, IsRelative_ShouldReturnFalseOnAbsoluteFile)
|
||||||
{
|
{
|
||||||
EXPECT_FALSE(m_file.Absolute().IsRelative());
|
EXPECT_FALSE(m_file.ToAbsolute().IsRelative());
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
|
|
||||||
TEST_F(FileFixture, IsAbsolute_ShouldReturnTrueOnAbsoluteFile)
|
TEST_F(FileFixture, IsAbsolute_ShouldReturnTrueOnAbsoluteFile)
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(m_file.Absolute().IsAbsolute());
|
EXPECT_TRUE(m_file.ToAbsolute().IsAbsolute());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FileFixture, IsAbsolute_ShouldReturnFalseOnRelativeFile)
|
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
|
} // namespace Bigfoot
|
||||||
|
|||||||
@@ -1,138 +0,0 @@
|
|||||||
/*********************************************************************
|
|
||||||
* \file Log.cpp
|
|
||||||
*
|
|
||||||
* \author Romain BOULLARD
|
|
||||||
* \date December 2022
|
|
||||||
*********************************************************************/
|
|
||||||
#include <System/Log/Log.hpp>
|
|
||||||
|
|
||||||
#include <Utils/Singleton.hpp>
|
|
||||||
|
|
||||||
#include <SystemTests/SystemTestsLogger_generated.hpp>
|
|
||||||
|
|
||||||
#if defined BIGFOOT_NOT_OPTIMIZED
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
|
|
||||||
namespace Bigfoot
|
|
||||||
{
|
|
||||||
class LogFixture: public ::testing::Test
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
void SetUp() override
|
|
||||||
{
|
|
||||||
SYSTEMTESTS_LOGGER = {"UTILSTESTS_LOGGER", Flat::LogLevel::Trace};
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr Flat::LogLevel QuillLogLevelToLogLevel(const quill::LogLevel p_level)
|
|
||||||
{
|
|
||||||
switch (p_level)
|
|
||||||
{
|
|
||||||
case quill::LogLevel::Debug:
|
|
||||||
return Flat::LogLevel::Debug;
|
|
||||||
case quill::LogLevel::TraceL3:
|
|
||||||
return Flat::LogLevel::Trace;
|
|
||||||
case quill::LogLevel::Info:
|
|
||||||
return Flat::LogLevel::Info;
|
|
||||||
case quill::LogLevel::Warning:
|
|
||||||
return Flat::LogLevel::Warn;
|
|
||||||
case quill::LogLevel::Error:
|
|
||||||
return Flat::LogLevel::Error;
|
|
||||||
case quill::LogLevel::Critical:
|
|
||||||
return Flat::LogLevel::Critical;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Flat::LogLevel::Trace;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log m_log;
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, RegisterLogger_ShouldRegisterTheLogger)
|
|
||||||
{
|
|
||||||
const quill::Logger* logger = m_log.RegisterLogger(SYSTEMTESTS_LOGGER);
|
|
||||||
EXPECT_TRUE(logger);
|
|
||||||
EXPECT_EQ(logger, m_log.GetLogger(SYSTEMTESTS_LOGGER));
|
|
||||||
EXPECT_EQ(logger->get_logger_name(), SYSTEMTESTS_LOGGER.m_name);
|
|
||||||
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), SYSTEMTESTS_LOGGER.m_level);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, GetLogger_ShouldReturnNullptrIfTheLoggerDoesNotExist)
|
|
||||||
{
|
|
||||||
EXPECT_FALSE(m_log.GetLogger(SYSTEMTESTS_LOGGER));
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, GetLogger_ShouldReturnTheLoggerIfItExists)
|
|
||||||
{
|
|
||||||
[[maybe_unused]]
|
|
||||||
const quill::Logger* logger = m_log.RegisterLogger(SYSTEMTESTS_LOGGER);
|
|
||||||
EXPECT_TRUE(m_log.GetLogger(SYSTEMTESTS_LOGGER));
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, ChangeLoggerLogLevel_ShouldChangeTheLoggerLogLevel)
|
|
||||||
{
|
|
||||||
const quill::Logger* logger = m_log.RegisterLogger(SYSTEMTESTS_LOGGER);
|
|
||||||
|
|
||||||
m_log.ChangeLoggerLogLevel(SYSTEMTESTS_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(SYSTEMTESTS_LOGGER, "Hello");
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, LogTrace)
|
|
||||||
{
|
|
||||||
Singleton<Log>::Lifetime singletonLifetime;
|
|
||||||
BIGFOOT_LOG_TRACE(SYSTEMTESTS_LOGGER, "Hello");
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, LogInfo)
|
|
||||||
{
|
|
||||||
Singleton<Log>::Lifetime singletonLifetime;
|
|
||||||
BIGFOOT_LOG_INFO(SYSTEMTESTS_LOGGER, "Hello");
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, LogWarn)
|
|
||||||
{
|
|
||||||
Singleton<Log>::Lifetime singletonLifetime;
|
|
||||||
BIGFOOT_LOG_WARN(SYSTEMTESTS_LOGGER, "Hello");
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, LogError)
|
|
||||||
{
|
|
||||||
Singleton<Log>::Lifetime singletonLifetime;
|
|
||||||
BIGFOOT_LOG_ERROR(SYSTEMTESTS_LOGGER, "Hello");
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************/
|
|
||||||
|
|
||||||
TEST_F(LogFixture, LogFatal)
|
|
||||||
{
|
|
||||||
Singleton<Log>::Lifetime singletonLifetime;
|
|
||||||
BIGFOOT_LOG_FATAL(SYSTEMTESTS_LOGGER, "Hello");
|
|
||||||
}
|
|
||||||
} // namespace Bigfoot
|
|
||||||
#endif
|
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
* \author Romain BOULLARD
|
* \author Romain BOULLARD
|
||||||
* \date December 2025
|
* \date December 2025
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
#include <System/Time.hpp>
|
#include <System/Time/Time.hpp>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
@@ -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
|
} // namespace Bigfoot
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
#include <System/UUID/UUID.hpp>
|
#include <System/UUID/UUID.hpp>
|
||||||
|
|
||||||
#include <ankerl/unordered_dense.h>
|
#include <ankerl/unordered_dense.h>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
namespace Bigfoot
|
namespace Bigfoot
|
||||||
@@ -44,13 +43,13 @@ class UUIDFixture: public ::testing::Test
|
|||||||
|
|
||||||
TEST_F(UUIDFixture, DumpingRawAndConstructAnUUIDWithItShouldGiveTheSameUUID)
|
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});
|
EXPECT_EQ(m_a, UUID {raw});
|
||||||
|
|
||||||
raw = m_b;
|
raw = m_b.ToBytes();
|
||||||
EXPECT_EQ(m_b, UUID {raw});
|
EXPECT_EQ(m_b, UUID {raw});
|
||||||
|
|
||||||
raw = m_d;
|
raw = m_d.ToBytes();
|
||||||
EXPECT_EQ(m_d, UUID {raw});
|
EXPECT_EQ(m_d, UUID {raw});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,21 +57,21 @@ TEST_F(UUIDFixture, DumpingRawAndConstructAnUUIDWithItShouldGiveTheSameUUID)
|
|||||||
|
|
||||||
TEST_F(UUIDFixture, ValidIDFromStringShouldBeEqualToString)
|
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)
|
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)
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************/
|
/****************************************************************************************/
|
||||||
@@ -169,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;
|
std::span<const std::byte, UUID::UUID_BYTE_SIZE> raw = m_raw;
|
||||||
|
|
||||||
for (std::uint32_t i = 0; i < UUID::UUID_BYTE_SIZE; ++i)
|
for (std::uint32_t i = 0; i < UUID::UUID_BYTE_SIZE; ++i)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||||
project(${PackageName}Tests)
|
project(${PackageName}Tests)
|
||||||
|
|
||||||
set(BigfootDependencies
|
set(Dependencies)
|
||||||
Utils)
|
set(BigfootDependencies)
|
||||||
|
|
||||||
bigfoot_create_package_tests(
|
bigfoot_create_package_tests(
|
||||||
""
|
"${Dependencies}"
|
||||||
"${BigfootDependencies}")
|
"${BigfootDependencies}"
|
||||||
|
"")
|
||||||
|
|
||||||
bigfoot_setup_dependencies("Tests/Bigfoot")
|
bigfoot_create_logger()
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
|||||||
|
// AUTO-GENERATED DO NOT TOUCH
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* \file UtilsTestsLogger.generated.hpp
|
||||||
|
*
|
||||||
|
*********************************************************************/
|
||||||
|
#ifndef BIGFOOT_UTILSTESTSLOGGER_GENERATED_HPP
|
||||||
|
#define BIGFOOT_UTILSTESTSLOGGER_GENERATED_HPP
|
||||||
|
#include <Utils/Log/LogMacros.hpp>
|
||||||
|
|
||||||
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Logger
|
||||||
|
*/
|
||||||
|
inline Log::LoggerInfo UTILSTESTS_LOGGER {"UTILSTESTS_LOGGER", Flat::LogLevel::Trace};
|
||||||
|
} // namespace Bigfoot
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/*********************************************************************
|
||||||
|
* \file Log.cpp
|
||||||
|
*
|
||||||
|
* \author Romain BOULLARD
|
||||||
|
* \date December 2022
|
||||||
|
*********************************************************************/
|
||||||
|
#include <Utils/Log/Log.hpp>
|
||||||
|
|
||||||
|
#include <Utils/Singleton.hpp>
|
||||||
|
|
||||||
|
#include <UtilsTests/UtilsTestsLogger_generated.hpp>
|
||||||
|
|
||||||
|
#if defined BIGFOOT_NOT_OPTIMIZED
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace Bigfoot
|
||||||
|
{
|
||||||
|
class LogFixture: public ::testing::Test
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
static constexpr Flat::LogLevel QuillLogLevelToLogLevel(const quill::LogLevel p_level)
|
||||||
|
{
|
||||||
|
switch (p_level)
|
||||||
|
{
|
||||||
|
case quill::LogLevel::Debug:
|
||||||
|
return Flat::LogLevel::Debug;
|
||||||
|
case quill::LogLevel::TraceL3:
|
||||||
|
return Flat::LogLevel::Trace;
|
||||||
|
case quill::LogLevel::Info:
|
||||||
|
return Flat::LogLevel::Info;
|
||||||
|
case quill::LogLevel::Warning:
|
||||||
|
return Flat::LogLevel::Warn;
|
||||||
|
case quill::LogLevel::Error:
|
||||||
|
return Flat::LogLevel::Error;
|
||||||
|
case quill::LogLevel::Critical:
|
||||||
|
return Flat::LogLevel::Critical;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Flat::LogLevel::Trace;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(LogFixture, RegisterLogger_ShouldRegisterTheLogger)
|
||||||
|
{
|
||||||
|
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
|
||||||
|
EXPECT_TRUE(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, UnregisterLogger_ShouldUnregisterTheLogger)
|
||||||
|
{
|
||||||
|
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_ShouldReturnNullptrIfTheLoggerDoesNotExist)
|
||||||
|
{
|
||||||
|
EXPECT_FALSE(Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(LogFixture, GetLoger_ShouldReturnTheLoggerIfItExists)
|
||||||
|
{
|
||||||
|
[[maybe_unused]]
|
||||||
|
const quill::Logger* logger = Singleton<Log>::GetInstance().RegisterLogger(UTILSTESTS_LOGGER);
|
||||||
|
EXPECT_TRUE(Singleton<Log>::GetInstance().GetLogger(UTILSTESTS_LOGGER));
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************************/
|
||||||
|
|
||||||
|
TEST_F(LogFixture, ChangeLoggerLogLevel_ShouldChangeTheLoggerLogLevel)
|
||||||
|
{
|
||||||
|
const Flat::LogLevel previous = UTILSTESTS_LOGGER.m_level;
|
||||||
|
|
||||||
|
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);
|
||||||
|
Singleton<Log>::GetInstance().ChangeLoggerLogLevel(UTILSTESTS_LOGGER, previous);
|
||||||
|
EXPECT_EQ(QuillLogLevelToLogLevel(logger->get_log_level()), previous);
|
||||||
|
}
|
||||||
|
} // namespace Bigfoot
|
||||||
|
#endif
|
||||||
@@ -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
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user