/*********************************************************************
 * \file   EngineAssertHandler.hpp
 *
 * \author Romain BOULLARD
 * \date   December 2025
 *********************************************************************/
#ifndef BIGFOOT_ENGINE_ENGINEASSERTHANDLER_HPP
#define BIGFOOT_ENGINE_ENGINEASSERTHANDLER_HPP
#include <Engine/EngineLogger_generated.hpp>

#include <Utils/Assert.hpp>

#if defined BIGFOOT_NOT_OPTIMIZED

#include <format>
#include <source_location>

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_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(ENGINE_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());
    }

    EngineAssertHandler& operator=(const EngineAssertHandler& p_handler) = delete;
    EngineAssertHandler& operator=(EngineAssertHandler&& p_handler) = delete;
};
}   // namespace Bigfoot
#endif
#endif
