Changeset 196:90c862451791 in rrlib_math


Ignore:
Timestamp:
23.03.2020 22:58:50 (12 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Message:

Adds explicit template rrlib_rtti tDataTypeInfo instantiations for various vector types

Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • rtti.cpp

    r193 r196  
    3535//---------------------------------------------------------------------- 
    3636#include "rrlib/rtti/tStaticTypeRegistration.h" 
     37#include "rrlib/util/string.h" 
    3738 
    3839//---------------------------------------------------------------------- 
     
    6162 
    6263tStaticTypeRegistration init_type = tStaticTypeRegistration("rrlib_math"). 
    63                                     Add<tVec2d>("Vector2d"). 
    64                                     Add<tVec3d>("Vector3d"). 
    65                                     Add<tVec6d>("Vector6d"). 
    66                                     Add<tVec2i>("Vector2i"). 
    67                                     Add<tVec3i>("Vector3i"). 
    68                                     Add<tVec6i>("Vector6i"). 
     64                                    Add<tVec2d>(). 
     65                                    Add<tVec3d>(). 
     66                                    Add<tVec6d>(). 
     67                                    Add<tVec2f>(). 
     68                                    Add<tVec3f>(). 
     69                                    Add<tVec6f>(). 
     70                                    Add<tVec2i>(). 
     71                                    Add<tVec3i>(). 
     72                                    Add<tVec6i>(). 
    6973                                    Add<tMat2x2d>("Matrix2x2d"). 
    7074                                    Add<tMat3x3d>("Matrix3x3d"). 
     
    114118} 
    115119 
     120util::tManagedConstCharPointer GetRRLibRttiCartesianVectorTypeName(const tType& type) 
     121{ 
     122  auto rrlib_rtti_name = rrlib::rtti::detail::tTypeInfo::GetDefaultTypeNameFromRttiName(type.GetRttiName()); 
     123  std::string rrlib_rtti_name_string(rrlib_rtti_name.Get()); 
     124  if (rrlib_rtti_name_string.find("<") == std::string::npos) 
     125  { 
     126    return rrlib_rtti_name; 
     127  } 
     128 
     129  std::stringstream result; 
     130  result << "Vector"; 
     131 
     132  std::string template_arguments = rrlib_rtti_name_string.substr(rrlib_rtti_name_string.find("<") + 1); 
     133  std::vector<std::string> tokens; 
     134  util::Tokenize(template_arguments, tokens, ","); 
     135  if (tokens.size() < 2) 
     136  { 
     137    return rrlib_rtti_name; 
     138  } 
     139  util::TrimWhitespace(tokens[0]); 
     140  util::TrimWhitespace(tokens[1]); 
     141  size_t dimension_length = 1; 
     142  while (tokens[0].length() > dimension_length && std::isdigit(tokens[0][dimension_length])) 
     143  { 
     144    dimension_length++; 
     145  } 
     146  result << tokens[0].substr(0, dimension_length) << tokens[1][0]; 
     147  //std::cout << "Generated " << result.str() << "\n" << tokens[0]; 
     148  return util::tManagedConstCharPointer(result.str().c_str(), true); 
     149} 
     150 
    116151} 
    117152 
    118153namespace rtti 
    119154{ 
     155 
     156// angle/rtti.h 
    120157template class detail::tDataTypeInfo<math::tAngle<double, math::angle::Radian, math::angle::Signed>>; 
    121158template class detail::tDataTypeInfo<math::tAngle<double, math::angle::Degree, math::angle::Signed>>; 
     
    143180template class detail::tDataTypeInfo<std::vector<math::tAngle<float, math::angle::Radian, math::angle::NoWrap>>>; 
    144181template class detail::tDataTypeInfo<std::vector<math::tAngle<float, math::angle::Degree, math::angle::NoWrap>>>; 
     182 
     183// vector/rtti.h 
     184template class detail::tDataTypeInfo<math::tVector<2, double, math::vector::Cartesian>>; 
     185template class detail::tDataTypeInfo<math::tVector<3, double, math::vector::Cartesian>>; 
     186template class detail::tDataTypeInfo<math::tVector<6, double, math::vector::Cartesian>>; 
     187template class detail::tDataTypeInfo<math::tVector<2, float, math::vector::Cartesian>>; 
     188template class detail::tDataTypeInfo<math::tVector<3, float, math::vector::Cartesian>>; 
     189template class detail::tDataTypeInfo<math::tVector<6, float, math::vector::Cartesian>>; 
     190template class detail::tDataTypeInfo<math::tVector<2, int, math::vector::Cartesian>>; 
     191template class detail::tDataTypeInfo<math::tVector<3, int, math::vector::Cartesian>>; 
     192template class detail::tDataTypeInfo<math::tVector<6, int, math::vector::Cartesian>>; 
     193 
     194template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<2, double, math::vector::Cartesian>>::type>; 
     195template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<3, double, math::vector::Cartesian>>::type>; 
     196template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<6, double, math::vector::Cartesian>>::type>; 
     197template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<2, float, math::vector::Cartesian>>::type>; 
     198template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<3, float, math::vector::Cartesian>>::type>; 
     199template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<6, float, math::vector::Cartesian>>::type>; 
     200template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<2, int, math::vector::Cartesian>>::type>; 
     201template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<3, int, math::vector::Cartesian>>::type>; 
     202template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<6, int, math::vector::Cartesian>>::type>; 
     203 
     204template class detail::tDataTypeInfo<std::vector<math::tVector<2, double, math::vector::Cartesian>>>; 
     205template class detail::tDataTypeInfo<std::vector<math::tVector<3, double, math::vector::Cartesian>>>; 
     206template class detail::tDataTypeInfo<std::vector<math::tVector<6, double, math::vector::Cartesian>>>; 
     207template class detail::tDataTypeInfo<std::vector<math::tVector<2, float, math::vector::Cartesian>>>; 
     208template class detail::tDataTypeInfo<std::vector<math::tVector<3, float, math::vector::Cartesian>>>; 
     209template class detail::tDataTypeInfo<std::vector<math::tVector<6, float, math::vector::Cartesian>>>; 
     210template class detail::tDataTypeInfo<std::vector<math::tVector<2, int, math::vector::Cartesian>>>; 
     211template class detail::tDataTypeInfo<std::vector<math::tVector<3, int, math::vector::Cartesian>>>; 
     212template class detail::tDataTypeInfo<std::vector<math::tVector<6, int, math::vector::Cartesian>>>; 
     213 
     214template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<2, double, math::vector::Cartesian>>>::type>; 
     215template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<3, double, math::vector::Cartesian>>>::type>; 
     216template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<6, double, math::vector::Cartesian>>>::type>; 
     217template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<2, float, math::vector::Cartesian>>>::type>; 
     218template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<3, float, math::vector::Cartesian>>>::type>; 
     219template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<6, float, math::vector::Cartesian>>>::type>; 
     220template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<2, int, math::vector::Cartesian>>>::type>; 
     221template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<3, int, math::vector::Cartesian>>>::type>; 
     222template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<6, int, math::vector::Cartesian>>>::type>; 
     223 
    145224} 
    146225 
  • tVector.h

    r166 r196  
    8484 
    8585#include "rrlib/math/vector/functions.h" 
     86#include "rrlib/math/vector/rtti.h" 
    8687 
    8788#undef __rrlib_math__vector__include_guard__ 
  • vector/tVector.h

    r184 r196  
    4343//---------------------------------------------------------------------- 
    4444#include <functional> 
    45  
    46 #ifdef _LIB_RRLIB_RTTI_PRESENT_ 
    47 #include "rrlib/rtti/rtti.h" 
    48 #endif 
    4945 
    5046//---------------------------------------------------------------------- 
     
    129125//---------------------------------------------------------------------- 
    130126} 
    131  
    132 #ifdef _LIB_RRLIB_RTTI_PRESENT_ 
    133 namespace rtti 
    134 { 
    135 template <size_t Tdimension, typename TElement, template <size_t, typename, typename ...> class TData, typename ... TAdditionalDataParameters> 
    136 struct UnderlyingType<math::tVector<Tdimension, TElement, TData, TAdditionalDataParameters...>> 
    137 { 
    138   typedef math::tVector<Tdimension, TElement, TData, TAdditionalDataParameters...> tInternalVectorType; 
    139  
    140   typedef std::array<TElement, Tdimension> type; 
    141   static_assert(sizeof(type) == sizeof(tInternalVectorType), "Invalid trait implementation"); 
    142   enum { cREVERSE_CAST_VALID = true }; 
    143   enum { cBINARY_SERIALIZATION_DIFFERS = false }; 
    144   enum { cOTHER_SERIALIZATION_DIFFERS = true }; 
    145   enum { cINHERITS_ELEMENT_ACCESS_CONVERSION_OPERATIONS = true }; 
    146 }; 
    147 } 
    148 #endif 
    149  
    150127} 
    151128 
Note: See TracChangeset for help on using the changeset viewer.