From 4cd1ee140e89a6d7cf3d4b88ab957ee6c8b7a6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 22 May 2012 15:01:02 +0200 Subject: [PATCH] Removed Math::TypeTraits to MathTypeTraits to avoid name clash. --- src/Math/{TypeTraits.h => MathTypeTraits.h} | 38 +++++++++---------- src/Math/Matrix.h | 2 +- src/Math/Test/CMakeLists.txt | 2 +- ...eTraitsTest.cpp => MathTypeTraitsTest.cpp} | 24 ++++++------ ...{TypeTraitsTest.h => MathTypeTraitsTest.h} | 6 +-- src/Math/Vector.h | 4 +- src/TypeTraits.h | 24 ++++++------ 7 files changed, 50 insertions(+), 50 deletions(-) rename src/Math/{TypeTraits.h => MathTypeTraits.h} (67%) rename src/Math/Test/{TypeTraitsTest.cpp => MathTypeTraitsTest.cpp} (63%) rename src/Math/Test/{TypeTraitsTest.h => MathTypeTraitsTest.h} (86%) diff --git a/src/Math/TypeTraits.h b/src/Math/MathTypeTraits.h similarity index 67% rename from src/Math/TypeTraits.h rename to src/Math/MathTypeTraits.h index 6f7050df2..06e0f746d 100644 --- a/src/Math/TypeTraits.h +++ b/src/Math/MathTypeTraits.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Math_TypeTraits_h -#define Magnum_Math_TypeTraits_h +#ifndef Magnum_Math_MathTypeTraits_h +#define Magnum_Math_MathTypeTraits_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Math::TypeTraits + * @brief Class Magnum::Math::MathTypeTraits */ #include @@ -44,7 +44,7 @@ This class and class methods are specialized only for types where it makes sense, it has empty implementation for unknown types or types which don't support given feature, thus forcing the compilation stop with an error. */ -template struct TypeTraits { +template struct MathTypeTraits { #ifdef DOXYGEN_GENERATING_OUTPUT /* Development note: the following values are implemented as inline functions, not as static const variables, because the compiler will @@ -79,39 +79,39 @@ template struct TypeTraits { */ #ifndef DOXYGEN_GENERATING_OUTPUT -template struct _TypeTraitsIntegral { +template struct _MathTypeTraitsIntegral { constexpr inline static T epsilon() { return 1; } inline constexpr static bool equals(T a, T b) { return a == b; } }; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; /* long is 32 bits somewhere and 64 bits elsewhere, so it cannot be mapped to any of them */ -template<> struct TypeTraits: public _TypeTraitsIntegral {}; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; -template<> struct TypeTraits: public _TypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; +template<> struct MathTypeTraits: public _MathTypeTraitsIntegral {}; -template struct _TypeTraitsFloatingPoint { +template struct _MathTypeTraitsFloatingPoint { inline static bool equals(T a, T b) { - return std::abs(a - b) < TypeTraits::epsilon(); + return std::abs(a - b) < MathTypeTraits::epsilon(); } }; -template<> struct TypeTraits: public _TypeTraitsFloatingPoint { +template<> struct MathTypeTraits: public _MathTypeTraitsFloatingPoint { constexpr inline static float epsilon() { return FLOAT_EQUALITY_PRECISION; } }; -template<> struct TypeTraits: public _TypeTraitsFloatingPoint { +template<> struct MathTypeTraits: public _MathTypeTraitsFloatingPoint { constexpr inline static double epsilon() { return DOUBLE_EQUALITY_PRECISION; } }; #endif diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index f265d309b..d77a35e9c 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -158,7 +158,7 @@ template class Matrix { /** @brief Equality operator */ inline bool operator==(const Matrix& other) const { for(size_t i = 0; i != size*size; ++i) - if(!TypeTraits::equals(_data[i], other._data[i])) return false; + if(!MathTypeTraits::equals(_data[i], other._data[i])) return false; return true; } diff --git a/src/Math/Test/CMakeLists.txt b/src/Math/Test/CMakeLists.txt index ec2adac6f..05f843a62 100644 --- a/src/Math/Test/CMakeLists.txt +++ b/src/Math/Test/CMakeLists.txt @@ -1,4 +1,4 @@ -corrade_add_test(MathTypeTraitsTest TypeTraitsTest.h TypeTraitsTest.cpp) +corrade_add_test(MathMathTypeTraitsTest MathTypeTraitsTest.h MathTypeTraitsTest.cpp) corrade_add_test(MathVectorTest VectorTest.h VectorTest.cpp ${CORRADE_UTILITY_LIBRARY}) corrade_add_test(MathVector2Test Vector2Test.h Vector2Test.cpp ${CORRADE_UTILITY_LIBRARY}) diff --git a/src/Math/Test/TypeTraitsTest.cpp b/src/Math/Test/MathTypeTraitsTest.cpp similarity index 63% rename from src/Math/Test/TypeTraitsTest.cpp rename to src/Math/Test/MathTypeTraitsTest.cpp index 1be3e6da8..126a36186 100644 --- a/src/Math/Test/TypeTraitsTest.cpp +++ b/src/Math/Test/MathTypeTraitsTest.cpp @@ -13,17 +13,17 @@ GNU Lesser General Public License version 3 for more details. */ -#include "TypeTraitsTest.h" +#include "MathTypeTraitsTest.h" #include -#include "TypeTraits.h" +#include "MathTypeTraits.h" -QTEST_APPLESS_MAIN(Magnum::Math::Test::TypeTraitsTest) +QTEST_APPLESS_MAIN(Magnum::Math::Test::MathTypeTraitsTest) namespace Magnum { namespace Math { namespace Test { -void TypeTraitsTest::equalsIntegral() { +void MathTypeTraitsTest::equalsIntegral() { _equalsIntegral(); _equalsIntegral(); _equalsIntegral(); @@ -36,23 +36,23 @@ void TypeTraitsTest::equalsIntegral() { _equalsIntegral(); } -void TypeTraitsTest::equalsFloatingPoint() { +void MathTypeTraitsTest::equalsFloatingPoint() { _equalsFloatingPoint(); _equalsFloatingPoint(); } -template void TypeTraitsTest::_equalsIntegral() { - QVERIFY(!TypeTraits::equals(1, 1+TypeTraits::epsilon())); +template void MathTypeTraitsTest::_equalsIntegral() { + QVERIFY(!MathTypeTraits::equals(1, 1+MathTypeTraits::epsilon())); } -template void TypeTraitsTest::_equalsFloatingPoint() { - QVERIFY(TypeTraits::equals(1.0f+TypeTraits::epsilon()/2, 1.0f)); - QVERIFY(!TypeTraits::equals(1.0f+TypeTraits::epsilon()*2, 1.0f)); +template void MathTypeTraitsTest::_equalsFloatingPoint() { + QVERIFY(MathTypeTraits::equals(1.0f+MathTypeTraits::epsilon()/2, 1.0f)); + QVERIFY(!MathTypeTraits::equals(1.0f+MathTypeTraits::epsilon()*2, 1.0f)); QEXPECT_FAIL(0, "Comparing to infinity is broken", Continue); - QVERIFY(TypeTraits::equals(std::numeric_limits::infinity(), + QVERIFY(MathTypeTraits::equals(std::numeric_limits::infinity(), std::numeric_limits::infinity())); - QVERIFY(!TypeTraits::equals(std::numeric_limits::quiet_NaN(), + QVERIFY(!MathTypeTraits::equals(std::numeric_limits::quiet_NaN(), std::numeric_limits::quiet_NaN())); } diff --git a/src/Math/Test/TypeTraitsTest.h b/src/Math/Test/MathTypeTraitsTest.h similarity index 86% rename from src/Math/Test/TypeTraitsTest.h rename to src/Math/Test/MathTypeTraitsTest.h index 426071a6d..9ea28afc2 100644 --- a/src/Math/Test/TypeTraitsTest.h +++ b/src/Math/Test/MathTypeTraitsTest.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Math_Test_TypeTraitsTest_h -#define Magnum_Math_Test_TypeTraitsTest_h +#ifndef Magnum_Math_Test_MathTypeTraitsTest_h +#define Magnum_Math_Test_MathTypeTraitsTest_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -19,7 +19,7 @@ namespace Magnum { namespace Math { namespace Test { -class TypeTraitsTest: public QObject { +class MathTypeTraitsTest: public QObject { Q_OBJECT private slots: diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 46a2dc8b2..c49c4d2f5 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -22,7 +22,7 @@ #include #include "Utility/Debug.h" -#include "TypeTraits.h" +#include "MathTypeTraits.h" namespace Magnum { namespace Math { @@ -145,7 +145,7 @@ template class Vector { /** @brief Equality operator */ inline bool operator==(const Vector& other) const { for(size_t pos = 0; pos != size; ++pos) - if(!TypeTraits::equals((*this)[pos], other[pos])) return false; + if(!MathTypeTraits::equals((*this)[pos], other[pos])) return false; return true; } diff --git a/src/TypeTraits.h b/src/TypeTraits.h index 76e06ae25..906583f7e 100644 --- a/src/TypeTraits.h +++ b/src/TypeTraits.h @@ -26,13 +26,13 @@ namespace Magnum { /** @brief Traits class for plain OpenGL types -@copydetails Math::TypeTraits +@copydetails Math::MathTypeTraits -Where it makes sense, this class extends Math::TypeTraits with OpenGL-specific -traits. +Where it makes sense, this class extends Math::MathTypeTraits with +OpenGL-specific traits. */ #ifdef DOXYGEN_GENERATING_OUTPUT -template struct TypeTraits: public Math::TypeTraits { +template struct TypeTraits: public Math::MathTypeTraits { /** * @brief OpenGL plain type ID * @@ -146,7 +146,7 @@ template<> struct TypeOf { typedef GLint Type; }; template<> struct TypeOf { typedef GLfloat Type; }; template<> struct TypeOf { typedef GLdouble Type; }; -template<> struct TypeTraits: public Math::TypeTraits { +template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::UnsignedByte; } inline constexpr static Type indexType() { return Type::UnsignedByte; } inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedByte; } @@ -154,7 +154,7 @@ template<> struct TypeTraits: public Math::TypeTraits { inline constexpr static size_t count() { return 1; } }; -template<> struct TypeTraits: public Math::TypeTraits { +template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Byte; } /* Can not be used for indices */ inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Byte; } @@ -162,7 +162,7 @@ template<> struct TypeTraits: public Math::TypeTraits { inline constexpr static size_t count() { return 1; } }; -template<> struct TypeTraits: public Math::TypeTraits { +template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::UnsignedShort; } inline constexpr static Type indexType() { return Type::UnsignedShort; } inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedShort; } @@ -170,7 +170,7 @@ template<> struct TypeTraits: public Math::TypeTraits inline constexpr static size_t count() { return 1; } }; -template<> struct TypeTraits: public Math::TypeTraits { +template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Short; } /* Can not be used for indices */ inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Short; } @@ -178,7 +178,7 @@ template<> struct TypeTraits: public Math::TypeTraits { inline constexpr static size_t count() { return 1; } }; -template<> struct TypeTraits: public Math::TypeTraits { +template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::UnsignedInt; } inline constexpr static Type indexType() { return Type::UnsignedInt; } inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedInt; } @@ -186,7 +186,7 @@ template<> struct TypeTraits: public Math::TypeTraits { inline constexpr static size_t count() { return 1; } }; -template<> struct TypeTraits: public Math::TypeTraits { +template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Int; } /* Can not be used for indices */ inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Int; } @@ -194,7 +194,7 @@ template<> struct TypeTraits: public Math::TypeTraits { inline constexpr static size_t count() { return 1; } }; -template<> struct TypeTraits: public Math::TypeTraits { +template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Float; } /* Can not be used for indices */ inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Float; } @@ -202,7 +202,7 @@ template<> struct TypeTraits: public Math::TypeTraits { inline constexpr static size_t count() { return 1; } }; -template<> struct TypeTraits: public Math::TypeTraits { +template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Double; } /* Can not be used for indices */ /* Can not be used for images */