Debian Codegraph @

3rdparty/xspublic/xstypes/xsglovedata.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 XSGLOVEDATA_H
34 #define XSGLOVEDATA_H
35
36 #include "xstypesconfig.h"
37 #include "xsvector3.h"
38 #include "xsquaternion.h"
39
40 struct XsGloveData;
41 struct XsFingerData;
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 #ifndef __cplusplus
47 #define XSFINGERDATA_INITIALIZER {XSQUATERNION_INITIALIZER, XSVECTOR3_INITIALIZER, XSVECTOR3_INITIALIZER, 0, 0, 0}
48 #define XSGLOVEDATA_INITIALIZER {0, 0, 0, 0, \
49 XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, \
50 XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER, XSFINGERDATA_INITIALIZER }
51 #endif
52
53 XSTYPES_DLL_API void XsFingerData_construct(struct XsFingerData* thisPtr);
54 XSTYPES_DLL_API void XsFingerData_destruct(struct XsFingerData* thisPtr);
55
56 XSTYPES_DLL_API void XsGloveData_construct(struct XsGloveData* thisPtr);
57 XSTYPES_DLL_API void XsGloveData_destruct(struct XsGloveData* thisPtr);
58
59 #ifdef __cplusplus
60 } // extern "C"
61 #endif
62
63 /*! \brief A container for Finger data
64 */
65 struct XsFingerData
66 {
67 #ifdef __cplusplus
68 //! \brief Construct an empty object
69 inline XsFingerData()
70 : m_flags(0)
71 , m_ccAcc(0)
72 , m_ccGyr(0)
73 {
74 }
75
76 //! \brief Construct an initialized object
77 inline XsFingerData(const XsQuaternion& dq, const XsVector& dv, const XsVector& mag, const uint16_t flags, const uint8_t ccAcc, const uint8_t ccGyr)
78 : m_orientationIncrement(dq)
79 , m_velocityIncrement(dv)
80 , m_mag(mag)
81 , m_flags(flags)
82 , m_ccAcc(ccAcc)
83 , m_ccGyr(ccGyr)
84 {
85 }
86
87 //! \brief Copy constructor
88 inline XsFingerData(const XsFingerData& other)
89 : m_orientationIncrement(other.m_orientationIncrement)
90 , m_velocityIncrement(other.m_velocityIncrement)
91 , m_mag(other.m_mag)
92 , m_flags(other.m_flags)
93 , m_ccAcc(other.m_ccAcc)
94 , m_ccGyr(other.m_ccGyr)
95 {
96 }
97
98 //! \brief Assignment operator
99 inline const XsFingerData& operator=(const XsFingerData& other)
100 {
101 if (this != &other)
102 {
103 m_orientationIncrement = other.m_orientationIncrement;
104 m_velocityIncrement = other.m_velocityIncrement;
105 m_mag = other.m_mag;
106 m_flags = other.m_flags;
107 m_ccAcc = other.m_ccAcc;
108 m_ccGyr = other.m_ccGyr;
109 }
110 return *this;
111 }
112
113 //! \brief Clear the object so it contains unity data
114 inline void zero()
115 {
116 m_orientationIncrement = XsQuaternion::identity();
117 m_velocityIncrement.zero();
118 m_mag.zero();
119 }
120
121 //! \brief Returns the contained orientation increment
122 inline const XsQuaternion& orientationIncrement() const
123 {
124 return m_orientationIncrement;
125 }
126
127 //! \brief Update the contained orientation increment
128 inline void setOrientationIncrement(const XsQuaternion& dq)
129 {
130 m_orientationIncrement = dq;
131 }
132
133 //! \brief Returns the contained velocity increment
134 inline const XsVector3& velocityIncrement() const
135 {
136 return m_velocityIncrement;
137 }
138
139 //! \brief Update the contained velocity increment
140 inline void setVelocityIncrement(const XsVector& dv)
141 {
142 m_velocityIncrement = dv;
143 }
144 //! \brief Returns the mag
145 inline const XsVector3& mag() const
146 {
147 return m_mag;
148 }
149
150 //! \brief Update the mag
151 inline void setMag(const XsVector& mag)
152 {
153 m_mag = mag;
154 }
155
156 //! \brief Returns the flags
157 inline const uint16_t& flags() const
158 {
159 return m_flags;
160 }
161
162 //! \brief Update the flags
163 inline void setFlags(const uint16_t& flags)
164 {
165 m_flags = flags;
166 }
167
168 //! \brief Returns the acc clip
169 inline const uint8_t& ccAcc() const
170 {
171 return m_ccAcc;
172 }
173
174 //! \brief Update the acc clip
175 inline void setCcAcc(const uint8_t& ccAcc)
176 {
177 m_ccAcc = ccAcc;
178 }
179
180 //! \brief Returns the gyr clip
181 inline const uint8_t& ccGyr() const
182 {
183 return m_ccGyr;
184 }
185
186 //! \brief Update the gyr clip
187 inline void setCcGyr(const uint8_t& ccGyr)
188 {
189 m_ccGyr = ccGyr;
190 }
191
192 /*! \brief Returns true if all fields of this and \a other are exactly identical */
193 inline bool operator == (const XsFingerData& other) const
194 {
195 return m_orientationIncrement == other.m_orientationIncrement &&
196 m_velocityIncrement == other.m_velocityIncrement &&
197 m_mag == other.m_mag &&
198 m_flags == other.m_flags &&
199 m_ccAcc == other.m_ccAcc &&
200 m_ccGyr == other.m_ccGyr;
201 }
202
203 private:
204 #endif
205
206 XsQuaternion m_orientationIncrement; //!< The orientation increment
207 XsVector3 m_velocityIncrement; //!< The velocity increment
208 XsVector3 m_mag;
209 uint16_t m_flags;
210 uint8_t m_ccAcc;
211 uint8_t m_ccGyr;
212 };
213 typedef struct XsFingerData XsFingerData;
214
215 /*! \brief A container for glove data
216 */
217 struct XsGloveData
218 {
219 #ifdef __cplusplus
220 //! \brief Construct an empty object
221 inline XsGloveData()
222 : m_snapshotCounter(0)
223 , m_validSampleFlags(0)
224 , m_timestamp(0)
225 , m_carpusOffset(0)
226 {
227 }
228
229 //! \brief Construct an initialized object
230 inline XsGloveData(const uint16_t& snapshotCounter, const uint16_t& validSampleFlags, const uint16_t& timestamp, const uint8_t& carpusOffset, const XsFingerData *fingerData)
231 : m_snapshotCounter(snapshotCounter)
232 , m_validSampleFlags(validSampleFlags)
233 , m_timestamp(timestamp)
234 , m_carpusOffset(carpusOffset)
235 {
236 setFingerData(fingerData);
237 }
238
239 //! \brief Copy constructor
240 inline XsGloveData(const XsGloveData& other)
241 : m_snapshotCounter(other.m_snapshotCounter)
242 , m_validSampleFlags(other.m_validSampleFlags)
243 , m_timestamp(other.m_timestamp)
244 , m_carpusOffset(other.m_carpusOffset)
245 {
246 setFingerData(other.m_fingerData);
247 }
248
249 //! \brief Returns the snapshot counter
250 inline const uint16_t& snapshotCounter() const
251 {
252 return m_snapshotCounter;
253 }
254
255 //! \brief Update the snapshot counter
256 inline void setSnapshotCounter(const uint16_t& snapshotCounter)
257 {
258 m_snapshotCounter = snapshotCounter;
259 }
260
261 //! \brief Returns the valid sample flags
262 inline const uint16_t& validSampleFlags() const
263 {
264 return m_validSampleFlags;
265 }
266
267 //! \brief Update the valid sample flags
268 inline void setValidSampleFlags(const uint16_t& validSampleFlags)
269 {
270 m_validSampleFlags = validSampleFlags;
271 }
272
273 //! \brief Returns the timestamp
274 inline const uint16_t& timestamp() const
275 {
276 return m_timestamp;
277 }
278
279 //! \brief Update the timestamp
280 inline void setTimestamp(const uint16_t& timestamp)
281 {
282 m_timestamp = timestamp;
283 }
284
285 //! \brief Returns the carpus offset
286 inline const uint8_t& carpusOffset() const
287 {
288 return m_carpusOffset;
289 }
290
291 //! \brief Update the carpus offset
292 inline void setCarpusOffset(const uint8_t& carpusOffset)
293 {
294 m_carpusOffset = carpusOffset;
295 }
296
297 //! \brief Returns the finger data
298 inline void fingerData(XsFingerData *fingerData) const
299 {
300 for (int i = 0; i < 12; i++)
301 fingerData[i] = m_fingerData[i];
302 }
303
304 //! \brief Update the finger data
305 inline void setFingerData(const XsFingerData *fingerData)
306 {
307 for (int i = 0; i < 12; i++)
308 m_fingerData[i] = fingerData[i];
309 }
310
311 /*! \brief Returns true if all fields of this and \a other are exactly identical */
312 inline bool operator == (const XsGloveData& other) const
313 {
314 if (m_snapshotCounter != other.m_snapshotCounter ||
315 m_validSampleFlags != other.m_validSampleFlags ||
316 m_timestamp != other.m_timestamp ||
317 m_carpusOffset != other.m_carpusOffset)
318 return false;
319
320 for (int i = 0; i < 12; i++)
321 {
322 if (!(m_fingerData[i] == other.m_fingerData[i]))
323 return false;
324 }
325 return true;
326 }
327
328 private:
329 #endif
330 uint16_t m_snapshotCounter;
331 uint16_t m_validSampleFlags;
332 uint16_t m_timestamp; /*!< \brief The timestamp */
333 uint8_t m_carpusOffset;
334 XsFingerData m_fingerData[12];
335 };
336
337 typedef struct XsGloveData XsGloveData;
338
339 #endif // file guard