#ifndef Magnum_DimensionTraits_h #define Magnum_DimensionTraits_h /* This file is part of Magnum. Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "Math/Math.h" #include "Types.h" /** @file * @brief Class Magnum::DimensionTraits */ namespace Magnum { /** @brief Matrix and vector specializations for given dimension count */ template struct DimensionTraits { DimensionTraits() = delete; #ifdef DOXYGEN_GENERATING_OUTPUT /** * @brief Vector type * * Math::Vector, Math::Vector2 or Math::Vector3 based on dimension count. */ typedef U VectorType; /** * @brief Matrix type * * Floating-point Math::Matrix3 or Math::Matrix4 for 2D or 3D. No matrix * type defined for one dimension and integral types. */ typedef U MatrixType; #endif }; /** @todo `using VectorTypeForDimension = typename DimensionTraits::VectorType` etc. shortcuts when support for GCC 4.6 is dropped (similarly to what C++14 does with type traits) */ #ifndef DOXYGEN_GENERATING_OUTPUT /* One dimension */ template struct DimensionTraits<1, T> { DimensionTraits() = delete; typedef Math::Vector<1, T> VectorType; }; /* Two dimensions - integral */ template struct DimensionTraits<2, T> { DimensionTraits() = delete; typedef Math::Vector2 VectorType; }; /* Two dimensions - floating-point */ template<> struct DimensionTraits<2, Float> { DimensionTraits() = delete; typedef Math::Vector2 VectorType; typedef Math::Matrix3 MatrixType; }; #ifndef MAGNUM_TARGET_GLES template<> struct DimensionTraits<2, Double> { DimensionTraits() = delete; typedef Math::Vector2 VectorType; typedef Math::Matrix3 MatrixType; }; #endif /* Three dimensions - integral */ template struct DimensionTraits<3, T> { DimensionTraits() = delete; typedef Math::Vector3 VectorType; }; /* Three dimensions - floating-point */ template<> struct DimensionTraits<3, Float> { DimensionTraits() = delete; typedef Math::Vector3 VectorType; typedef Math::Matrix4 MatrixType; }; #ifndef MAGNUM_TARGET_GLES template<> struct DimensionTraits<3, Double> { DimensionTraits() = delete; typedef Math::Vector3 VectorType; typedef Math::Matrix4 MatrixType; }; #endif #endif } #endif