[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
00001 /************************************************************************/ 00002 /* */ 00003 /* Copyright 1998-2002 by Ullrich Koethe */ 00004 /* Cognitive Systems Group, University of Hamburg, Germany */ 00005 /* */ 00006 /* This file is part of the VIGRA computer vision library. */ 00007 /* The VIGRA Website is */ 00008 /* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */ 00009 /* Please direct questions, bug reports, and contributions to */ 00010 /* ullrich.koethe@iwr.uni-heidelberg.de or */ 00011 /* vigra@informatik.uni-hamburg.de */ 00012 /* */ 00013 /* Permission is hereby granted, free of charge, to any person */ 00014 /* obtaining a copy of this software and associated documentation */ 00015 /* files (the "Software"), to deal in the Software without */ 00016 /* restriction, including without limitation the rights to use, */ 00017 /* copy, modify, merge, publish, distribute, sublicense, and/or */ 00018 /* sell copies of the Software, and to permit persons to whom the */ 00019 /* Software is furnished to do so, subject to the following */ 00020 /* conditions: */ 00021 /* */ 00022 /* The above copyright notice and this permission notice shall be */ 00023 /* included in all copies or substantial portions of the */ 00024 /* Software. */ 00025 /* */ 00026 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */ 00027 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */ 00028 /* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */ 00029 /* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */ 00030 /* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */ 00031 /* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */ 00032 /* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */ 00033 /* OTHER DEALINGS IN THE SOFTWARE. */ 00034 /* */ 00035 /************************************************************************/ 00036 00037 00038 #ifndef VIGRA_SIZED_INT_HXX 00039 #define VIGRA_SIZED_INT_HXX 00040 00041 #include "metaprogramming.hxx" 00042 00043 namespace vigra { 00044 00045 class Int_type_not_supported_on_this_platform {}; 00046 00047 #ifndef NO_PARTIAL_TEMPLATE_SPECIALIZATION 00048 00049 namespace detail { 00050 00051 template<class T, class NEXT> 00052 struct IntTypeList 00053 { 00054 enum { size = sizeof(T)*8 }; 00055 typedef T type; 00056 typedef NEXT next; 00057 }; 00058 00059 template<int SIZE, class LIST> 00060 struct SelectIntegerType 00061 { 00062 typedef typename 00063 IfBool<(SIZE == LIST::size), 00064 typename LIST::type, 00065 typename SelectIntegerType<SIZE, typename LIST::next>::type >::type 00066 type; 00067 }; 00068 00069 template<int SIZE> 00070 struct SelectIntegerType<SIZE, Int_type_not_supported_on_this_platform> 00071 { 00072 typedef Int_type_not_supported_on_this_platform type; 00073 }; 00074 00075 template<class LIST> 00076 struct SelectBiggestIntegerType 00077 { 00078 enum { cursize = LIST::size, 00079 nextsize = SelectBiggestIntegerType<typename LIST::next>::size, 00080 size = (cursize < nextsize) ? nextsize : cursize }; 00081 typedef typename 00082 IfBool<(cursize < nextsize), 00083 typename SelectBiggestIntegerType<typename LIST::next>::type, 00084 typename LIST::type>::type 00085 type; 00086 }; 00087 00088 template<> 00089 struct SelectBiggestIntegerType<Int_type_not_supported_on_this_platform> 00090 { 00091 enum { size = 0 }; 00092 typedef Int_type_not_supported_on_this_platform type; 00093 }; 00094 00095 typedef IntTypeList<signed char, 00096 IntTypeList<signed short, 00097 IntTypeList<signed int, 00098 IntTypeList<signed long, 00099 IntTypeList<signed long long, 00100 Int_type_not_supported_on_this_platform > > > > > SignedIntTypes; 00101 typedef IntTypeList<unsigned char, 00102 IntTypeList<unsigned short, 00103 IntTypeList<unsigned int, 00104 IntTypeList<unsigned long, 00105 IntTypeList<unsigned long long, 00106 Int_type_not_supported_on_this_platform > > > > > UnsignedIntTypes; 00107 00108 } // namespace detail 00109 00110 /** \addtogroup FixedSizeInt Fixed Size Integer Types 00111 00112 Since the C++ standard does only specify minimal sizes for the built-in 00113 integer types, one cannot rely on them to have a specific size. But 00114 pixel types with a specific size are often required in image processing, 00115 especially when reading or writing binary files. The VIGRA typedefs 00116 are guaranteed to have exactly the correct size. If the system 00117 does not provide a suitable type, the typedef will evaluate to 00118 <tt>Int_type_not_supported_on_this_platform</tt>. 00119 */ 00120 //@{ 00121 00122 /// 8-bit signed int 00123 typedef detail::SelectIntegerType<8, detail::SignedIntTypes>::type Int8; 00124 /// 16-bit signed int 00125 typedef detail::SelectIntegerType<16, detail::SignedIntTypes>::type Int16; 00126 /// 32-bit signed int 00127 typedef detail::SelectIntegerType<32, detail::SignedIntTypes>::type Int32; 00128 /// 64-bit signed int 00129 typedef detail::SelectIntegerType<64, detail::SignedIntTypes>::type Int64; 00130 /// 8-bit unsigned int 00131 typedef detail::SelectIntegerType<8, detail::UnsignedIntTypes>::type UInt8; 00132 /// 16-bit unsigned int 00133 typedef detail::SelectIntegerType<16, detail::UnsignedIntTypes>::type UInt16; 00134 /// 32-bit unsigned int 00135 typedef detail::SelectIntegerType<32, detail::UnsignedIntTypes>::type UInt32; 00136 /// 64-bit unsigned int 00137 typedef detail::SelectIntegerType<64, detail::UnsignedIntTypes>::type UInt64; 00138 00139 /// the biggest signed integer type of the system 00140 typedef detail::SelectBiggestIntegerType<detail::SignedIntTypes>::type IntBiggest; 00141 /// the biggest unsigned integer type of the system 00142 typedef detail::SelectBiggestIntegerType<detail::UnsignedIntTypes>::type UIntBiggest; 00143 00144 //@} 00145 00146 #else // NO_PARTIAL_TEMPLATE_SPECIALIZATION 00147 00148 typedef signed char Int8; 00149 typedef signed short Int16; 00150 typedef signed int Int32; 00151 typedef Int_type_not_supported_on_this_platform Int64; 00152 typedef unsigned char UInt8; 00153 typedef unsigned short UInt16; 00154 typedef unsigned int UInt32; 00155 typedef Int_type_not_supported_on_this_platform UInt64; 00156 00157 typedef Int32 IntBiggest; 00158 typedef UInt32 UIntBiggest; 00159 00160 #endif // NO_PARTIAL_TEMPLATE_SPECIALIZATION 00161 00162 } // namespace vigra 00163 00164 #endif /* VIGRA_SIZED_INT_HXX */
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |
html generated using doxygen and Python
|