JeVoisBase  1.20
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Types.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2016 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 // This code from:
19 
20 // //////////////////////////////////////////////////////////////////// //
21 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
22 // University of Southern California (USC) and the iLab at USC. //
23 // See http://iLab.usc.edu for information about this project. //
24 // //////////////////////////////////////////////////////////////////// //
25 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
26 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
27 // in Visual Environments, and Applications'' by Christof Koch and //
28 // Laurent Itti, California Institute of Technology, 2001 (patent //
29 // pending; application number 09/912,225 filed July 23, 2001; see //
30 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). //
31 // //////////////////////////////////////////////////////////////////// //
32 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. //
33 // //
34 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can //
35 // redistribute it and/or modify it under the terms of the GNU General //
36 // Public License as published by the Free Software Foundation; either //
37 // version 2 of the License, or (at your option) any later version. //
38 // //
39 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope //
40 // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
41 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
42 // PURPOSE. See the GNU General Public License for more details. //
43 // //
44 // You should have received a copy of the GNU General Public License //
45 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write //
46 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, //
47 // Boston, MA 02111-1307 USA. //
48 // //////////////////////////////////////////////////////////////////// //
49 //
50 // Primary maintainer for this file: Laurent Itti <itti@usc.edu>
51 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Util/Types.H $
52 // $Id: Types.H 12782 2010-02-05 22:14:30Z irock $
53 //
54 
55 #pragma once
56 
57 // ######################################################################
58 // type definitions
59 
60 //! Makes a <i>type</i> a typedef for \a T only if \a B is true.
61 template <class T, bool B>
62 struct type_if {};
63 
64 template <class T>
65 struct type_if<T, true> { typedef T type; };
66 
67 //! A compile-time check that \a T has \a N bits.
68 template <class T, unsigned long N>
70 {
71  typedef typename type_if<T, sizeof(T)*8 == N>::type type;
72 };
73 
74 // Now use the type_if and type_with_N_bits helper structs to make some
75 // fixed-size integer typedef's. If the stated bit-size does not match the
76 // given type, then we get a compile-time error.
77 
78 // if some other include file (e.g., from opencv, xclib, etc) defines
79 // some of the types below, just include those other files first, and
80 // then apply the appropriate #define below before including any of
81 // our INVT includes:
82 
83 #ifndef INVT_TYPEDEF_BYTE
84 #define INVT_TYPEDEF_BYTE
85 //! 8-bit unsigned integer
87 #endif
88 
89 #ifndef INVT_TYPEDEF_INT16
90 #define INVT_TYPEDEF_INT16
91 //! 16-bit signed integer
93 #endif
94 
95 #ifndef INVT_TYPEDEF_UINT16
96 #define INVT_TYPEDEF_UINT16
97 //! 16-bit unsigned integer
99 #endif
100 
101 #ifndef INVT_TYPEDEF_INT32
102 #define INVT_TYPEDEF_INT32
103 //! 32-bit signed integer
105 #endif
106 
107 #ifndef INVT_TYPEDEF_UINT32
108 #define INVT_TYPEDEF_UINT32
109 //! 32-bit unsigned integer
111 #endif
112 
113 #ifndef INVT_TYPEDEF_INT64
114 #define INVT_TYPEDEF_INT64
115 //! 64-bit signed integer
117 #endif
118 
119 #ifndef INVT_TYPEDEF_UINT64
120 #define INVT_TYPEDEF_UINT64
121 //! 64-bit unsigned integer
123 #endif
124 
125 #ifndef INVT_TYPEDEF_USHORT
126 #define INVT_TYPEDEF_USHORT
127 //! Canonical unsigned short int
128 typedef unsigned short int ushort;
129 #endif
130 
131 #ifndef INVT_TYPEDEF_UINT
132 #define INVT_TYPEDEF_UINT
133 //! Canonical unsigned int
134 typedef unsigned int uint;
135 #endif
136 
137 #ifndef INVT_TYPEDEF_ULONG
138 #define INVT_TYPEDEF_ULONG
139 //! Canonical unsigned long int
140 typedef unsigned long int ulong;
141 #endif
int16
type_with_N_bits< short, 16 >::type int16
16-bit signed integer
Definition: Types.H:92
uint16
type_with_N_bits< unsigned short, 16 >::type uint16
16-bit unsigned integer
Definition: Types.H:98
byte
type_with_N_bits< unsigned char, 8 >::type byte
8-bit unsigned integer
Definition: Types.H:86
int64
type_with_N_bits< long long int, 64 >::type int64
64-bit signed integer
Definition: Types.H:116
ushort
unsigned short int ushort
Canonical unsigned short int.
Definition: Types.H:128
ulong
unsigned long int ulong
Canonical unsigned long int.
Definition: Types.H:140
uint64
type_with_N_bits< unsigned long long int, 64 >::type uint64
64-bit unsigned integer
Definition: Types.H:122
uint
unsigned int uint
Canonical unsigned int.
Definition: Types.H:134
type_if
Makes a type a typedef for T only if B is true.
Definition: Types.H:62
type_if< T, true >::type
T type
Definition: Types.H:65
type_with_N_bits
A compile-time check that T has N bits.
Definition: Types.H:69
type_with_N_bits< unsigned char, 8 >::type
type_if< unsigned char, sizeof(unsigned char) *8==N >::type type
Definition: Types.H:71
int32
type_with_N_bits< int, 32 >::type int32
32-bit signed integer
Definition: Types.H:104
uint32
type_with_N_bits< unsigned int, 32 >::type uint32
32-bit unsigned integer
Definition: Types.H:110