itom
Loading...
Searching...
No Matches
typeDefs.h
1/* ********************************************************************
2itom software
3URL: http://www.uni-stuttgart.de/ito
4Copyright (C) 2020, Institut für Technische Optik (ITO),
5Universität Stuttgart, Germany
6
7This file is part of itom and its software development toolkit (SDK).
8
9itom is free software; you can redistribute it and/or modify it
10under the terms of the GNU Library General Public Licence as published by
11the Free Software Foundation; either version 2 of the Licence, or (at
12your option) any later version.
13
14In addition, as a special exception, the Institut für Technische
15Optik (ITO) gives you certain additional rights.
16These rights are described in the ITO LGPL Exception version 1.0,
17which can be found in the file LGPL_EXCEPTION.txt in this package.
18
19itom is distributed in the hope that it will be useful, but
20WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22General Public Licence for more details.
23
24You should have received a copy of the GNU Library General Public License
25along with itom. If not, see <http://www.gnu.org/licenses/>.
26*********************************************************************** */
27
28#ifndef TYPEDEFS_H
29#define TYPEDEFS_H
30
31#include <stdint.h>
32#include <complex>
33#include <exception> // std::exception
34#include <string.h>
35#include <stdexcept>
36#ifndef WIN32
37#include <unistd.h> // needed for usleep
38#endif
39
40#ifdef _MSC_VER
41#if (_MSC_VER >= 1800)
42#include <algorithm>
43#endif
44#endif
45
46// WARNING it is very EVIL to include ANY QT STUFF here!!!
47
48namespace ito
49{
50#define PLUGINWAIT 5000
51
57 {
58 retOk = 0x0,
59 retWarning = 0x1,
60 retError = 0x2
61 };
62
67 {
68 tCmpEqual,
69 tCmpCompatible,
70 tCmpFailed
71 };
72
77 {
78 msgStreamOut = 1,
79 msgStreamErr = 2,
80 msgStreamIn = 3
81 };
82
103
109 {
110 pclInvalid = 0x0000,
111 pclXYZ = 0x0001,
112 pclXYZI = 0x0002,
113 pclXYZRGBA = 0x0004,
114 pclXYZNormal = 0x0008,
115 pclXYZINormal = 0x0010,
116 pclXYZRGBNormal = 0x0020
117 };
118
119
120
121 // data types for images should always be the same size
122 // so define them to fixed byte sizes here
123
124
125 /*< \todo #define bool bool */
126 typedef int8_t int8;
127 typedef int16_t int16;
128 typedef int32_t int32;
129 typedef long long int64;
130
131 typedef uint8_t uint8;
132 typedef uint16_t uint16;
133 typedef uint32_t uint32;
134 typedef unsigned long long uint64;
135
136 typedef float float32;
137 typedef double float64;
138
139 typedef std::complex<ito::float32> complex64;
140 typedef std::complex<ito::float64> complex128;
141
143 {
144 public:
145 union
146 {
147 struct
148 {
149 ito::uint8 b;
150 ito::uint8 g;
151 ito::uint8 r;
152 ito::uint8 a;
153 };
154 ito::uint8 items[4];
155 ito::uint32 rgba;
156 };
157 };
158
159#pragma pack(push, 1)
161 {
162 public:
163 DateTime(ito::int64 datetimeMuS = 0) : datetime(datetimeMuS), utcOffset(0) {}
164
165 bool operator ==(const DateTime &b) const
166 {
167 if (utcOffset == b.utcOffset)
168 {
169 return datetime == b.datetime;
170 }
171
172 ito::int64 utcDiffMicroSec = (ito::int64)(b.utcOffset - utcOffset) * 1000000;
173 return datetime + utcDiffMicroSec == b.datetime;
174 }
175
176 bool operator !=(const DateTime &b) const
177 {
178 return !(*this == b);
179 }
180
181 bool operator <(const DateTime &b) const
182 {
183 return !(*this >= b);
184 }
185
186 bool operator >(const DateTime &b) const
187 {
188 return !(*this <= b);
189 }
190
191 bool operator <=(const DateTime &b) const
192 {
193 if (utcOffset == b.utcOffset)
194 {
195 return datetime <= b.datetime;
196 }
197
198 ito::int64 utcDiffMicroSec = (ito::int64)(b.utcOffset - utcOffset) * 1000000;
199 return datetime + utcDiffMicroSec <= b.datetime;
200 }
201
202 bool operator >=(const DateTime &b) const
203 {
204 if (utcOffset == b.utcOffset)
205 {
206 return datetime >= b.datetime;
207 }
208
209 ito::int64 utcDiffMicroSec = (ito::int64)(b.utcOffset - utcOffset) * 1000000;
210 return datetime + utcDiffMicroSec >= b.datetime;
211 }
212
213 ito::int64 datetime; // microseconds since 01.01.1970, 00:00:00 in UTC time
214 int utcOffset; // offset from UTC time in seconds
215 };
216
218 {
219 public:
220 TimeDelta(ito::int64 deltaMuS = 0) : delta(deltaMuS) {}
221
222 bool operator ==(const TimeDelta &b) const
223 {
224 return delta == b.delta;
225 }
226
227 bool operator !=(const TimeDelta &b) const
228 {
229 return delta != b.delta;
230 }
231
232 bool operator <(const TimeDelta &b) const
233 {
234 return delta < b.delta;
235 }
236
237 bool operator >(const TimeDelta &b) const
238 {
239 return delta > b.delta;
240 }
241
242 bool operator <=(const TimeDelta &b) const
243 {
244 return delta <= b.delta;
245 }
246
247 bool operator >=(const TimeDelta &b) const
248 {
249 return delta >= b.delta;
250 }
251
252 ito::int64 delta; // in microseconds
253 };
254#pragma pack(pop)
255
256} // namespace ito
257
258#ifdef __GNUC__
259#define DEPRECATED __attribute__((deprecated))
260#elif defined(_MSC_VER)
261#define DEPRECATED __declspec(deprecated)
262#else
263#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
264#define DEPRECATED
265#endif
266
267
268#ifndef WIN32
269#define _strdup strdup
270#define _itoa itoa
271#define _snprintf snprintf
272#define Sleep(TIME) usleep(TIME*1000.0)
273#endif
274
275 // this will be set on Visual Studio only, so this code is added for all other compilers
276#ifndef _MSC_VER
277 //for the ##__VA_ARGS__ trick see http://stackoverflow.com/questions/5588855/standard-alternative-to-gccs-va-args-trick
278#define vsprintf_s(b,l,f,...) vsprintf(b,f,##__VA_ARGS__);
279#define sprintf_s(b,l,f,...) sprintf(b,f,##__VA_ARGS__);
280#define strcat_s(dest,len,source) strcat(dest,source);
281#define strcpy_s(dest,len,source) strcpy(dest,source);
282#endif
283
284 //If the compiler is set to c++11 mode, NULL is not known any more.
285 //Therefore replace the NULL macro by the c++11 value 'nullptr'
286#if __cplusplus >= 201103L
287#ifdef NULL
288#undef NULL
289#endif
290#define NULL nullptr
291#endif
292
293#endif
Definition typeDefs.h:161
Definition typeDefs.h:143
Definition typeDefs.h:218
Definition apiFunctionsGraph.cpp:40
tPCLPointType
Definition typeDefs.h:109
@ pclXYZNormal
Definition typeDefs.h:114
@ pclXYZ
Definition typeDefs.h:111
@ pclXYZI
Definition typeDefs.h:112
@ pclXYZRGBNormal
Definition typeDefs.h:116
@ pclXYZINormal
Definition typeDefs.h:115
@ pclInvalid
Definition typeDefs.h:110
@ pclXYZRGBA
Definition typeDefs.h:113
tCompareResult
Definition typeDefs.h:67
tStreamMessageType
Definition typeDefs.h:77
tDataType
Definition typeDefs.h:88
@ tTimeDelta
Definition typeDefs.h:101
@ tInt16
Definition typeDefs.h:91
@ tFloat32
Definition typeDefs.h:95
@ tInt8
Definition typeDefs.h:89
@ tComplex128
Definition typeDefs.h:98
@ tInt32
Definition typeDefs.h:93
@ tUInt16
Definition typeDefs.h:92
@ tFloat64
Definition typeDefs.h:96
@ tComplex64
Definition typeDefs.h:97
@ tRGBA32
Definition typeDefs.h:99
@ tDateTime
Definition typeDefs.h:100
@ tUInt8
Definition typeDefs.h:90
@ tUInt32
Definition typeDefs.h:94
tRetValue
Definition typeDefs.h:57
@ retError
Definition typeDefs.h:60
@ retOk
Definition typeDefs.h:58
@ retWarning
Definition typeDefs.h:59