/*********************************************************************
 * \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
