/*********************************************************************
 * \file   UtilsAssertHandler.hpp
 *
 * \author Romain BOULLARD
 * \date   May 2026
 *********************************************************************/
#ifndef BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
#define BIGFOOT_UTILS_UTILSASSERTHANDLER_HPP
#include <Utils/Assert.hpp>
#include <Utils/UtilsLogger_generated.hpp>

#if defined BIGFOOT_NOT_OPTIMIZED

#include <format>
#include <source_location>

namespace Bigfoot
{
class UtilsAssertHandler
{
  public:
    UtilsAssertHandler() = delete;

    UtilsAssertHandler(const UtilsAssertHandler& p_handler) = delete;
    UtilsAssertHandler(UtilsAssertHandler&& p_handler) = delete;

    ~UtilsAssertHandler() = 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(UTILS_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());
    }

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