// =====================================================================================================================
//  fennec, a free and open source game engine
//  Copyright © 2025 - 2026  Medusa Slockbower
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================

///
/// \file fennec/math/vector_traits.h
/// \brief
///
///
/// \details this header implements functions to test vector types at compile time
/// \author Medusa Slockbower
///
/// \copyright Copyright © 2025 - 2026 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
///
///

#ifndef FENNEC_MATH_VECTOR_TRAITS_H
#define FENNEC_MATH_VECTOR_TRAITS_H

///
/// \page fennec_math_vector_traits Vector Traits
///
/// \brief Part of the fennec math library. This header defines structures for metaprogramming with vectors.
///
/// \code #include <fennec/math/vector_traits.h> \endcode
///
///
/// <table width="100%" class="fieldtable" id="table_fennec_math_ext_constants">
/// <tr><th style="vertical-align: top">Syntax
///     <th style="vertical-align: top">Description
/// <tr><td width="50%" style="vertical-align: top"> <br>
///         \ref fennec::is_vector "is_vector<TypeT>::value"<br>
///         \ref fennec::is_vector_v "is_vector_v<TypeT>"
///     <td width="50%" style="vertical-align: top">
///         \copydetails fennec::is_vector
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
///         \ref fennec::component_count "component_count<TypeT>::value"<br>
///         \ref fennec::component_count_v "component_count_v<TypeT>"
///     <td width="50%" style="vertical-align: top">
///         \copydetails fennec::component_count
///
/// <tr><td width="50%" style="vertical-align: top"> <br>
///         \ref fennec::total_component_count "total_component_count<TypeT>::value"<br>
///         \ref fennec::total_component_count_v "total_component_count_v<TypeT>"
///     <td width="50%" style="vertical-align: top">
///         \copydetails fennec::total_component_count
///
/// </table>
///

#include <fennec/math/detail/_vector_traits.h>

namespace fennec
{

///
/// \brief check if \p T is a fennec::vector type
/// \tparam T type to check
template<typename T> struct is_vector : detail::_is_vector_helper<remove_cvref_t<T>>{};

///
/// \brief shorthand for `(.*?)`
/// \tparam T type to check
template<typename T> constexpr bool is_vector_v = is_vector<T>::value;

///
/// \brief Get the number of Components in \p T, returns 1 for types that pass `(.*?)`, returns \ref vector::N for \ref vector "Vector" Types, and returns 0 for all other cases
/// \tparam T type to check
template<typename T> struct component_count : detail::_component_count_helper<remove_cvref_t<T>>{};

///
/// \brief shorthand for `(.*?)`
/// \tparam T type to get the component count of
template<typename T> constexpr size_t component_count_v = component_count<T>::value;

///
/// \brief Get the total number of Components among types in \p TypesT
/// \tparam Ts types to accumulate the count of
template<typename...Ts> struct total_component_count : integral_constant<size_t, (component_count_v<Ts> + ...)>{};

// Override for empty list
template<> struct total_component_count<> : integral_constant<size_t, 0>{};

///
/// \brief shorthand for `(.*?)`
/// \tparam Ts types to accumulate the count of
template<typename...Ts> constexpr size_t total_component_count_v = total_component_count<Ts...>::value;


}

#endif // FENNEC_MATH_VECTOR_TRAITS_H
