Debian Codegraph @

3rdparty/xspublic/xstypes/xsdeviceid.h

raw
1
2 // Copyright (c) 2003-2019 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32
33 #ifndef XSDEVICEID_H
34 #define XSDEVICEID_H
35
36 #include "xstypesconfig.h"
37 #include "pstdint.h"
38 #include "xsstring.h"
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 #define XSDEVICEID_PRODUCT_CODE_LEN 24
44 #define XSDEVICEID_PRODUCT_CODE_INIT "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
45
46 #ifndef __cplusplus
47 #define XSDEVICEID_INITIALIZER { 0, XSDEVICEID_PRODUCT_CODE_INIT, 0, 0 }
48 #endif
49
50 struct XsDeviceId;
51
52 XSTYPES_DLL_API int XsDeviceId_isLegacyDeviceId(struct XsDeviceId const* thisPtr);
53 XSTYPES_DLL_API uint64_t XsDeviceId_legacyBit(struct XsDeviceId const* thisPtr);
54 XSTYPES_DLL_API int XsDeviceId_isMtiX(struct XsDeviceId const* thisPtr);
55 XSTYPES_DLL_API int XsDeviceId_isMtiX0(struct XsDeviceId const* thisPtr);
56 XSTYPES_DLL_API int XsDeviceId_isMtiX00(struct XsDeviceId const* thisPtr);
57 XSTYPES_DLL_API int XsDeviceId_isMtigX00(struct XsDeviceId const* thisPtr);
58 XSTYPES_DLL_API int XsDeviceId_isMtigX10(struct XsDeviceId const* thisPtr);
59 XSTYPES_DLL_API int XsDeviceId_isMti6X0(struct XsDeviceId const* thisPtr);
60 XSTYPES_DLL_API int XsDeviceId_isMtw(struct XsDeviceId const* thisPtr);
61 XSTYPES_DLL_API int XsDeviceId_isMtw2(struct XsDeviceId const* thisPtr);
62 XSTYPES_DLL_API int XsDeviceId_isMtx(struct XsDeviceId const* thisPtr);
63 XSTYPES_DLL_API int XsDeviceId_isMtx2(struct XsDeviceId const* thisPtr);
64 XSTYPES_DLL_API int XsDeviceId_isBodyPack(struct XsDeviceId const* thisPtr);
65 XSTYPES_DLL_API int XsDeviceId_isWirelessMaster(struct XsDeviceId const* thisPtr);
66 XSTYPES_DLL_API int XsDeviceId_isAwindaX(struct XsDeviceId const* thisPtr);
67 XSTYPES_DLL_API int XsDeviceId_isAwindaXStation(struct XsDeviceId const* thisPtr);
68 XSTYPES_DLL_API int XsDeviceId_isAwindaXDongle(struct XsDeviceId const* thisPtr);
69 XSTYPES_DLL_API int XsDeviceId_isAwindaXOem(struct XsDeviceId const* thisPtr);
70 XSTYPES_DLL_API int XsDeviceId_isAwinda2(struct XsDeviceId const* thisPtr);
71 XSTYPES_DLL_API int XsDeviceId_isAwinda2Station(struct XsDeviceId const* thisPtr);
72 XSTYPES_DLL_API int XsDeviceId_isAwinda2Dongle(struct XsDeviceId const* thisPtr);
73 XSTYPES_DLL_API int XsDeviceId_isAwinda2Oem(struct XsDeviceId const* thisPtr);
74 XSTYPES_DLL_API int XsDeviceId_isSyncStationX(struct XsDeviceId const* thisPtr);
75 XSTYPES_DLL_API int XsDeviceId_isSyncStation2(struct XsDeviceId const* thisPtr);
76 XSTYPES_DLL_API int XsDeviceId_isHilDevice(struct XsDeviceId const* thisPtr);
77 XSTYPES_DLL_API int XsDeviceId_isGlove(struct XsDeviceId const* thisPtr);
78
79 XSTYPES_DLL_API int XsDeviceId_isImu(struct XsDeviceId const* thisPtr);
80 XSTYPES_DLL_API int XsDeviceId_isVru(struct XsDeviceId const* thisPtr);
81 XSTYPES_DLL_API int XsDeviceId_isAhrs(struct XsDeviceId const* thisPtr);
82 XSTYPES_DLL_API int XsDeviceId_isGnss(struct XsDeviceId const* thisPtr);
83 XSTYPES_DLL_API int XsDeviceId_isContainerDevice(struct XsDeviceId const* thisPtr);
84
85 XSTYPES_DLL_API int XsDeviceId_isMt(struct XsDeviceId const* thisPtr);
86 XSTYPES_DLL_API int XsDeviceId_isMti(struct XsDeviceId const* thisPtr);
87 XSTYPES_DLL_API int XsDeviceId_isMtig(struct XsDeviceId const* thisPtr);
88 XSTYPES_DLL_API int XsDeviceId_isMtMark4(struct XsDeviceId const* thisPtr);
89 XSTYPES_DLL_API int XsDeviceId_isMtMark5(struct XsDeviceId const* thisPtr);
90
91 //------------------------------------------------------------------------------------------------------------
92 //------------------------------------------------------------------------------------------------------------
93 //------------------------------------------------------------------------------------------------------------
94 //------------------------------------------------------------------------------------------------------------
95
96 XSTYPES_DLL_API void XsDeviceId_toString(struct XsDeviceId const* thisPtr, XsString* str);
97 XSTYPES_DLL_API void XsDeviceId_fromString(struct XsDeviceId* thisPtr, XsString const* str);
98 XSTYPES_DLL_API void XsDeviceId_toDeviceTypeString(struct XsDeviceId const* thisPtr, XsString* str, int makeType);
99 XSTYPES_DLL_API void XsDeviceId_fromDeviceTypeString(struct XsDeviceId* thisPtr, XsString const* str);
100 XSTYPES_DLL_API int XsDeviceId_isValid(struct XsDeviceId const* thisPtr);
101 XSTYPES_DLL_API void XsDeviceId_swap(struct XsDeviceId* a, struct XsDeviceId* b);
102 XSTYPES_DLL_API int XsDeviceId_contains(struct XsDeviceId const* a, struct XsDeviceId const* b);
103 XSTYPES_DLL_API int XsDeviceId_isType(struct XsDeviceId const* thisPtr);
104 XSTYPES_DLL_API void XsDeviceId_typeName(struct XsDeviceId const* thisPtr, XsString* str);
105 XSTYPES_DLL_API void XsDeviceId_type(struct XsDeviceId const* thisPtr, struct XsDeviceId* type);
106 XSTYPES_DLL_API void XsDeviceId_deviceType(struct XsDeviceId const* thisPtr, int detailed, struct XsDeviceId* type);
107 XSTYPES_DLL_API void XsDeviceId_deviceTypeMask(struct XsDeviceId const* thisPtr, int detailed, struct XsDeviceId* type);
108
109 //============================================================================================================
110 //==== Deprecated methods follow =====
111 //============================================================================================================
112 XSTYPES_DLL_API int XsDeviceId_isMtMk4(struct XsDeviceId const* thisPtr);
113 XSTYPES_DLL_API int XsDeviceId_isMtMk4_X(struct XsDeviceId const* thisPtr);
114 XSTYPES_DLL_API int XsDeviceId_isMtMk4_1(struct XsDeviceId const* thisPtr);
115 XSTYPES_DLL_API int XsDeviceId_isMtMk4_2(struct XsDeviceId const* thisPtr);
116 XSTYPES_DLL_API int XsDeviceId_isMtMk4_3(struct XsDeviceId const* thisPtr);
117 XSTYPES_DLL_API int XsDeviceId_isMtMk4_7(struct XsDeviceId const* thisPtr);
118 XSTYPES_DLL_API int XsDeviceId_isMtMk4_X0(struct XsDeviceId const* thisPtr);
119 XSTYPES_DLL_API int XsDeviceId_isMtMk4_10(struct XsDeviceId const* thisPtr);
120 XSTYPES_DLL_API int XsDeviceId_isMtMk4_20(struct XsDeviceId const* thisPtr);
121 XSTYPES_DLL_API int XsDeviceId_isMtMk4_30(struct XsDeviceId const* thisPtr);
122 XSTYPES_DLL_API int XsDeviceId_isMtMk4_X00(struct XsDeviceId const* thisPtr);
123 XSTYPES_DLL_API int XsDeviceId_isMtMk4_100(struct XsDeviceId const* thisPtr);
124 XSTYPES_DLL_API int XsDeviceId_isMtMk4_200(struct XsDeviceId const* thisPtr);
125 XSTYPES_DLL_API int XsDeviceId_isMtMk4_300(struct XsDeviceId const* thisPtr);
126 XSTYPES_DLL_API int XsDeviceId_isMtMk4_400(struct XsDeviceId const* thisPtr);
127 XSTYPES_DLL_API int XsDeviceId_isMtMk4_500(struct XsDeviceId const* thisPtr);
128 XSTYPES_DLL_API int XsDeviceId_isMtMk4_600(struct XsDeviceId const* thisPtr);
129 XSTYPES_DLL_API int XsDeviceId_isMtMk4_700(struct XsDeviceId const* thisPtr);
130 XSTYPES_DLL_API int XsDeviceId_isMtMk4_710(struct XsDeviceId const* thisPtr);
131 XSTYPES_DLL_API int XsDeviceId_isMtMk4_800(struct XsDeviceId const* thisPtr);
132 XSTYPES_DLL_API int XsDeviceId_isMtMk4_900(struct XsDeviceId const* thisPtr);
133 XSTYPES_DLL_API int XsDeviceId_isMtMk5(struct XsDeviceId const* thisPtr);
134 XSTYPES_DLL_API int XsDeviceId_isMtMk5_X0(struct XsDeviceId const* thisPtr);
135 XSTYPES_DLL_API int XsDeviceId_isMtMk5_10(struct XsDeviceId const* thisPtr);
136 XSTYPES_DLL_API int XsDeviceId_isMtMk5_20(struct XsDeviceId const* thisPtr);
137 XSTYPES_DLL_API int XsDeviceId_isMtMk5_30(struct XsDeviceId const* thisPtr);
138 XSTYPES_DLL_API int XsDeviceId_isMtMk5_X00(struct XsDeviceId const* thisPtr);
139 XSTYPES_DLL_API int XsDeviceId_isMtMk5_100(struct XsDeviceId const* thisPtr);
140 XSTYPES_DLL_API int XsDeviceId_isMtMk5_200(struct XsDeviceId const* thisPtr);
141 XSTYPES_DLL_API int XsDeviceId_isMtMk5_300(struct XsDeviceId const* thisPtr);
142 XSTYPES_DLL_API int XsDeviceId_isMtMk5_710(struct XsDeviceId const* thisPtr);
143 //============================================================================================================
144
145 #ifdef __cplusplus
146 } // extern "C"
147 #endif
148
149 struct XsDeviceId {
150 #ifdef __cplusplus
151 /*! \brief Constructor that creates an XsDeviceId from the supplied \a productcode, \a hardwareVersion, \a productVariant and \a serialNumber*/
152 inline XsDeviceId(const char* productCode, uint16_t hardwareVersion, uint32_t productVariant, uint64_t serialNumber)
153 : m_deviceId(serialNumber)
154 , m_hardwareVersion(hardwareVersion)
155 , m_productVariant(productVariant)
156 {
157 memset(m_productCode, 0, sizeof(m_productCode));
158 if (productCode)
159 strcpy(m_productCode, productCode);
160 }
161
162 /*! \brief Constructor that creates an XsDeviceId from the supplied \a deviceId */
163 inline XsDeviceId(uint64_t serialNumber = 0)
164 : m_deviceId(serialNumber)
165 , m_hardwareVersion(0)
166 , m_productVariant(0)
167 {
168 memset(m_productCode, 0, sizeof(m_productCode));
169 }
170
171 /*! \brief Constructor that creates an XsDeviceId from the supplied XsDeviceId \a other */
172 inline XsDeviceId(const XsDeviceId& other)
173 {
174 memcpy(static_cast<void*>(this), static_cast<void const*>(&other), sizeof(XsDeviceId));
175 }
176 /*! \brief Assign the \a other deviceId to this XsDeviceId */
177 inline const XsDeviceId& operator=(const XsDeviceId& other)
178 {
179 if (this != &other)
180 memcpy(static_cast<void*>(this), static_cast<void const*>(&other), sizeof(XsDeviceId));
181 return *this;
182 }
183
184 /*! \brief \copybrief XsDeviceId_legacyBit(const struct XsDeviceId*) */
185 static inline uint64_t legacyBit()
186 {
187 return XsDeviceId_legacyBit(nullptr);
188 }
189 /*! \brief \copybrief XsDeviceId_isLegacyDeviceId(const struct XsDeviceId*) */
190 inline bool isLegacyDeviceId() const
191 {
192 return 0 != XsDeviceId_isLegacyDeviceId(this);
193 }
194 /*! \brief Returns the device serial number as an unsigned integer */
195 inline uint64_t toInt() const
196 {
197 return m_deviceId;
198 }
199 /*! \brief Returns the product code */
200 inline XsString productCode() const
201 {
202 XsString tmp(m_productCode);
203 return tmp;
204 }
205 /*! \brief Returns the product variant */
206 inline uint32_t productVariant() const
207 {
208 return m_productVariant;
209 }
210 /*! \brief Returns the product variant */
211 inline uint16_t hardwareVersion() const
212 {
213 return m_hardwareVersion;
214 }
215 /*! \brief Returns the 32-bit device serial number, which may be 0 if the device has a 64-bit serial number */
216 inline uint32_t legacyDeviceId() const
217 {
218 return static_cast<uint32_t>(m_deviceId);
219 }
220 /*! \brief \copybrief XsDeviceId_isMtiX(const struct XsDeviceId*) */
221 inline bool isMtiX() const
222 {
223 return 0 != XsDeviceId_isMtiX(this);
224 }
225 /*! \brief \copybrief XsDeviceId_isMtiX0(const struct XsDeviceId*) */
226 inline bool isMtiX0() const
227 {
228 return 0 != XsDeviceId_isMtiX0(this);
229 }
230 /*! \brief \copybrief XsDeviceId_isMtiX00(const struct XsDeviceId*) */
231 inline bool isMtiX00() const
232 {
233 return 0 != XsDeviceId_isMtiX00(this);
234 }
235 /*! \brief \copybrief XsDeviceId_isMtigX00(const struct XsDeviceId*) */
236 inline bool isMtigX00() const
237 {
238 return 0 != XsDeviceId_isMtigX00(this);
239 }
240 /*! \brief \copybrief XsDeviceId_isMtigX10(const struct XsDeviceId*) */
241 inline bool isMtigX10() const
242 {
243 return 0 != XsDeviceId_isMtigX10(this);
244 }
245 /*! \brief \copybrief XsDeviceId_isMti6X0(const struct XsDeviceId*) */
246 inline bool isMti6X0() const
247 {
248 return 0 != XsDeviceId_isMti6X0(this);
249 }
250 /*! \brief \copybrief XsDeviceId_isGlove(const struct XsDeviceId*) */
251 inline bool isGlove () const
252 {
253 return 0 != XsDeviceId_isGlove(this);
254 }
255 /*! \brief \copybrief XsDeviceId_isMtw(const struct XsDeviceId*) */
256 inline bool isMtw() const
257 {
258 return 0 != XsDeviceId_isMtw(this);
259 }
260 /*! \brief \copybrief XsDeviceId_isMtw2(const struct XsDeviceId*) */
261 inline bool isMtw2() const
262 {
263 return 0 != XsDeviceId_isMtw2(this);
264 }
265 /*! \brief \copybrief XsDeviceId_isMtx(const struct XsDeviceId*) */
266 inline bool isMtx() const
267 {
268 return 0 != XsDeviceId_isMtx(this);
269 }
270 /*! \brief \copybrief XsDeviceId_isMtx2(const struct XsDeviceId*) */
271 inline bool isMtx2() const
272 {
273 return 0 != XsDeviceId_isMtx2(this);
274 }
275 /*! \brief \copybrief XsDeviceId_isBodyPack(const struct XsDeviceId*) */
276 inline bool isBodyPack() const
277 {
278 return 0 != XsDeviceId_isBodyPack(this);
279 }
280 /*! \brief \copybrief XsDeviceId_isWirelessMaster(const struct XsDeviceId*) */
281 inline bool isWirelessMaster() const
282 {
283 return 0 != XsDeviceId_isWirelessMaster(this);
284 }
285 /*! \brief \copybrief XsDeviceId_isAwindaX(const struct XsDeviceId*) */
286 inline bool isAwindaX() const
287 {
288 return 0 != XsDeviceId_isAwindaX(this);
289 }
290 /*! \brief \copybrief XsDeviceId_isAwindaXStation(const struct XsDeviceId*) */
291 inline bool isAwindaXStation() const
292 {
293 return 0 != XsDeviceId_isAwindaXStation(this);
294 }
295 /*! \brief \copybrief XsDeviceId_isAwindaXDongle(const struct XsDeviceId*) */
296 inline bool isAwindaXDongle() const
297 {
298 return 0 != XsDeviceId_isAwindaXDongle(this);
299 }
300 /*! \brief \copybrief XsDeviceId_isAwindaXOem(const struct XsDeviceId*) */
301 inline bool isAwindaXOem() const
302 {
303 return 0 != XsDeviceId_isAwindaXOem(this);
304 }
305 /*! \brief \copybrief XsDeviceId_isAwinda2(const struct XsDeviceId*) */
306 inline bool isAwinda2() const
307 {
308 return 0 != XsDeviceId_isAwinda2(this);
309 }
310 /*! \brief \copybrief XsDeviceId_isAwinda2Station(const struct XsDeviceId*) */
311 inline bool isAwinda2Station() const
312 {
313 return 0 != XsDeviceId_isAwinda2Station(this);
314 }
315 /*! \brief \copybrief XsDeviceId_isAwinda2Dongle(const struct XsDeviceId*) */
316 inline bool isAwinda2Dongle() const
317 {
318 return 0 != XsDeviceId_isAwinda2Dongle(this);
319 }
320 /*! \brief \copybrief XsDeviceId_isAwinda2Oem(const struct XsDeviceId*) */
321 inline bool isAwinda2Oem() const
322 {
323 return 0 != XsDeviceId_isAwinda2Oem(this);
324 }
325 /*! \brief \copybrief XsDeviceId_isSyncStationX(const struct XsDeviceId*) */
326 inline bool isSyncStationX() const
327 {
328 return 0 != XsDeviceId_isSyncStationX(this);
329 }
330 /*! \brief \copybrief XsDeviceId_isSyncStation2(const struct XsDeviceId*) */
331 inline bool isSyncStation2() const
332 {
333 return 0 != XsDeviceId_isSyncStation2(this);
334 }
335 /*! \brief \copybrief XsDeviceId_isHilDevice(const struct XsDeviceId*) */
336 inline bool isHilDevice() const
337 {
338 return 0 != XsDeviceId_isHilDevice(this);
339 }
340 /*! \brief \copybrief XsDeviceId_isImu(const struct XsDeviceId*) */
341 inline bool isImu() const
342 {
343 return 0 != XsDeviceId_isImu(this);
344 }
345 /*! \brief \copybrief XsDeviceId_isVru(const struct XsDeviceId*) */
346 inline bool isVru() const
347 {
348 return 0 != XsDeviceId_isVru(this);
349 }
350 /*! \brief \copybrief XsDeviceId_isAhrs(const struct XsDeviceId*) */
351 inline bool isAhrs() const
352 {
353 return 0 != XsDeviceId_isAhrs(this);
354 }
355 /*! \brief \copybrief XsDeviceId_isGnss(const struct XsDeviceId*) */
356 inline bool isGnss() const
357 {
358 return 0 != XsDeviceId_isGnss(this);
359 }
360 /*! \brief \copybrief XsDeviceId_isContainerDevice(const struct XsDeviceId*) */
361 inline bool isContainerDevice() const
362 {
363 return 0 != XsDeviceId_isContainerDevice(this);
364 }
365 /*! \brief \copybrief XsDeviceId_isMt(const struct XsDeviceId*) */
366 inline bool isMt() const
367 {
368 return 0 != XsDeviceId_isMt(this);
369 }
370 /*! \brief \copybrief XsDeviceId_isMti(const struct XsDeviceId*) */
371 inline bool isMti() const
372 {
373 return 0 != XsDeviceId_isMti(this);
374 }
375 /*! \brief \copybrief XsDeviceId_isMtig(const struct XsDeviceId*) */
376 inline bool isMtig() const
377 {
378 return 0 != XsDeviceId_isMtig(this);
379 }
380 /*! \brief \copybrief XsDeviceId_isMtMark4(const struct XsDeviceId*) */
381 inline bool isMtMark4() const
382 {
383 return 0 != XsDeviceId_isMtMark4(this);
384 }
385 /*! \brief \copybrief XsDeviceId_isMtMark5(const struct XsDeviceId*) */
386 inline bool isMtMark5() const
387 {
388 return 0 != XsDeviceId_isMtMark5(this);
389 }
390 /*! \brief \copybrief XsDeviceId_toString(const XsDeviceId* thisPtr, XsString* str) */
391 inline XsString toString() const
392 {
393 XsString tmp;
394 XsDeviceId_toString(this, &tmp);
395 return tmp;
396 }
397 /*! \copydoc XsDeviceId_fromString(XsDeviceId* thisPtr, const XsString* str) */
398 inline void fromString(const XsString &str)
399 {
400 XsDeviceId_fromString(this, &str);
401 }
402
403 /*! \copybrief XsDeviceId_toDeviceTypeString(const XsDeviceId* thisPtr, XsString* str, int makeType)
404 \param makeType Boolean whether the deviceid is made a devicetype or is printed fully in the output string
405 \return The string with the device type or device id information in string format
406 */
407 inline XsString toDeviceTypeString(bool makeType = true) const
408 {
409 XsString tmp;
410 XsDeviceId_toDeviceTypeString(this, &tmp, makeType ? 1 : 0);
411 return tmp;
412 }
413
414 /*! \copydoc XsDeviceId_fromDeviceTypeString(XsDeviceId* thisPtr, const XsString* str)
415 */
416 inline void fromDeviceTypeString(const XsString &str)
417 {
418 XsDeviceId_fromDeviceTypeString(this, &str);
419 }
420
421 /*! \brief \copybrief XsDeviceId_isValid(const struct XsDeviceId*) */
422 inline bool isValid() const
423 {
424 return 0 != XsDeviceId_isValid(this);
425 }
426 /*! \copydoc XsDeviceId_contains(XsDeviceId const*, XsDeviceId const*) */
427 inline bool contains(const XsDeviceId& other) const
428 {
429 return 0 != XsDeviceId_contains(this, &other);
430 }
431 /*! \brief Returns true if the ID is just a device type, not an actual device ID */
432 inline bool isType() const
433 {
434 return 0 != XsDeviceId_isType(this);
435 }
436 /*! \brief Returns the name of the type of device identified by this id */
437 inline XsString typeName() const
438 {
439 XsString rv;
440 XsDeviceId_typeName(this, &rv);
441 return rv;
442 }
443 /*! \brief Returns the type of device identified by this id */
444 inline XsDeviceId type() const
445 {
446 XsDeviceId xtype;
447 XsDeviceId_type(this, &xtype);
448 return xtype;
449 }
450 /*! \brief Returns the (detailed) device type of this id
451 \param detailed Boolean whether detailed information is returned
452 \return The requested device type
453 */
454 inline XsDeviceId deviceType(bool detailed = true) const
455 {
456 XsDeviceId xtype;
457 XsDeviceId_deviceType(this, detailed ? 1 : 0, &xtype);
458 return xtype;
459 }
460 /*! \brief Returns the detailed device type mask of this id
461 \param detailed Boolean whether detailed information is returned
462 \return The requested device type mask
463 */
464 inline XsDeviceId deviceTypeMask(bool detailed = true) const
465 {
466 XsDeviceId xtype;
467 XsDeviceId_deviceTypeMask(this, detailed ? 1 : 0, &xtype);
468 return xtype;
469 }
470
471 /*! \brief Returns true if the \a other deviceId matches this deviceId */
472 inline bool operator==(const XsDeviceId& other) const
473 {
474 if (isLegacyDeviceId() || other.isLegacyDeviceId())
475 return toInt() == other.toInt();
476 else
477 {
478 return (toInt() == other.toInt() &&
479 m_productVariant == other.m_productVariant &&
480 m_hardwareVersion == other.m_hardwareVersion &&
481 (strcmp(m_productCode, other.m_productCode) == 0)
482 );
483 }
484 }
485 /*! \brief Returns true if the \a other deviceId does not match this deviceId */
486 inline bool operator!=(const XsDeviceId& other) const { return !(*this == other); }
487 /*! \brief Returns true if this deviceId is less than the \a other deviceId */
488 inline bool operator<(const XsDeviceId& other) const
489 {
490 if (isLegacyDeviceId() || other.isLegacyDeviceId())
491 return toInt() < other.toInt();
492 else
493 {
494 int pdiff = strcmp(m_productCode, other.m_productCode);
495 if (pdiff < 0)
496 return true;
497 else if (pdiff > 0)
498 return false;
499 else
500 {
501 if (m_hardwareVersion < other.m_hardwareVersion)
502 return true;
503 else if (m_hardwareVersion > other.m_hardwareVersion)
504 return false;
505 else
506 {
507 if (m_productVariant < other.m_productVariant)
508 return true;
509 else if (m_productVariant > other.m_productVariant)
510 return false;
511 else
512 {
513 if (toInt() < other.toInt())
514 return true;
515 else if (toInt() > other.toInt())
516 return false;
517 else
518 return false;
519 }
520 }
521 }
522 }
523 }
524 /*! \brief Returns true if this deviceId is less or equal to the \a other deviceId */
525 inline bool operator<=(const XsDeviceId& other) const
526 {
527 if (isLegacyDeviceId())
528 return toInt() <= other.toInt();
529 else
530 {
531 int pdiff = strcmp(m_productCode, other.m_productCode);
532 if (pdiff > 0)
533 return false;
534 else
535 {
536 if (m_hardwareVersion > other.m_hardwareVersion)
537 return false;
538 else
539 {
540 if (m_productVariant > other.m_productVariant)
541 return false;
542 else
543 {
544 if (toInt() > other.toInt())
545 return false;
546 else
547 return true;
548 }
549 }
550 }
551 }
552 }
553 /*! \brief Returns true if this deviceId is larger than the \a other deviceId */
554 inline bool operator>(const XsDeviceId& other) const
555 {
556 if (isLegacyDeviceId())
557 return toInt() > other.toInt();
558 else
559 {
560 int pdiff = strcmp(m_productCode, other.m_productCode);
561 if (pdiff > 0)
562 return true;
563 else if (pdiff < 0)
564 return false;
565 else
566 {
567 if (m_hardwareVersion > other.m_hardwareVersion)
568 return true;
569 else if (m_hardwareVersion < other.m_hardwareVersion)
570 return false;
571 else
572 {
573 if (m_productVariant > other.m_productVariant)
574 return true;
575 else if (m_productVariant < other.m_productVariant)
576 return false;
577 else
578 {
579 if (toInt() > other.toInt())
580 return true;
581 else if (toInt() < other.toInt())
582 return false;
583 else
584 return false;
585 }
586 }
587 }
588 }
589 }
590 /*! \brief Returns true if this deviceId is larger or equal to the \a other deviceId */
591 inline bool operator>=(const XsDeviceId& other) const
592 {
593 if (isLegacyDeviceId())
594 return toInt() >= other.toInt();
595 else
596 {
597 int pdiff = strcmp(m_productCode, other.m_productCode);
598 if (pdiff < 0)
599 return false;
600 else
601 {
602 if (m_hardwareVersion < other.m_hardwareVersion)
603 return false;
604 else
605 {
606 if (m_productVariant < other.m_productVariant)
607 return false;
608 else
609 {
610 if (toInt() < other.toInt())
611 return false;
612 else
613 return true;
614 }
615 }
616 }
617 }
618 }
619
620
621 //============================================================================================================
622 //============================================================================================================
623 //==== Deprecated methods follow =====
624 //============================================================================================================
625 //============================================================================================================
626
627 /*! \brief \copybrief XsDeviceId_isMtMk4(const struct XsDeviceId*) */
628 inline bool isMtMk4() const
629 {
630 return 0 != XsDeviceId_isMtMk4(this);
631 }
632 /*! \brief \copybrief XsDeviceId_isMtMk4_X(const struct XsDeviceId*) */
633 inline bool isMtMk4_X() const
634 {
635 return 0 != XsDeviceId_isMtMk4_X(this);
636 }
637 /*! \brief \copybrief XsDeviceId_isMtMk4_1(const struct XsDeviceId*) */
638 inline bool isMtMk4_1() const
639 {
640 return 0 != XsDeviceId_isMtMk4_1(this);
641 }
642 /*! \brief \copybrief XsDeviceId_isMtMk4_2(const struct XsDeviceId*) */
643 inline bool isMtMk4_2() const
644 {
645 return 0 != XsDeviceId_isMtMk4_2(this);
646 }
647 /*! \brief \copybrief XsDeviceId_isMtMk4_3(const struct XsDeviceId*) */
648 inline bool isMtMk4_3() const
649 {
650 return 0 != XsDeviceId_isMtMk4_3(this);
651 }
652 /*! \brief \copybrief XsDeviceId_isMtMk4_7(const struct XsDeviceId*) */
653 inline bool isMtMk4_7() const
654 {
655 return 0 != XsDeviceId_isMtMk4_7(this);
656 }
657 /*! \brief \copybrief XsDeviceId_isMtMk4_X0(const struct XsDeviceId*) */
658 inline bool isMtMk4_X0() const
659 {
660 return 0 != XsDeviceId_isMtMk4_X0(this);
661 }
662 /*! \brief \copybrief XsDeviceId_isMtMk4_10(const struct XsDeviceId*) */
663 inline bool isMtMk4_10() const
664 {
665 return 0 != XsDeviceId_isMtMk4_10(this);
666 }
667 /*! \brief \copybrief XsDeviceId_isMtMk4_20(const struct XsDeviceId*) */
668 inline bool isMtMk4_20() const
669 {
670 return 0 != XsDeviceId_isMtMk4_20(this);
671 }
672 /*! \brief \copybrief XsDeviceId_isMtMk4_30(const struct XsDeviceId*) */
673 inline bool isMtMk4_30() const
674 {
675 return 0 != XsDeviceId_isMtMk4_30(this);
676 }
677 /*! \brief \copybrief XsDeviceId_isMtMk4_X00(const struct XsDeviceId*) */
678 inline bool isMtMk4_X00() const
679 {
680 return 0 != XsDeviceId_isMtMk4_X00(this);
681 }
682 /*! \brief \copybrief XsDeviceId_isMtMk4_100(const struct XsDeviceId*) */
683 inline bool isMtMk4_100() const
684 {
685 return 0 != XsDeviceId_isMtMk4_100(this);
686 }
687 /*! \brief \copybrief XsDeviceId_isMtMk4_200(const struct XsDeviceId*) */
688 inline bool isMtMk4_200() const
689 {
690 return 0 != XsDeviceId_isMtMk4_200(this);
691 }
692 /*! \brief \copybrief XsDeviceId_isMtMk4_300(const struct XsDeviceId*) */
693 inline bool isMtMk4_300() const
694 {
695 return 0 != XsDeviceId_isMtMk4_300(this);
696 }
697 /*! \brief \copybrief XsDeviceId_isMtMk4_400(const struct XsDeviceId*) */
698 inline bool isMtMk4_400() const
699 {
700 return 0 != XsDeviceId_isMtMk4_400(this);
701 }
702 /*! \brief \copybrief XsDeviceId_isMtMk4_500(const struct XsDeviceId*) */
703 inline bool isMtMk4_500() const
704 {
705 return 0 != XsDeviceId_isMtMk4_500(this);
706 }
707 /*! \brief \copybrief XsDeviceId_isMtMk4_600(const struct XsDeviceId*) */
708 inline bool isMtMk4_600() const
709 {
710 return 0 != XsDeviceId_isMtMk4_600(this);
711 }
712 /*! \brief \copybrief XsDeviceId_isMtMk4_700(const struct XsDeviceId*) */
713 inline bool isMtMk4_700() const
714 {
715 return 0 != XsDeviceId_isMtMk4_700(this);
716 }
717 /*! \brief \copybrief XsDeviceId_isMtMk4_710(const struct XsDeviceId*) */
718 inline bool isMtMk4_710() const
719 {
720 return 0 != XsDeviceId_isMtMk4_710(this);
721 }
722 /*! \brief \copybrief XsDeviceId_isMtMk4_800(const struct XsDeviceId*) */
723 inline bool isMtMk4_800() const
724 {
725 return 0 != XsDeviceId_isMtMk4_800(this);
726 }
727 /*! \brief \copybrief XsDeviceId_isMtMk4_900(const struct XsDeviceId*) */
728 inline bool isMtMk4_900() const
729 {
730 return 0 != XsDeviceId_isMtMk4_900(this);
731 }
732 /*! \brief \copybrief XsDeviceId_isMtMk5(const struct XsDeviceId*) */
733 inline bool isMtMk5() const
734 {
735 return 0 != XsDeviceId_isMtMk5(this);
736 }
737 /*! \brief \copybrief XsDeviceId_isMtMk5_X0(const struct XsDeviceId*) */
738 inline bool isMtMk5_X0() const
739 {
740 return 0 != XsDeviceId_isMtMk5_X0(this);
741 }
742 /*! \brief \copybrief XsDeviceId_isMtMk5_10(const struct XsDeviceId*) */
743 inline bool isMtMk5_10() const
744 {
745 return 0 != XsDeviceId_isMtMk5_10(this);
746 }
747 /*! \brief \copybrief XsDeviceId_isMtMk5_20(const struct XsDeviceId*) */
748 inline bool isMtMk5_20() const
749 {
750 return 0 != XsDeviceId_isMtMk5_20(this);
751 }
752 /*! \brief \copybrief XsDeviceId_isMtMk5_30(const struct XsDeviceId*) */
753 inline bool isMtMk5_30() const
754 {
755 return 0 != XsDeviceId_isMtMk5_30(this);
756 }
757 /*! \brief \copybrief XsDeviceId_isMtMk5_X00(const struct XsDeviceId*) */
758 inline bool isMtMk5_X00() const
759 {
760 return 0 != XsDeviceId_isMtMk5_X00(this);
761 }
762 /*! \brief \copybrief XsDeviceId_isMtMk5_100(const struct XsDeviceId*) */
763 inline bool isMtMk5_100() const
764 {
765 return 0 != XsDeviceId_isMtMk5_100(this);
766 }
767 /*! \brief \copybrief XsDeviceId_isMtMk5_200(const struct XsDeviceId*) */
768 inline bool isMtMk5_200() const
769 {
770 return 0 != XsDeviceId_isMtMk5_200(this);
771 }
772 /*! \brief \copybrief XsDeviceId_isMtMk5_300(const struct XsDeviceId*) */
773 inline bool isMtMk5_300() const
774 {
775 return 0 != XsDeviceId_isMtMk5_300(this);
776 }
777 /*! \brief \copybrief XsDeviceId_isMtMk5_710(const struct XsDeviceId*) */
778 inline bool isMtMk5_710() const
779 {
780 return 0 != XsDeviceId_isMtMk5_710(this);
781 }
782
783 //============================================================================================================
784
785 private:
786 #endif
787 uint64_t m_deviceId; //!< The serialnumber of a device
788 char m_productCode[24]; //!< The productcode of a device
789 uint16_t m_hardwareVersion; //!< The hardware version of a device
790 uint32_t m_productVariant; //!< The product variant of a device
791 };
792
793 typedef struct XsDeviceId XsDeviceId;
794
795 #if defined(__cplusplus) && !defined(XSENS_NO_STL)
796 namespace std
797 {
798 template<typename _CharT, typename _Traits>
799 basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& o, XsDeviceId const& xd)
800 {
801 return (o << xd.toString());
802 }
803 }
804
805 inline XsString& operator<<(XsString& o, XsDeviceId const& xd)
806 {
807 o.append(xd.toString());
808 return o;
809 }
810
811 #endif
812
813 #endif