Initial commit
Bigfoot / Sonarqube (push) Failing after 0s
Bigfoot / Build & Test Debug (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test Debug (Unity Build: ON) (push) Failing after 0s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: ON) (push) Failing after 0s
Bigfoot / Build & Test Release (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test Release (Unity Build: ON) (push) Failing after 0s
Bigfoot / Clang Format Checks (push) Failing after 0s

This commit is contained in:
2026-08-17 01:14:21 +02:00
commit 50e314be56
87 changed files with 5657 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Utils)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/System)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Engine)
@@ -0,0 +1,41 @@
PRAGMA journal_mode=WAL;
PRAGMA foreign_keys = ON;
DROP TABLE IF EXISTS AssetHeader;
CREATE TABLE IF NOT EXISTS AssetHeader (
UUID BLOB NOT NULL UNIQUE,
Name TEXT NOT NULL UNIQUE,
TypeID INTEGER NOT NULL,
TypeName TEXT NOT NULL,
CreateTime INTEGER NOT NULL DEFAULT(CAST(unixepoch('subsec') AS INTEGER) * 1000000),
ModificationTime INTEGER NOT NULL DEFAULT(CAST(unixepoch('subsec') AS INTEGER) * 1000000),
PRIMARY KEY(UUID)
);
CREATE TRIGGER IF NOT EXISTS AssetHeader_UpdateTime
AFTER UPDATE OF Name, TypeID, TypeName ON AssetHeader FOR EACH ROW
BEGIN
UPDATE AssetHeader
SET ModificationTime = CAST(unixepoch('subsec') AS INTEGER) * 1000000
WHERE UUID = NEW.UUID;
END;
DROP TABLE IF EXISTS Asset;
CREATE TABLE IF NOT EXISTS Asset (
UUID BLOB NOT NULL UNIQUE,
Asset BLOB NOT NULL,
PRIMARY KEY(UUID),
FOREIGN KEY(UUID) REFERENCES AssetHeader(UUID) ON DELETE CASCADE
);
CREATE TRIGGER IF NOT EXISTS Asset_UpdateTime
AFTER UPDATE OF Asset ON Asset FOR EACH ROW
BEGIN
UPDATE AssetHeader
SET ModificationTime = CAST(unixepoch('subsec') AS INTEGER) * 1000000
WHERE UUID = NEW.UUID;
END;
+25
View File
@@ -0,0 +1,25 @@
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${PackageName})
set(PublicDependencies
SQLite::SQLite3)
set(PrivateDependencies)
set(BigfootPublicDependencies
System
Utils)
set(BigfootPrivateDependencies)
set(BIGFOOT_MAJOR 0)
set(BIGFOOT_MINOR 1)
set(BIGFOOT_PATCH 0)
set(BIGFOOT_NAME "Bigfoot")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Include/Engine/EngineInfo_generated.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/Include/Engine/EngineInfo_generated.hpp @ONLY)
bigfoot_create_logger()
bigfoot_create_package_lib(
"${PublicDependencies}"
"${PrivateDependencies}"
"${BigfootPublicDependencies}"
"${BigfootPrivateDependencies}"
"")
@@ -0,0 +1,19 @@
@AUTO_GENERATED_COMMENT@
/*********************************************************************
* \file BigFileInfo.generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_@BIGFILE_NAME@_BIGFILEINFO_GENERATED_HPP
#define BIGFOOT_@BIGFILE_NAME@_BIGFILEINFO_GENERATED_HPP
#include <EASTL/string_view.h>
namespace Bigfoot
{
/*
* BigFile location
*/
constexpr eastl::string_view BIGFILE_@BIGFILE_NAME@_LOCATION {"@BIGFILE_LOCATION@"};
} // namespace Bigfoot
#endif
@@ -0,0 +1,60 @@
/*********************************************************************
* \file EngineAssertHandler.hpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#ifndef BIGFOOT_ENGINE_ENGINEASSERTHANDLER_HPP
#define BIGFOOT_ENGINE_ENGINEASSERTHANDLER_HPP
#include <Utils/Assert.hpp>
#include <Engine/EngineLogger_generated.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <EASTL/utility.h>
#include <format>
#include <source_location>
#include <string_view>
namespace Bigfoot
{
class EngineAssertHandler
{
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
#endif
#endif
@@ -0,0 +1,25 @@
// AUTO-GENERATED DO NOT TOUCH
/*********************************************************************
* \file EngineInfo_generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_ENGINE_ENGINEINFO_GENERATED_HPP
#define BIGFOOT_ENGINE_ENGINEINFO_GENERATED_HPP
#include <Utils/Version.hpp>
#include <EASTL/string_view.h>
namespace Bigfoot
{
/*
* Engine version
*/
constexpr Version BIGFOOT_VERSION {0, 1, 0};
/*
* Engine name
*/
constexpr eastl::string_view BIGFOOT_NAME {"Bigfoot"};
} // namespace Bigfoot
#endif
@@ -0,0 +1,25 @@
@AUTO_GENERATED_COMMENT@
/*********************************************************************
* \file EngineInfo_generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_ENGINE_ENGINEINFO_GENERATED_HPP
#define BIGFOOT_ENGINE_ENGINEINFO_GENERATED_HPP
#include <Utils/Version.hpp>
#include <EASTL/string_view.h>
namespace Bigfoot
{
/*
* Engine version
*/
constexpr Version BIGFOOT_VERSION {@BIGFOOT_MAJOR@, @BIGFOOT_MINOR@, @BIGFOOT_PATCH@};
/*
* Engine name
*/
constexpr eastl::string_view BIGFOOT_NAME {"@BIGFOOT_NAME@"};
} // namespace Bigfoot
#endif
@@ -0,0 +1,21 @@
// AUTO-GENERATED DO NOT TOUCH
/*********************************************************************
* \file EngineLogger.generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_ENGINELOGGER_GENERATED_HPP
#define BIGFOOT_ENGINELOGGER_GENERATED_HPP
#include <System/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
namespace Bigfoot
{
/*
* Logger
*/
inline Log::LoggerInfo ENGINE_LOGGER {"ENGINE_LOGGER", Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
+1
View File
@@ -0,0 +1 @@
// to delete when an actual source is in Engine
+28
View File
@@ -0,0 +1,28 @@
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${PackageName})
set(PublicDependencies
$<$<CONFIG:Debug,RelWithDebInfo>:quill::quill>
mimalloc
stduuid::stduuid)
set(PrivateDependencies)
set(BigfootPublicDependencies
Utils)
set(BigfootPrivateDependencies)
bigfoot_create_package_lib(
"${PublicDependencies}"
"${PrivateLibraries}"
"${BigfootPublicDependencies}"
"${BigfootPrivateDependencies}"
"")
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)
+66
View File
@@ -0,0 +1,66 @@
/*********************************************************************
* \file File.cpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#include <System/File.hpp>
namespace Bigfoot
{
File::File(const eastl::string_view p_path):
m_path(p_path.data()),
m_pathString(p_path)
{
}
/****************************************************************************************/
bool File::IsAbsolute() const
{
return m_path.is_absolute();
}
/****************************************************************************************/
bool File::IsRelative() const
{
return m_path.is_relative();
}
/****************************************************************************************/
bool File::Exists() const
{
return std::filesystem::exists(m_path);
}
/****************************************************************************************/
eastl::string_view File::Path() const
{
return m_pathString;
}
/****************************************************************************************/
File File::Absolute() const
{
return File {std::filesystem::absolute(m_path)};
}
/****************************************************************************************/
File File::Relative() const
{
return File {std::filesystem::relative(m_path)};
}
/****************************************************************************************/
File::File(const std::filesystem::path& p_path):
m_path(p_path),
m_pathString(m_path.string().c_str())
{
}
} // namespace Bigfoot
@@ -0,0 +1,103 @@
/*********************************************************************
* \file File.hpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#ifndef BIGFOOT_SYSTEM_FILE_HPP
#define BIGFOOT_SYSTEM_FILE_HPP
#include <EASTL/string.h>
#include <EASTL/string_view.h>
#include <filesystem>
namespace Bigfoot
{
class File
{
public:
/**
* Constructor
*
* \param p_path The path
*/
File(const eastl::string_view p_path);
File(const File& p_path) = default;
File(File&& p_path) = default;
/**
* Check if the file is relative to the current executable
*
* \return True if the file is relative, false otherwise
*/
[[nodiscard]]
bool IsRelative() const;
/**
* Check if the file is absolute
*
* \return True if the file is absolute, false otherwise
*/
[[nodiscard]]
bool IsAbsolute() const;
/**
* Check if the file exists
*
* \return True if it exists, false otherwise
*/
[[nodiscard]]
bool Exists() const;
/**
* Get the file path
*
* \return The path
*/
[[nodiscard]]
eastl::string_view Path() const;
/**
* Get the same file, relative to the current executable
*
* \return The relative file
*/
[[nodiscard]]
File Relative() const;
/**
* Get the same file, with an absolute path
*
* \return The absolute file
*/
[[nodiscard]]
File Absolute() const;
~File() = default;
File& operator=(const File& p_path) = default;
File& operator=(File&& p_path) = default;
private:
/**
* Constructor
*
* \param p_path The path
*/
File(const std::filesystem::path& p_path);
/**
* The path
*/
std::filesystem::path m_path;
/*
* The path as a string
*/
eastl::string m_pathString;
};
} // namespace Bigfoot
#endif
@@ -0,0 +1,95 @@
/*********************************************************************
* \file EASTLFormatters.hpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#ifndef BIGFOOT_SYSTEM_EASTLFORMATTERS_HPP
#define BIGFOOT_SYSTEM_EASTLFORMATTERS_HPP
#include <Utils/TargetMacros.h>
#if defined(BIGFOOT_NOT_OPTIMIZED)
#include <quill/DeferredFormatCodec.h>
#endif
#include <format>
#include <EASTL/string.h>
#include <EASTL/string_view.h>
// STRING
template<>
struct std::formatter<eastl::string>
{
constexpr auto parse(std::format_parse_context& ctx)
{
return ctx.begin();
}
template<typename FormatContext>
auto format(const eastl::string& p_string, FormatContext& ctx) const
{
return std::format_to(ctx.out(), "{}", p_string.c_str());
}
};
#if defined BIGFOOT_NOT_OPTIMIZED
template<>
struct fmtquill::formatter<eastl::string>
{
constexpr auto parse(format_parse_context& ctx)
{
return ctx.begin();
}
auto format(const eastl::string& p_string, format_context& ctx) const
{
return fmtquill::format_to(ctx.out(), "{}", p_string.c_str());
}
};
template<>
struct quill::Codec<eastl::string>: quill::DeferredFormatCodec<eastl::string>
{
};
#endif
// STRING_VIEW
template<>
struct std::formatter<eastl::string_view>
{
constexpr auto parse(std::format_parse_context& ctx)
{
return ctx.begin();
}
template<typename FormatContext>
auto format(const eastl::string_view& p_stringView, FormatContext& ctx) const
{
return std::format_to(ctx.out(), "{}", p_stringView.data());
}
};
#if defined BIGFOOT_NOT_OPTIMIZED
template<>
struct fmtquill::formatter<eastl::string_view>
{
constexpr auto parse(format_parse_context& ctx)
{
return ctx.begin();
}
auto format(const eastl::string_view& p_stringView, format_context& ctx) const
{
return fmtquill::format_to(ctx.out(), "{}", p_stringView.data());
}
};
template<>
struct quill::Codec<eastl::string_view>: quill::DeferredFormatCodec<eastl::string_view>
{
};
#endif
#endif
@@ -0,0 +1,16 @@
namespace Bigfoot.Flat;
enum LogSinkType: byte
{
Console
}
enum LogLevel: byte
{
Debug,
Trace,
Info,
Warn,
Error,
Critical
}
@@ -0,0 +1,182 @@
/*********************************************************************
* \file Log.hpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_SYSTEM_LOG_HPP
#define BIGFOOT_SYSTEM_LOG_HPP
#include <System/Log/EASTLFormatters.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <System/Log/Log_generated.hpp>
#include <Utils/Singleton.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);
/**
* 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, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_DEBUG(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_DEBUG(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_TRACE_L3(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_TRACE_L3(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_INFO(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_WARNING(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_ERROR(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...) \
do \
{ \
if (quill::Logger* logger = Bigfoot::Singleton<Bigfoot::Log>::Instance().GetLogger(loggerName)) \
{ \
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
else \
{ \
QUILL_LOG_CRITICAL(Bigfoot::Singleton<Bigfoot::Log>::Instance().RegisterLogger(loggerName), \
fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
#else
#define BIGFOOT_LOG_DEBUG(loggerName, fmt, ...)
#define BIGFOOT_LOG_TRACE(loggerName, fmt, ...)
#define BIGFOOT_LOG_INFO(loggerName, fmt, ...)
#define BIGFOOT_LOG_WARN(loggerName, fmt, ...)
#define BIGFOOT_LOG_ERROR(loggerName, fmt, ...)
#define BIGFOOT_LOG_FATAL(loggerName, fmt, ...)
#endif
#endif
@@ -0,0 +1,136 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_LOG_BIGFOOT_FLAT_H_
#define FLATBUFFERS_GENERATED_LOG_BIGFOOT_FLAT_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");
#include "EASTL/unique_ptr.h"
#include "EASTL/string.h"
namespace Bigfoot {
namespace Flat {
enum class LogSinkType : int8_t {
Console = 0,
MIN = Console,
MAX = Console
};
inline const LogSinkType (&EnumValuesLogSinkType())[1] {
static const LogSinkType values[] = {
LogSinkType::Console
};
return values;
}
inline const char * const *EnumNamesLogSinkType() {
static const char * const names[2] = {
"Console",
nullptr
};
return names;
}
inline const char *EnumNameLogSinkType(LogSinkType e) {
if (::flatbuffers::IsOutRange(e, LogSinkType::Console, LogSinkType::Console)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesLogSinkType()[index];
}
enum class LogLevel : int8_t {
Debug = 0,
Trace = 1,
Info = 2,
Warn = 3,
Error = 4,
Critical = 5,
MIN = Debug,
MAX = Critical
};
inline const LogLevel (&EnumValuesLogLevel())[6] {
static const LogLevel values[] = {
LogLevel::Debug,
LogLevel::Trace,
LogLevel::Info,
LogLevel::Warn,
LogLevel::Error,
LogLevel::Critical
};
return values;
}
inline const char * const *EnumNamesLogLevel() {
static const char * const names[7] = {
"Debug",
"Trace",
"Info",
"Warn",
"Error",
"Critical",
nullptr
};
return names;
}
inline const char *EnumNameLogLevel(LogLevel e) {
if (::flatbuffers::IsOutRange(e, LogLevel::Debug, LogLevel::Critical)) return "";
const size_t index = static_cast<size_t>(e);
return EnumNamesLogLevel()[index];
}
inline const ::flatbuffers::TypeTable *LogSinkTypeTypeTable() {
static const ::flatbuffers::TypeCode type_codes[] = {
{ ::flatbuffers::ET_CHAR, 0, 0 }
};
static const ::flatbuffers::TypeFunction type_refs[] = {
Bigfoot::Flat::LogSinkTypeTypeTable
};
static const char * const names[] = {
"Console"
};
static const ::flatbuffers::TypeTable tt = {
::flatbuffers::ST_ENUM, 1, type_codes, type_refs, nullptr, nullptr, names
};
return &tt;
}
inline const ::flatbuffers::TypeTable *LogLevelTypeTable() {
static const ::flatbuffers::TypeCode type_codes[] = {
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 },
{ ::flatbuffers::ET_CHAR, 0, 0 }
};
static const ::flatbuffers::TypeFunction type_refs[] = {
Bigfoot::Flat::LogLevelTypeTable
};
static const char * const names[] = {
"Debug",
"Trace",
"Info",
"Warn",
"Error",
"Critical"
};
static const ::flatbuffers::TypeTable tt = {
::flatbuffers::ST_ENUM, 6, type_codes, type_refs, nullptr, nullptr, names
};
return &tt;
}
} // namespace Flat
} // namespace Bigfoot
#endif // FLATBUFFERS_GENERATED_LOG_BIGFOOT_FLAT_H_
@@ -0,0 +1,21 @@
@AUTO_GENERATED_COMMENT@
/*********************************************************************
* \file @LOGGER_FILENAME@.generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
#define BIGFOOT_@LOGGER_FILENAME_UPPER@_GENERATED_HPP
#include <System/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
namespace Bigfoot
{
/*
* Logger
*/
inline Log::LoggerInfo @LOGGER_NAME@ {"@LOGGER_NAME@", Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
@@ -0,0 +1,64 @@
/*********************************************************************
* \file Profiler.hpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_CONCAT_PROFILER_HPP
#define BIGFOOT_CONCAT_PROFILER_HPP
#ifdef TRACY
#include <tracy/Tracy.hpp>
#define BIGFOOT_PROFILER_THREADNAME(p_name) tracy::SetThreadName(p_name)
#define BIGFOOT_PROFILER_FRAME() FrameMark
#define BIGFOOT_PROFILER_FRAME_START(p_name) FrameMarkStart(p_name)
#define BIGFOOT_PROFILER_FRAME_STOP(p_name) FrameMarkEnd(p_name)
#define BIGFOOT_PROFILER_PROFILE_FUNCTION() ZoneScoped
#define BIGFOOT_PROFILER_PROFILE(p_name) ZoneScopedN(p_name)
#define BIGFOOT_PROFILER_TEXT(p_text, p_size) ZoneText(p_text, p_size)
#define BIGFOOT_PROFILER_MEMORY_ALLOC(p_ptr, p_size) TracyAlloc(p_ptr, p_size)
#define BIGFOOT_PROFILER_MEMORY_FREE(p_ptr) TracyFree(p_ptr)
#define BIGFOOT_PROFILER_LOCKABLE(p_type, p_name) TracyLockable(p_type, p_name)
#define BIGFOOT_PROFILER_LOCK(p_name) LockMark(p_name)
#define BIGFOOT_PROFILER_APPINFO(p_text, p_size) TracyAppInfo(p_text, p_size)
#define BIGFOOT_PROFILER_ATTACH_FRAME_IMAGE(p_imageData, p_width, p_height, p_offset) \
FrameImage(p_imageData, p_width, p_height, p_offset, false)
#define BIGFOOT_PROFILER
#define BIGFOOT_PROFILER_ONLY(...) __VA_ARGS__
// TODO: profile GPU
#else
#define BIGFOOT_PROFILER_THREADNAME(p_name)
#define BIGFOOT_PROFILER_FRAME()
#define BIGFOOT_PROFILER_FRAME_START(p_name)
#define BIGFOOT_PROFILER_FRAME_STOP(p_name)
#define BIGFOOT_PROFILER_PROFILE_FUNCTION()
#define BIGFOOT_PROFILER_PROFILE(p_name)
#define BIGFOOT_PROFILER_TEXT_FUNCTION(p_text, p_size)
#define BIGFOOT_PROFILER_TEXT(p_text, p_size)
#define BIGFOOT_PROFILER_MEMORY_ALLOC(p_ptr, p_size)
#define BIGFOOT_PROFILER_MEMORY_FREE(p_ptr)
#define BIGFOOT_PROFILER_LOCKABLE(p_type, p_name) p_type p_name
#define BIGFOOT_PROFILER_LOCK(p_name)
#define BIGFOOT_PROFILER_APPINFO(p_text, p_size)
#define BIGFOOT_PROFILER_ATTACH_FRAME_IMAGE(p_imageData, p_width, p_height, p_offset)
#define BIGFOOT_PROFILER_ONLY(...)
// TODO: profile GPU
#endif
#endif
@@ -0,0 +1,60 @@
/*********************************************************************
* \file SystemAssertHandler.hpp
*
* \author Romain BOULLARD
* \date January 2026
*********************************************************************/
#ifndef BIGFOOT_SYSTEM_SYSTEMASSERTHANDLER_HPP
#define BIGFOOT_SYSTEM_SYSTEMASSERTHANDLER_HPP
#include <Utils/Assert.hpp>
#include <System/SystemLogger_generated.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
#include <EASTL/utility.h>
#include <format>
#include <source_location>
#include <string_view>
namespace Bigfoot
{
class SystemAssertHandler
{
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
#endif
#endif
@@ -0,0 +1,21 @@
// AUTO-GENERATED DO NOT TOUCH
/*********************************************************************
* \file SystemLogger.generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
#define BIGFOOT_SYSTEMLOGGER_GENERATED_HPP
#include <System/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
namespace Bigfoot
{
/*
* Logger
*/
inline Log::LoggerInfo SYSTEM_LOGGER {"SYSTEM_LOGGER", Flat::LogLevel::Trace};
} // namespace Bigfoot
#endif
#endif
@@ -0,0 +1,68 @@
/*********************************************************************
* \file Time.hpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#ifndef BIGFOOT_SYSTEM_TIME_HPP
#define BIGFOOT_SYSTEM_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 Year() const;
[[nodiscard]]
std::uint32_t Month() const;
[[nodiscard]]
std::uint32_t Day() const;
[[nodiscard]]
std::uint32_t Hour() const;
[[nodiscard]]
std::uint32_t Minute() const;
[[nodiscard]]
std::uint32_t Second() const;
[[nodiscard]]
std::uint32_t Microsecond() const;
[[nodiscard]]
std::uint64_t Epoch() 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
#endif
@@ -0,0 +1,18 @@
/*********************************************************************
* \file FlatUUID.hpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#ifndef BIGFOOT_SYSTEM_FLATUUID_HPP
#define BIGFOOT_SYSTEM_FLATUUID_HPP
#include <System/UUID/UUID.hpp>
#include <System/UUID/UUID_generated.hpp>
namespace flatbuffers
{
Bigfoot::Flat::UUID Pack(const Bigfoot::UUID& p_uuid);
Bigfoot::UUID UnPack(const Bigfoot::Flat::UUID& p_flatUUID);
} // namespace flatbuffers
#endif
@@ -0,0 +1,8 @@
native_include "System/UUID/FlatUUID.hpp";
namespace Bigfoot.Flat;
struct UUID (native_type: "::Bigfoot::UUID")
{
bytes:[ubyte:16];
}
@@ -0,0 +1,144 @@
/*********************************************************************
* \file UUID.hpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_SYSTEM_UUID_HPP
#define BIGFOOT_SYSTEM_UUID_HPP
#include <uuid.h>
namespace Bigfoot
{
class UUID
{
public:
static constexpr std::uint32_t UUID_BYTE_SIZE = 16;
UUID();
/**
* Constructor.
*
* \param p_string String to create the UUID, should be a UUID V4
*/
explicit UUID(const std::string_view p_string);
/**
* Constructor
*
* \param p_raw The raw UUID
*/
explicit UUID(const std::span<const std::byte, UUID_BYTE_SIZE> p_raw);
UUID(const UUID& p_uuid) = default;
UUID(UUID&& p_uuid) noexcept = default;
~UUID() = default;
operator std::span<const std::byte, UUID_BYTE_SIZE>() const;
operator std::string() const;
operator bool() const;
UUID& operator=(const UUID& p_uuid) = default;
UUID& operator=(UUID&& p_uuid) noexcept = default;
[[nodiscard]]
bool operator==(const UUID& p_uuid) const = default;
[[nodiscard]]
bool operator!=(const UUID& p_uuid) const = default;
[[nodiscard]]
bool operator<(const UUID& p_uuid) const;
private:
/**
* Get a random generator
*
* \return A random generator
*/
static std::mt19937 GetRandomGenerator();
/**
* Get a UUID generator
*
* \return A UUID generator
*/
static uuids::uuid_random_generator GetUUIDGenerator();
public:
/**
* Null UUID.
*/
static UUID NULL_UUID;
private:
friend struct std::hash<UUID>;
/**
* The uuid.
*/
uuids::uuid m_uuid;
/**
* Random generator for the UUID
*/
inline static std::mt19937 ms_randomGenerator = GetRandomGenerator();
/**
* UUID generator
*/
inline static uuids::uuid_random_generator ms_uuidGenerator = GetUUIDGenerator();
};
} // namespace Bigfoot
/****************************************************************************************/
template<>
struct std::hash<Bigfoot::UUID>
{
std::size_t operator()(const Bigfoot::UUID& p_uuid) const noexcept
{
return std::hash<uuids::uuid>()(p_uuid.m_uuid);
}
};
template<>
struct std::formatter<Bigfoot::UUID, char>
{
constexpr auto parse(std::format_parse_context& ctx)
{
return ctx.begin();
}
template<typename FormatContext>
auto format(const Bigfoot::UUID& p_uuid, FormatContext& ctx) const
{
return std::format_to(ctx.out(), "{}", static_cast<std::string>(p_uuid));
}
};
#if defined BIGFOOT_NOT_OPTIMIZED
#include <quill/DeferredFormatCodec.h>
template<>
struct fmtquill::formatter<Bigfoot::UUID>
{
constexpr auto parse(format_parse_context& ctx)
{
return ctx.begin();
}
auto format(const Bigfoot::UUID& p_uuid, format_context& ctx) const
{
return fmtquill::format_to(ctx.out(), "{}", static_cast<std::string>(p_uuid));
}
};
template<>
struct quill::Codec<Bigfoot::UUID>: quill::DeferredFormatCodec<Bigfoot::UUID>
{
};
#endif
#endif
@@ -0,0 +1,74 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_UUID_BIGFOOT_FLAT_H_
#define FLATBUFFERS_GENERATED_UUID_BIGFOOT_FLAT_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");
#include "System/UUID/FlatUUID.hpp"
#include "EASTL/unique_ptr.h"
#include "EASTL/string.h"
namespace Bigfoot {
namespace Flat {
struct UUID;
inline const ::flatbuffers::TypeTable *UUIDTypeTable();
FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) UUID FLATBUFFERS_FINAL_CLASS {
private:
uint8_t bytes_[16];
public:
struct Traits;
static const ::flatbuffers::TypeTable *MiniReflectTypeTable() {
return UUIDTypeTable();
}
static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() {
return "Bigfoot.Flat.UUID";
}
UUID()
: bytes_() {
}
UUID(::flatbuffers::span<const uint8_t, 16> _bytes) {
::flatbuffers::CastToArray(bytes_).CopyFromSpan(_bytes);
}
const ::flatbuffers::Array<uint8_t, 16> *bytes() const {
return &::flatbuffers::CastToArray(bytes_);
}
};
FLATBUFFERS_STRUCT_END(UUID, 16);
struct UUID::Traits {
using type = UUID;
};
inline const ::flatbuffers::TypeTable *UUIDTypeTable() {
static const ::flatbuffers::TypeCode type_codes[] = {
{ ::flatbuffers::ET_UCHAR, 1, -1 }
};
static const int16_t array_sizes[] = { 16, };
static const int64_t values[] = { 0, 16 };
static const char * const names[] = {
"bytes"
};
static const ::flatbuffers::TypeTable tt = {
::flatbuffers::ST_STRUCT, 1, type_codes, nullptr, array_sizes, values, names
};
return &tt;
}
} // namespace Flat
} // namespace Bigfoot
#endif // FLATBUFFERS_GENERATED_UUID_BIGFOOT_FLAT_H_
+92
View File
@@ -0,0 +1,92 @@
/*******************************************************************
* \file Log.cpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#include <System/Log/Log.hpp>
#if defined BIGFOOT_NOT_OPTIMIZED
namespace Bigfoot
{
Log::Log()
{
quill::Backend::start();
m_sinks[static_cast<std::size_t>(Flat::LogSinkType::Console)] =
quill::Frontend::create_or_get_sink<quill::ConsoleSink>(
std::string {Flat::EnumNameLogSinkType(Flat::LogSinkType::Console)});
}
/****************************************************************************************/
quill::Logger* Log::RegisterLogger(const LoggerInfo& p_loggerInfo)
{
quill::Logger* logger = quill::Frontend::create_or_get_logger(
p_loggerInfo.m_name,
m_sinks[static_cast<std::size_t>(Flat::LogSinkType::Console)]);
SetLoggerLevel(p_loggerInfo);
return logger;
}
/****************************************************************************************/
quill::Logger* Log::GetLogger(const LoggerInfo& p_loggerInfo)
{
return quill::Frontend::get_logger(p_loggerInfo.m_name);
}
/****************************************************************************************/
void Log::ChangeLoggerLogLevel(LoggerInfo& p_loggerInfo, const Flat::LogLevel p_level)
{
p_loggerInfo.m_level = p_level;
SetLoggerLevel(p_loggerInfo);
}
/****************************************************************************************/
void Log::SetLoggerLevel(const LoggerInfo& p_loggerInfo)
{
constexpr auto logLevelToQuillLogLevel = [](const Flat::LogLevel p_level) constexpr -> quill::LogLevel
{
switch (p_level)
{
case Flat::LogLevel::Debug:
return quill::LogLevel::Debug;
case Flat::LogLevel::Trace:
return quill::LogLevel::TraceL3;
case Flat::LogLevel::Info:
return quill::LogLevel::Info;
case Flat::LogLevel::Warn:
return quill::LogLevel::Warning;
case Flat::LogLevel::Error:
return quill::LogLevel::Error;
case Flat::LogLevel::Critical:
return quill::LogLevel::Critical;
}
return quill::LogLevel::TraceL3;
};
if (quill::Logger* logger = GetLogger(p_loggerInfo))
{
logger->set_log_level(logLevelToQuillLogLevel(p_loggerInfo.m_level));
}
}
/****************************************************************************************/
Log::~Log()
{
for (quill::Logger* logger: quill::Frontend::get_all_loggers())
{
quill::Frontend::remove_logger(logger);
}
quill::Backend::stop();
}
} // namespace Bigfoot
#endif
+98
View File
@@ -0,0 +1,98 @@
/*********************************************************************
* \file MimallocImpl.cpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#include <System/Profiler.hpp>
#if defined BIGFOOT_WINDOWS
#pragma comment(linker, "/include:mi_version")
#pragma warning(disable: 4100 4559)
#elif defined BIGFOOT_LINUX
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#else
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#endif
#endif
// Taken from mimalloc-new-delete.h
// clang-format off
// ----------------------------------------------------------------------------
// This header provides convenient overrides for the new and
// delete operations in C++.
//
// This header should be included in only one source file!
//
// On Windows, or when linking dynamically with mimalloc, these
// can be more performant than the standard new-delete operations.
// See <https://en.cppreference.com/w/cpp/memory/new/operator_new>
// ---------------------------------------------------------------------------
#if defined(__cplusplus)
#include <new>
#include <mimalloc.h>
#if defined(_MSC_VER) && defined(_Ret_notnull_) && defined(_Post_writable_byte_size_)
// stay consistent with VCRT definitions
#define mi_decl_new(n) mi_decl_nodiscard mi_decl_restrict _Ret_notnull_ _Post_writable_byte_size_(n)
#define mi_decl_new_nothrow(n) mi_decl_nodiscard mi_decl_restrict _Ret_maybenull_ _Success_(return != NULL) _Post_writable_byte_size_(n)
#else
#define mi_decl_new(n) mi_decl_nodiscard mi_decl_restrict
#define mi_decl_new_nothrow(n) mi_decl_nodiscard mi_decl_restrict
#endif
void operator delete(void* p) noexcept { mi_free(p); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete[](void* p) noexcept { mi_free(p); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete (void* p, const std::nothrow_t&) noexcept { mi_free(p); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void operator delete[](void* p, const std::nothrow_t&) noexcept { mi_free(p); BIGFOOT_PROFILER_MEMORY_FREE(p); }
mi_decl_new(n) void* operator new(std::size_t n) noexcept(false) { void* p = mi_new(n); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
mi_decl_new(n) void* operator new[](std::size_t n) noexcept(false) { void* p = mi_new(n); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
mi_decl_new_nothrow(n) void* operator new (std::size_t n, const std::nothrow_t& tag) noexcept { (void)(tag); void* p = mi_new_nothrow(n); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
mi_decl_new_nothrow(n) void* operator new[](std::size_t n, const std::nothrow_t& tag) noexcept { (void)(tag); void* p = mi_new_nothrow(n); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
// Not from mimalloc-new-delete.h, but necessary for EASTL
void* operator new[](size_t size, const char* name, int flags, unsigned debugFlags, const char* file, int line) noexcept(false) { void* p = mi_new(size); BIGFOOT_PROFILER_MEMORY_ALLOC(p, size); return p; }
#if (__cplusplus >= 201402L || _MSC_VER >= 1916)
void operator delete (void* p, std::size_t n) noexcept { mi_free_size(p,n); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete[](void* p, std::size_t n) noexcept { mi_free_size(p,n); BIGFOOT_PROFILER_MEMORY_FREE(p); };
#endif
#if (__cplusplus > 201402L || defined(__cpp_aligned_new))
void operator delete (void* p, std::align_val_t al) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void operator delete[](void* p, std::align_val_t al) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void operator delete (void* p, std::size_t n, std::align_val_t al) noexcept { mi_free_size_aligned(p, n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete[](void* p, std::size_t n, std::align_val_t al) noexcept { mi_free_size_aligned(p, n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); };
void operator delete (void* p, std::align_val_t al, const std::nothrow_t&) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void operator delete[](void* p, std::align_val_t al, const std::nothrow_t&) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_FREE(p); }
void* operator new (std::size_t n, std::align_val_t al) noexcept(false) { void* p = mi_new_aligned(n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
void* operator new[](std::size_t n, std::align_val_t al) noexcept(false) { void* p = mi_new_aligned(n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
void* operator new (std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { void* p = mi_new_aligned_nothrow(n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
void* operator new[](std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { void* p = mi_new_aligned_nothrow(n, static_cast<size_t>(al)); BIGFOOT_PROFILER_MEMORY_ALLOC(p, n); return p; }
// Not from mimalloc-new-delete.h, but necessary for EASTL
void* operator new[](size_t size, size_t alignment, size_t alignmentOffset, const char* pName, int flags, unsigned debugFlags, const char* file, int line) noexcept(false) { void* p = mi_new_aligned(size, alignment); BIGFOOT_PROFILER_MEMORY_ALLOC(p, size); return p; }
#endif
#endif
// clang-format on
#if defined BIGFOOT_WINDOWS
#pragma warning(default: 4100 4559)
#elif defined BIGFOOT_LINUX
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER)
#pragma GCC diagnostic pop
#else
#pragma clang diagnostic pop
#endif
#endif
+121
View File
@@ -0,0 +1,121 @@
/*********************************************************************
* \file Time.cpp
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#include <System/Time.hpp>
#include <System/SystemAssertHandler.hpp>
namespace
{
[[nodiscard]]
std::tm GetTimeInfo(const std::time_t& p_time)
{
std::tm timeInfo {};
#ifdef BIGFOOT_WINDOWS
[[maybe_unused]]
const errno_t error = gmtime_s(&timeInfo, &p_time);
if (error != 0)
{
char errnoStr[256];
strerror_s(errnoStr, error);
CRITICAL_ASSERT(Bigfoot::SystemAssertHandler,
false,
"Failed to convert epoch time to calendar time. {}",
errnoStr);
}
#elif BIGFOOT_LINUX
[[maybe_unused]]
const std::tm* error = gmtime_r(&p_time, &timeInfo);
CRITICAL_ASSERT(Bigfoot::SystemAssertHandler, error, "Failed to convert epoch time to calendar time");
#else
static_assert(false, "not implemented");
#endif
return timeInfo;
}
} // namespace
namespace Bigfoot
{
Time::Time(const std::uint64_t p_epoch):
m_epoch(p_epoch),
m_timeInfo(GetTimeInfo(std::chrono::system_clock::to_time_t(
std::chrono::time_point<std::chrono::system_clock> {std::chrono::microseconds {m_epoch}}))),
m_microseconds(std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::time_point<std::chrono::system_clock> {
std::chrono::microseconds {m_epoch}}.time_since_epoch()) %
std::chrono::seconds(1)))
{
}
/****************************************************************************************/
std::uint32_t Time::Year() const
{
return m_timeInfo.tm_year + 1900;
}
/****************************************************************************************/
std::uint32_t Time::Month() const
{
return m_timeInfo.tm_mon + 1;
}
/****************************************************************************************/
std::uint32_t Time::Day() const
{
return m_timeInfo.tm_mday;
}
/****************************************************************************************/
std::uint32_t Time::Hour() const
{
return m_timeInfo.tm_hour;
}
/****************************************************************************************/
std::uint32_t Time::Minute() const
{
return m_timeInfo.tm_min;
}
/****************************************************************************************/
std::uint32_t Time::Second() const
{
return m_timeInfo.tm_sec;
}
/****************************************************************************************/
std::uint32_t Time::Microsecond() const
{
return static_cast<std::uint32_t>(m_microseconds.count());
}
/****************************************************************************************/
std::uint64_t Time::Epoch() const
{
return m_epoch;
}
/****************************************************************************************/
Time Time::Now()
{
const std::chrono::time_point<std::chrono::system_clock> time = std::chrono::system_clock::now();
const std::uint64_t epochInMicroSeconds =
std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();
return Time {epochInMicroSeconds};
}
} // namespace Bigfoot
+27
View File
@@ -0,0 +1,27 @@
/*********************************************************************
* \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
+87
View File
@@ -0,0 +1,87 @@
/*********************************************************************
* \file UUID.cpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#include <System/UUID/UUID.hpp>
namespace Bigfoot
{
UUID UUID::NULL_UUID {"00000000-0000-0000-0000-000000000000"};
/****************************************************************************************/
UUID::UUID():
m_uuid(ms_uuidGenerator())
{
}
/****************************************************************************************/
UUID::UUID(const std::string_view p_string):
UUID(NULL_UUID)
{
if (const std::optional<uuids::uuid> value = uuids::uuid::from_string(p_string); value.has_value())
{
m_uuid = value.value();
}
}
/****************************************************************************************/
UUID::UUID(const std::span<const std::byte, UUID_BYTE_SIZE> p_raw)
{
const std::span<std::uint8_t, UUID_BYTE_SIZE> raw {
const_cast<std::uint8_t*>(std::bit_cast<const std::uint8_t*>(p_raw.data())),
UUID_BYTE_SIZE};
m_uuid = uuids::uuid {raw};
}
/****************************************************************************************/
UUID::operator std::span<const std::byte, UUID::UUID_BYTE_SIZE>() const
{
return m_uuid.as_bytes();
}
/****************************************************************************************/
UUID::operator std::string() const
{
return uuids::to_string(m_uuid);
}
/****************************************************************************************/
UUID::operator bool() const
{
return *this != NULL_UUID;
}
/****************************************************************************************/
bool UUID::operator<(const UUID& p_uuid) const
{
return m_uuid < p_uuid.m_uuid;
}
/****************************************************************************************/
std::mt19937 UUID::GetRandomGenerator()
{
std::random_device randomDevice;
std::array<std::uint32_t, std::mt19937::state_size> seed {};
std::generate(seed.begin(), seed.end(), std::reference_wrapper {randomDevice});
std::seed_seq seedSeq(seed.begin(), seed.end());
return std::mt19937 {seedSeq};
}
/****************************************************************************************/
uuids::uuid_random_generator UUID::GetUUIDGenerator()
{
return uuids::uuid_random_generator {ms_randomGenerator};
}
} // namespace Bigfoot
+15
View File
@@ -0,0 +1,15 @@
get_filename_component(PackageName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${PackageName})
set(PublicDependencies
$<$<CONFIG:Debug,RelWithDebInfo>:cpptrace::cpptrace>)
set(PrivateDependencies)
set(BigfootPublicDependencies)
set(BigfootPrivateDependencies)
bigfoot_create_package_lib(
"${PublicDependencies}"
"${PrivateLibraries}"
"${BigfootPublicDependencies}"
"${BigfootPrivateDependencies}"
"")
@@ -0,0 +1,94 @@
/*********************************************************************
* \file Assert.hpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_UTILS_ASSERT_HPP
#define BIGFOOT_UTILS_ASSERT_HPP
#if defined BIGFOOT_NOT_OPTIMIZED
#include <cpptrace/cpptrace.hpp>
#include <source_location>
#include <string>
#if defined BIGFOOT_LINUX
#include <csignal>
#endif
#if defined BIGFOOT_WINDOWS
#define BREAK \
do \
{ \
__debugbreak(); \
} while (false)
#elif defined BIGFOOT_LINUX
#define BREAK \
do \
{ \
std::raise(SIGTRAP); \
} while (false)
#endif
#define ASSERT(HANDLER, p_assert, p_message, ...) \
do \
{ \
constexpr std::source_location location = std::source_location::current(); \
if (!(p_assert)) [[unlikely]] \
{ \
constexpr auto stacktrace = []() -> std::string \
{ \
const cpptrace::stacktrace stacktrace = cpptrace::generate_trace(); \
return stacktrace.to_string(); \
}; \
\
HANDLER::Handle(location, stacktrace(), p_message __VA_OPT__(, ) __VA_ARGS__); \
BREAK; \
} \
} while (false)
#define SOFT_ASSERT(HANDLER, p_assert, p_message, ...) \
do \
{ \
constexpr std::source_location location = std::source_location::current(); \
if (!(p_assert)) [[unlikely]] \
{ \
constexpr auto stacktrace = []() -> std::string \
{ \
const cpptrace::stacktrace stacktrace = cpptrace::generate_trace(); \
return stacktrace.to_string(); \
}; \
\
HANDLER::Handle(location, stacktrace(), p_message __VA_OPT__(, ) __VA_ARGS__); \
BREAK; \
} \
} while (false)
#define CRITICAL_ASSERT(HANDLER, p_assert, p_message, ...) \
do \
{ \
constexpr std::source_location location = std::source_location::current(); \
if (!(p_assert)) [[unlikely]] \
{ \
constexpr auto stacktrace = []() -> std::string \
{ \
const cpptrace::stacktrace stacktrace = cpptrace::generate_trace(); \
return stacktrace.to_string(); \
}; \
\
HANDLER::Handle(location, stacktrace(), p_message __VA_OPT__(, ) __VA_ARGS__); \
BREAK; \
std::abort(); \
} \
} while (false)
#else
#define ASSERT(HANDLER, p_assert, p_message, ...)
#define SOFT_ASSERT(HANDLER, p_assert, p_message, ...)
#define CRITICAL_ASSERT(HANDLER, p_assert, p_message, ...)
#endif
#endif
@@ -0,0 +1,49 @@
/*********************************************************************
* \file Caster.hpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_UTILS_CASTER_HPP
#define BIGFOOT_UTILS_CASTER_HPP
#include <EASTL/type_traits.h>
namespace Bigfoot
{
template<class TO,
class FROM,
eastl::enable_if_t<eastl::is_base_of_v<FROM, TO> || eastl::is_base_of_v<TO, FROM>, bool> = true>
constexpr TO* Cast(FROM* p_object)
{
return static_cast<TO*>(p_object);
}
template<class TO,
class FROM,
eastl::enable_if_t<eastl::is_base_of_v<FROM, TO> || eastl::is_base_of_v<TO, FROM>, bool> = true>
constexpr const TO* Cast(const FROM* p_object)
{
return static_cast<const TO*>(p_object);
}
template<class TO,
class FROM,
eastl::enable_if_t<eastl::is_base_of_v<FROM, TO> || eastl::is_base_of_v<TO, FROM>, bool> = true>
constexpr TO& Cast(FROM& p_object)
{
return static_cast<TO&>(p_object);
}
template<class TO,
class FROM,
eastl::enable_if_t<eastl::is_base_of_v<FROM, TO> || eastl::is_base_of_v<TO, FROM>, bool> = true>
constexpr const TO& Cast(const FROM& p_object)
{
return static_cast<const TO&>(p_object);
}
} // namespace Bigfoot
#define BIGFOOT_NUMERIC_CAST(p_to, p_data) Bigfoot::NumericCast<p_to>(p_data)
#define BIGFOOT_OBJECT_CAST(p_to, p_object) Bigfoot::Cast<p_to>(p_object)
#endif
@@ -0,0 +1,17 @@
/*********************************************************************
* \file Concat.h
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_UTILS_CONCAT_H
#define BIGFOOT_UTILS_CONCAT_H
#define CONCAT_IMPL(a, b) a b
#define CONCAT(a, b) CONCAT_IMPL(a, b)
#define UNIQUE_IMPL(prefix, line) prefix##_##line
#define UNIQUE(prefix, line) UNIQUE_IMPL(prefix, line)
#define MAKE_UNIQUE_VARIABLE_NAME(prefix) UNIQUE(prefix, __LINE__)
#endif
@@ -0,0 +1,108 @@
/*********************************************************************
* \file Singleton.hpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_UTILS_SINGLETON_HPP
#define BIGFOOT_UTILS_SINGLETON_HPP
#include <EASTL/array.h>
#include <EASTL/bit.h>
#include <EASTL/type_traits.h>
#include <EASTL/utility.h>
namespace Bigfoot
{
template<class TYPE>
class Singleton
{
public:
Singleton() = delete;
Singleton(const Singleton& p_singleton) = delete;
Singleton(Singleton&& p_singleton) = delete;
~Singleton() = delete;
/**
* Get the instance.
*
* \return The instance
*/
static constexpr TYPE& Instance()
{
return *eastl::bit_cast<TYPE*>(ms_instance.data());
}
class Lifetime
{
public:
/**
* Constructor.
*
* \param p_args Arguments for the singleton
*/
template<typename... ARGS,
typename = eastl::enable_if_t<!(eastl::is_same_v<Lifetime, eastl::decay_t<ARGS>> || ...)>>
explicit Lifetime(ARGS&&... p_args)
{
Initialize(eastl::forward<ARGS>(p_args)...);
}
Lifetime(const Lifetime& p_lifetime) = delete;
Lifetime(Lifetime&& p_lifetime) = delete;
~Lifetime()
{
Finalize();
}
[[nodiscard]]
Lifetime& operator=(const Lifetime& p_lifetime) = delete;
[[nodiscard]]
Lifetime& operator=(Lifetime&& p_lifetime) = delete;
};
[[nodiscard]]
Singleton& operator=(const Singleton& p_singleton) = delete;
[[nodiscard]]
Singleton& operator=(Singleton&& p_singleton) = delete;
private:
/**
* Initialize the singleton.
*
* \param p_args Arguments for the singleton
*/
template<typename... ARGS>
static void Initialize(ARGS&&... p_args)
{
new (ms_instance.data()) TYPE(eastl::forward<ARGS>(p_args)...);
ms_initialized = true;
}
/**
* Finalize the singleton.
*
*/
static void Finalize()
{
eastl::bit_cast<TYPE*>(ms_instance.data())->~TYPE();
ms_initialized = false;
}
/**
* The singleton.
*/
alignas(alignof(TYPE)) inline static eastl::array<std::byte, sizeof(TYPE)> ms_instance;
/**
* Is the singleton initialized?
*/
inline static bool ms_initialized = false;
};
} // namespace Bigfoot
#endif
@@ -0,0 +1,131 @@
/*********************************************************************
* \file TaggedType.h
*
* \author Romain BOULLARD
* \date December 2025
*********************************************************************/
#ifndef BIGFOOT_UTILS_TAGGEDTYPE_H
#define BIGFOOT_UTILS_TAGGEDTYPE_H
#include <compare>
namespace Bigfoot
{
template<typename TYPE>
class TaggedType
{
public:
constexpr TaggedType() = default;
constexpr explicit TaggedType(TYPE p_value):
m_value(p_value)
{
}
constexpr TaggedType(const TaggedType& p_taggedType) = default;
constexpr TaggedType(TaggedType&& p_taggedType) noexcept = default;
~TaggedType() = default;
constexpr TaggedType& operator=(const TaggedType& p_taggedType) = default;
constexpr TaggedType& operator=(TaggedType&& p_taggedType) noexcept = default;
constexpr TaggedType& operator=(const TYPE& p_value)
{
m_value = p_value;
return *this;
}
constexpr explicit operator TYPE() const
{
return m_value;
}
constexpr TYPE Get() const
{
return m_value;
}
constexpr auto operator<=>(const TaggedType& p_other) const = default;
constexpr TaggedType& operator+=(const TYPE& p_value)
{
m_value += p_value;
return *this;
}
constexpr TaggedType& operator-=(const TYPE& p_value)
{
m_value -= p_value;
return *this;
}
constexpr TaggedType& operator*=(const TYPE& p_value)
{
m_value *= p_value;
return *this;
}
constexpr TaggedType& operator/=(const TYPE& p_value)
{
m_value /= p_value;
return *this;
}
constexpr TaggedType& operator+=(const TaggedType& p_other)
{
m_value += p_other.m_value;
return *this;
}
constexpr TaggedType& operator-=(const TaggedType& p_other)
{
m_value -= p_other.m_value;
return *this;
}
constexpr TaggedType& operator*=(const TaggedType& p_other)
{
m_value *= p_other.m_value;
return *this;
}
constexpr TaggedType& operator/=(const TaggedType& p_other)
{
m_value /= p_other.m_value;
return *this;
}
template<typename L, typename R>
friend constexpr TaggedType operator+(L p_left, R p_right)
{
return p_left += p_right;
}
template<typename L, typename R>
friend constexpr TaggedType operator-(L p_left, R p_right)
{
return p_left -= p_right;
}
template<typename L, typename R>
friend constexpr TaggedType operator*(L p_left, R p_right)
{
return p_left *= p_right;
}
template<typename L, typename R>
friend constexpr TaggedType operator/(L p_left, R p_right)
{
return p_left /= p_right;
}
private:
/**
* The value
*/
TYPE m_value {};
};
} // namespace Bigfoot
#endif
@@ -0,0 +1,21 @@
/*********************************************************************
* \file TargetMacros.h
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_UTILS_TARGETMACROS_H
#define BIGFOOT_UTILS_TARGETMACROS_H
#if defined BIGFOOT_OPTIMIZED
#define BIGFOOT_OPTIMIZED_ONLY(...) __VA_ARGS__
#define BIGFOOT_NOT_OPTIMIZED_ONLY(...)
#define BIGFOOT_OPTIMIZED_OR_NOT(p_optimized, p_notOptimized) p_optimized
#endif
#if defined BIGFOOT_NOT_OPTIMIZED
#define BIGFOOT_OPTIMIZED_ONLY(...)
#define BIGFOOT_NOT_OPTIMIZED_ONLY(...) __VA_ARGS__
#define BIGFOOT_OPTIMIZED_OR_NOT(p_optimized, p_notOptimized) p_notOptimized
#endif
#endif
@@ -0,0 +1,158 @@
/*********************************************************************
* \file Version.hpp
*
* \author Romain BOULLARD
* \date October 2025
*********************************************************************/
#ifndef BIGFOOT_UTILS_VERSION_HPP
#define BIGFOOT_UTILS_VERSION_HPP
#include <Utils/Caster.hpp>
#include <Utils/TargetMacros.h>
#include <cstdint>
#include <format>
#include <string>
namespace Bigfoot
{
class Version
{
public:
Version() = default;
/**
* Constructor.
*
* \param p_combined The combined version.
*/
explicit constexpr Version(const std::uint32_t p_combined):
m_combined(p_combined)
{
}
/**
* Constructor.
*
* \param p_major Major
* \param p_minor Minor
* \param p_patch Patch
*/
constexpr Version(const std::uint8_t p_major, const std::uint8_t p_minor, const std::uint8_t p_patch):
m_combined((p_major << 16) | (p_minor << 8) | p_patch)
{
}
Version(const Version& p_version) = default;
Version(Version&& p_version) = default;
~Version() = default;
/**
* Get the major part of the version.
*
* \return The major part of the version.
*/
[[nodiscard]]
constexpr std::uint8_t Major() const
{
constexpr std::uint32_t mask = 0b00000000111111110000000000000000;
return static_cast<std::uint8_t>((m_combined & mask) >> 16);
}
/**
* Get the minor part of the version.
*
* \return The minor part of the version.
*/
[[nodiscard]]
constexpr std::uint8_t Minor() const
{
constexpr std::uint32_t mask = 0b00000000000000001111111100000000;
return static_cast<std::uint8_t>((m_combined & mask) >> 8);
}
/**
* Get the patch part of the version.
*
* \return The patch part of the version.
*/
[[nodiscard]]
constexpr std::uint8_t Patch() const
{
constexpr std::uint32_t mask = 0b00000000000000000000000011111111;
return static_cast<std::uint8_t>(m_combined & mask);
}
[[nodiscard]]
constexpr operator std::uint32_t() const
{
return m_combined;
}
operator std::string() const;
constexpr Version& operator=(const Version& p_version) = default;
constexpr Version& operator=(Version&& p_version) = default;
[[nodiscard]]
constexpr bool operator>(const Version& p_version) const
{
return m_combined > p_version.m_combined;
}
[[nodiscard]]
constexpr bool operator<(const Version& p_version) const
{
return m_combined < p_version.m_combined;
}
[[nodiscard]]
constexpr bool operator>=(const Version& p_version) const
{
return m_combined >= p_version.m_combined;
}
[[nodiscard]]
constexpr bool operator<=(const Version& p_version) const
{
return m_combined <= p_version.m_combined;
}
[[nodiscard]]
constexpr bool operator==(const Version& p_version) const = default;
[[nodiscard]]
constexpr bool operator!=(const Version& p_version) const = default;
private:
/**
* The combined version.
*/
std::uint32_t m_combined = 0;
};
} // namespace Bigfoot
/****************************************************************************************/
#if defined BIGFOOT_NOT_OPTIMIZED
template<>
struct std::formatter<Bigfoot::Version>
{
template<typename ParseContext>
constexpr auto parse(ParseContext& p_context)
{
return p_context.begin();
}
template<typename FormatContext>
auto format(const Bigfoot::Version& p_version, FormatContext& p_context) const
{
return std::format_to(p_context.out(), "{}", static_cast<std::string>(p_version));
}
};
#endif
#endif
+15
View File
@@ -0,0 +1,15 @@
/*********************************************************************
* \file Version.cpp
*
* \author Romain BOULLARD
* \date January 2023
*********************************************************************/
#include <Utils/Version.hpp>
namespace Bigfoot
{
Version::operator std::string() const
{
return std::format("{}.{}.{}", Major(), Minor(), Patch());
}
} // namespace Bigfoot