00001 /*M/////////////////////////////////////////////////////////////////////////////////////// 00002 // 00003 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 00004 // 00005 // By downloading, copying, installing or using the software you agree to this license. 00006 // If you do not agree to this license, do not download, install, 00007 // copy or use the software. 00008 // 00009 // 00010 // License Agreement 00011 // For Open Source Computer Vision Library 00012 // 00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 00015 // Third party copyrights are property of their respective owners. 00016 // 00017 // Redistribution and use in source and binary forms, with or without modification, 00018 // are permitted provided that the following conditions are met: 00019 // 00020 // * Redistribution's of source code must retain the above copyright notice, 00021 // this list of conditions and the following disclaimer. 00022 // 00023 // * Redistribution's in binary form must reproduce the above copyright notice, 00024 // this list of conditions and the following disclaimer in the documentation 00025 // and/or other materials provided with the distribution. 00026 // 00027 // * The name of the copyright holders may not be used to endorse or promote products 00028 // derived from this software without specific prior written permission. 00029 // 00030 // This software is provided by the copyright holders and contributors "as is" and 00031 // any express or implied warranties, including, but not limited to, the implied 00032 // warranties of merchantability and fitness for a particular purpose are disclaimed. 00033 // In no event shall the Intel Corporation or contributors be liable for any direct, 00034 // indirect, incidental, special, exemplary, or consequential damages 00035 // (including, but not limited to, procurement of substitute goods or services; 00036 // loss of use, data, or profits; or business interruption) however caused 00037 // and on any theory of liability, whether in contract, strict liability, 00038 // or tort (including negligence or otherwise) arising in any way out of 00039 // the use of this software, even if advised of the possibility of such damage. 00040 // 00041 //M*/ 00042 00043 #ifndef __OPENCV_GPU_TYPE_TRAITS_DETAIL_HPP__ 00044 #define __OPENCV_GPU_TYPE_TRAITS_DETAIL_HPP__ 00045 00046 #include "../common.hpp" 00047 #include "../vec_traits.hpp" 00048 00049 namespace cv { namespace gpu { namespace device 00050 { 00051 namespace type_traits_detail 00052 { 00053 template <bool, typename T1, typename T2> struct Select { typedef T1 type; }; 00054 template <typename T1, typename T2> struct Select<false, T1, T2> { typedef T2 type; }; 00055 00056 template <typename T> struct IsSignedIntergral { enum {value = 0}; }; 00057 template <> struct IsSignedIntergral<schar> { enum {value = 1}; }; 00058 template <> struct IsSignedIntergral<char1> { enum {value = 1}; }; 00059 template <> struct IsSignedIntergral<short> { enum {value = 1}; }; 00060 template <> struct IsSignedIntergral<short1> { enum {value = 1}; }; 00061 template <> struct IsSignedIntergral<int> { enum {value = 1}; }; 00062 template <> struct IsSignedIntergral<int1> { enum {value = 1}; }; 00063 00064 template <typename T> struct IsUnsignedIntegral { enum {value = 0}; }; 00065 template <> struct IsUnsignedIntegral<uchar> { enum {value = 1}; }; 00066 template <> struct IsUnsignedIntegral<uchar1> { enum {value = 1}; }; 00067 template <> struct IsUnsignedIntegral<ushort> { enum {value = 1}; }; 00068 template <> struct IsUnsignedIntegral<ushort1> { enum {value = 1}; }; 00069 template <> struct IsUnsignedIntegral<uint> { enum {value = 1}; }; 00070 template <> struct IsUnsignedIntegral<uint1> { enum {value = 1}; }; 00071 00072 template <typename T> struct IsIntegral { enum {value = IsSignedIntergral<T>::value || IsUnsignedIntegral<T>::value}; }; 00073 template <> struct IsIntegral<char> { enum {value = 1}; }; 00074 template <> struct IsIntegral<bool> { enum {value = 1}; }; 00075 00076 template <typename T> struct IsFloat { enum {value = 0}; }; 00077 template <> struct IsFloat<float> { enum {value = 1}; }; 00078 template <> struct IsFloat<double> { enum {value = 1}; }; 00079 00080 template <typename T> struct IsVec { enum {value = 0}; }; 00081 template <> struct IsVec<uchar1> { enum {value = 1}; }; 00082 template <> struct IsVec<uchar2> { enum {value = 1}; }; 00083 template <> struct IsVec<uchar3> { enum {value = 1}; }; 00084 template <> struct IsVec<uchar4> { enum {value = 1}; }; 00085 template <> struct IsVec<uchar8> { enum {value = 1}; }; 00086 template <> struct IsVec<char1> { enum {value = 1}; }; 00087 template <> struct IsVec<char2> { enum {value = 1}; }; 00088 template <> struct IsVec<char3> { enum {value = 1}; }; 00089 template <> struct IsVec<char4> { enum {value = 1}; }; 00090 template <> struct IsVec<char8> { enum {value = 1}; }; 00091 template <> struct IsVec<ushort1> { enum {value = 1}; }; 00092 template <> struct IsVec<ushort2> { enum {value = 1}; }; 00093 template <> struct IsVec<ushort3> { enum {value = 1}; }; 00094 template <> struct IsVec<ushort4> { enum {value = 1}; }; 00095 template <> struct IsVec<ushort8> { enum {value = 1}; }; 00096 template <> struct IsVec<short1> { enum {value = 1}; }; 00097 template <> struct IsVec<short2> { enum {value = 1}; }; 00098 template <> struct IsVec<short3> { enum {value = 1}; }; 00099 template <> struct IsVec<short4> { enum {value = 1}; }; 00100 template <> struct IsVec<short8> { enum {value = 1}; }; 00101 template <> struct IsVec<uint1> { enum {value = 1}; }; 00102 template <> struct IsVec<uint2> { enum {value = 1}; }; 00103 template <> struct IsVec<uint3> { enum {value = 1}; }; 00104 template <> struct IsVec<uint4> { enum {value = 1}; }; 00105 template <> struct IsVec<uint8> { enum {value = 1}; }; 00106 template <> struct IsVec<int1> { enum {value = 1}; }; 00107 template <> struct IsVec<int2> { enum {value = 1}; }; 00108 template <> struct IsVec<int3> { enum {value = 1}; }; 00109 template <> struct IsVec<int4> { enum {value = 1}; }; 00110 template <> struct IsVec<int8> { enum {value = 1}; }; 00111 template <> struct IsVec<float1> { enum {value = 1}; }; 00112 template <> struct IsVec<float2> { enum {value = 1}; }; 00113 template <> struct IsVec<float3> { enum {value = 1}; }; 00114 template <> struct IsVec<float4> { enum {value = 1}; }; 00115 template <> struct IsVec<float8> { enum {value = 1}; }; 00116 template <> struct IsVec<double1> { enum {value = 1}; }; 00117 template <> struct IsVec<double2> { enum {value = 1}; }; 00118 template <> struct IsVec<double3> { enum {value = 1}; }; 00119 template <> struct IsVec<double4> { enum {value = 1}; }; 00120 template <> struct IsVec<double8> { enum {value = 1}; }; 00121 00122 template <class U> struct AddParameterType { typedef const U& type; }; 00123 template <class U> struct AddParameterType<U&> { typedef U& type; }; 00124 template <> struct AddParameterType<void> { typedef void type; }; 00125 00126 template <class U> struct ReferenceTraits 00127 { 00128 enum { value = false }; 00129 typedef U type; 00130 }; 00131 template <class U> struct ReferenceTraits<U&> 00132 { 00133 enum { value = true }; 00134 typedef U type; 00135 }; 00136 00137 template <class U> struct PointerTraits 00138 { 00139 enum { value = false }; 00140 typedef void type; 00141 }; 00142 template <class U> struct PointerTraits<U*> 00143 { 00144 enum { value = true }; 00145 typedef U type; 00146 }; 00147 template <class U> struct PointerTraits<U*&> 00148 { 00149 enum { value = true }; 00150 typedef U type; 00151 }; 00152 00153 template <class U> struct UnConst 00154 { 00155 typedef U type; 00156 enum { value = 0 }; 00157 }; 00158 template <class U> struct UnConst<const U> 00159 { 00160 typedef U type; 00161 enum { value = 1 }; 00162 }; 00163 template <class U> struct UnConst<const U&> 00164 { 00165 typedef U& type; 00166 enum { value = 1 }; 00167 }; 00168 00169 template <class U> struct UnVolatile 00170 { 00171 typedef U type; 00172 enum { value = 0 }; 00173 }; 00174 template <class U> struct UnVolatile<volatile U> 00175 { 00176 typedef U type; 00177 enum { value = 1 }; 00178 }; 00179 template <class U> struct UnVolatile<volatile U&> 00180 { 00181 typedef U& type; 00182 enum { value = 1 }; 00183 }; 00184 } // namespace type_traits_detail 00185 }}} // namespace cv { namespace gpu { namespace device 00186 00187 #endif // __OPENCV_GPU_TYPE_TRAITS_DETAIL_HPP__