Types.H

Go to the documentation of this file.
00001 /*!@file Util/Types.H  Basic integer types */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00005 // University of Southern California (USC) and the iLab at USC.         //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Laurent Itti <itti@usc.edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Util/Types.H $
00035 // $Id: Types.H 12782 2010-02-05 22:14:30Z irock $
00036 //
00037 
00038 #ifndef TYPES_H_DEFINED
00039 #define TYPES_H_DEFINED
00040 
00041 // ######################################################################
00042 // type definitions
00043 
00044 //! Makes a <i>type</i> a typedef for \a T only if \a B is true.
00045 template <class T, bool B>
00046 struct type_if {};
00047 
00048 template <class T>
00049 struct type_if<T, true> { typedef T type; };
00050 
00051 //! A compile-time check that \a T has \a N bits.
00052 template <class T, unsigned long N>
00053 struct type_with_N_bits
00054 {
00055   typedef typename type_if<T, sizeof(T)*8 == N>::type type;
00056 };
00057 
00058 // Now use the type_if and type_with_N_bits helper structs to make some
00059 // fixed-size integer typedef's. If the stated bit-size does not match the
00060 // given type, then we get a compile-time error.
00061 
00062 // if some other include file (e.g., from opencv, xclib, etc) defines
00063 // some of the types below, just include those other files first, and
00064 // then apply the appropriate #define below before including any of
00065 // our INVT includes:
00066 
00067 #ifndef INVT_TYPEDEF_BYTE
00068 #define INVT_TYPEDEF_BYTE
00069 //! 8-bit unsigned integer
00070 typedef type_with_N_bits<unsigned char, 8>::type byte;
00071 #endif
00072 
00073 #ifndef INVT_TYPEDEF_INT16
00074 #define INVT_TYPEDEF_INT16
00075 //! 16-bit signed integer
00076 typedef type_with_N_bits<short, 16>::type int16;
00077 #endif
00078 
00079 #ifndef INVT_TYPEDEF_UINT16
00080 #define INVT_TYPEDEF_UINT16
00081 //! 16-bit unsigned integer
00082 typedef type_with_N_bits<unsigned short, 16>::type uint16;
00083 #endif
00084 
00085 #ifndef INVT_TYPEDEF_INT32
00086 #define INVT_TYPEDEF_INT32
00087 //! 32-bit signed integer
00088 typedef type_with_N_bits<int, 32>::type int32;
00089 #endif
00090 
00091 #ifndef INVT_TYPEDEF_UINT32
00092 #define INVT_TYPEDEF_UINT32
00093 //! 32-bit unsigned integer
00094 typedef type_with_N_bits<unsigned int, 32>::type uint32;
00095 #endif
00096 
00097 #ifndef INVT_TYPEDEF_INT64
00098 #define INVT_TYPEDEF_INT64
00099 //! 64-bit signed integer
00100 typedef type_with_N_bits<long long int, 64>::type int64;
00101 #endif
00102 
00103 #ifndef INVT_TYPEDEF_UINT64
00104 #define INVT_TYPEDEF_UINT64
00105 //! 64-bit unsigned integer
00106 typedef type_with_N_bits<unsigned long long int, 64>::type uint64;
00107 #endif
00108 
00109 #ifndef INVT_TYPEDEF_USHORT
00110 #define INVT_TYPEDEF_USHORT
00111 //! Canonical unsigned short int
00112 typedef unsigned short int ushort;
00113 #endif
00114 
00115 #ifndef INVT_TYPEDEF_UINT
00116 #define INVT_TYPEDEF_UINT
00117 //! Canonical unsigned int
00118 typedef unsigned int uint;
00119 #endif
00120 
00121 #ifndef INVT_TYPEDEF_ULONG
00122 #define INVT_TYPEDEF_ULONG
00123 //! Canonical unsigned long int
00124 typedef unsigned long int ulong;
00125 #endif
00126 
00127 #endif // !TYPES_H_DEFINED
Generated on Sun May 8 08:42:32 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3