Changeset 196:90c862451791 in rrlib_math
- Timestamp:
- 23.03.2020 22:58:50 (3 years ago)
- Branch:
- 17.03
- Phase:
- public
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
rtti.cpp
r193 r196 35 35 //---------------------------------------------------------------------- 36 36 #include "rrlib/rtti/tStaticTypeRegistration.h" 37 #include "rrlib/util/string.h" 37 38 38 39 //---------------------------------------------------------------------- … … 61 62 62 63 tStaticTypeRegistration 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>(). 69 73 Add<tMat2x2d>("Matrix2x2d"). 70 74 Add<tMat3x3d>("Matrix3x3d"). … … 114 118 } 115 119 120 util::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 116 151 } 117 152 118 153 namespace rtti 119 154 { 155 156 // angle/rtti.h 120 157 template class detail::tDataTypeInfo<math::tAngle<double, math::angle::Radian, math::angle::Signed>>; 121 158 template class detail::tDataTypeInfo<math::tAngle<double, math::angle::Degree, math::angle::Signed>>; … … 143 180 template class detail::tDataTypeInfo<std::vector<math::tAngle<float, math::angle::Radian, math::angle::NoWrap>>>; 144 181 template class detail::tDataTypeInfo<std::vector<math::tAngle<float, math::angle::Degree, math::angle::NoWrap>>>; 182 183 // vector/rtti.h 184 template class detail::tDataTypeInfo<math::tVector<2, double, math::vector::Cartesian>>; 185 template class detail::tDataTypeInfo<math::tVector<3, double, math::vector::Cartesian>>; 186 template class detail::tDataTypeInfo<math::tVector<6, double, math::vector::Cartesian>>; 187 template class detail::tDataTypeInfo<math::tVector<2, float, math::vector::Cartesian>>; 188 template class detail::tDataTypeInfo<math::tVector<3, float, math::vector::Cartesian>>; 189 template class detail::tDataTypeInfo<math::tVector<6, float, math::vector::Cartesian>>; 190 template class detail::tDataTypeInfo<math::tVector<2, int, math::vector::Cartesian>>; 191 template class detail::tDataTypeInfo<math::tVector<3, int, math::vector::Cartesian>>; 192 template class detail::tDataTypeInfo<math::tVector<6, int, math::vector::Cartesian>>; 193 194 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<2, double, math::vector::Cartesian>>::type>; 195 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<3, double, math::vector::Cartesian>>::type>; 196 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<6, double, math::vector::Cartesian>>::type>; 197 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<2, float, math::vector::Cartesian>>::type>; 198 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<3, float, math::vector::Cartesian>>::type>; 199 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<6, float, math::vector::Cartesian>>::type>; 200 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<2, int, math::vector::Cartesian>>::type>; 201 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<3, int, math::vector::Cartesian>>::type>; 202 template class detail::tDataTypeInfo<typename UnderlyingType<math::tVector<6, int, math::vector::Cartesian>>::type>; 203 204 template class detail::tDataTypeInfo<std::vector<math::tVector<2, double, math::vector::Cartesian>>>; 205 template class detail::tDataTypeInfo<std::vector<math::tVector<3, double, math::vector::Cartesian>>>; 206 template class detail::tDataTypeInfo<std::vector<math::tVector<6, double, math::vector::Cartesian>>>; 207 template class detail::tDataTypeInfo<std::vector<math::tVector<2, float, math::vector::Cartesian>>>; 208 template class detail::tDataTypeInfo<std::vector<math::tVector<3, float, math::vector::Cartesian>>>; 209 template class detail::tDataTypeInfo<std::vector<math::tVector<6, float, math::vector::Cartesian>>>; 210 template class detail::tDataTypeInfo<std::vector<math::tVector<2, int, math::vector::Cartesian>>>; 211 template class detail::tDataTypeInfo<std::vector<math::tVector<3, int, math::vector::Cartesian>>>; 212 template class detail::tDataTypeInfo<std::vector<math::tVector<6, int, math::vector::Cartesian>>>; 213 214 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<2, double, math::vector::Cartesian>>>::type>; 215 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<3, double, math::vector::Cartesian>>>::type>; 216 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<6, double, math::vector::Cartesian>>>::type>; 217 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<2, float, math::vector::Cartesian>>>::type>; 218 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<3, float, math::vector::Cartesian>>>::type>; 219 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<6, float, math::vector::Cartesian>>>::type>; 220 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<2, int, math::vector::Cartesian>>>::type>; 221 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<3, int, math::vector::Cartesian>>>::type>; 222 template class detail::tDataTypeInfo<typename UnderlyingType<std::vector<math::tVector<6, int, math::vector::Cartesian>>>::type>; 223 145 224 } 146 225 -
tVector.h
r166 r196 84 84 85 85 #include "rrlib/math/vector/functions.h" 86 #include "rrlib/math/vector/rtti.h" 86 87 87 88 #undef __rrlib_math__vector__include_guard__ -
vector/tVector.h
r184 r196 43 43 //---------------------------------------------------------------------- 44 44 #include <functional> 45 46 #ifdef _LIB_RRLIB_RTTI_PRESENT_47 #include "rrlib/rtti/rtti.h"48 #endif49 45 50 46 //---------------------------------------------------------------------- … … 129 125 //---------------------------------------------------------------------- 130 126 } 131 132 #ifdef _LIB_RRLIB_RTTI_PRESENT_133 namespace rtti134 {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 #endif149 150 127 } 151 128
Note: See TracChangeset
for help on using the changeset viewer.