gusimplewhiteboard
SensorsHandSensors.hpp
Go to the documentation of this file.
1/*
2 * file SensorsHandSensors.hpp
3 *
4 * This file was generated by classgenerator from sensors_hand_sensors.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Dimitri Joukoff. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials
19 * provided with the distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgement:
23 *
24 * This product includes software developed by Dimitri Joukoff.
25 *
26 * 4. Neither the name of the author nor the names of contributors
27 * may be used to endorse or promote products derived from this
28 * software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
34 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
37 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
38 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 * -----------------------------------------------------------------------
43 * This program is free software; you can redistribute it and/or
44 * modify it under the above terms or under the terms of the GNU
45 * General Public License as published by the Free Software Foundation;
46 * either version 2 of the License, or (at your option) any later version.
47 *
48 * This program is distributed in the hope that it will be useful,
49 * but WITHOUT ANY WARRANTY; without even the implied warranty of
50 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51 * GNU General Public License for more details.
52 *
53 * You should have received a copy of the GNU General Public License
54 * along with this program; if not, see http://www.gnu.org/licenses/
55 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
56 * Fifth Floor, Boston, MA 02110-1301, USA.
57 *
58 */
59
60#ifndef guWhiteboard_SensorsHandSensors_h
61#define guWhiteboard_SensorsHandSensors_h
62
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
64#include <cstdlib>
65#include <string.h>
66#include <sstream>
67#endif
68
69#include <gu_util.h>
71
72#undef guWhiteboard_SensorsHandSensors_DEFINED
73#define guWhiteboard_SensorsHandSensors_DEFINED
74
75#undef SensorsHandSensors_DEFINED
76#define SensorsHandSensors_DEFINED
77
78namespace guWhiteboard {
79
84
85 private:
86
90 void init(bool t_LHand_Touch_Left = true, bool t_LHand_Touch_Back = true, bool t_LHand_Touch_Right = true, bool t_RHand_Touch_Left = true, bool t_RHand_Touch_Back = true, bool t_RHand_Touch_Right = true) {
91 set_LHand_Touch_Left(t_LHand_Touch_Left);
92 set_LHand_Touch_Back(t_LHand_Touch_Back);
93 set_LHand_Touch_Right(t_LHand_Touch_Right);
94 set_RHand_Touch_Left(t_RHand_Touch_Left);
95 set_RHand_Touch_Back(t_RHand_Touch_Back);
96 set_RHand_Touch_Right(t_RHand_Touch_Right);
97 }
98
99 public:
100
104 SensorsHandSensors(bool t_LHand_Touch_Left = true, bool t_LHand_Touch_Back = true, bool t_LHand_Touch_Right = true, bool t_RHand_Touch_Left = true, bool t_RHand_Touch_Back = true, bool t_RHand_Touch_Right = true) {
105 this->init(t_LHand_Touch_Left, t_LHand_Touch_Back, t_LHand_Touch_Right, t_RHand_Touch_Left, t_RHand_Touch_Back, t_RHand_Touch_Right);
106 }
107
112 this->init(t_other.LHand_Touch_Left(), t_other.LHand_Touch_Back(), t_other.LHand_Touch_Right(), t_other.RHand_Touch_Left(), t_other.RHand_Touch_Back(), t_other.RHand_Touch_Right());
113 }
114
119 this->init(t_other.LHand_Touch_Left, t_other.LHand_Touch_Back, t_other.LHand_Touch_Right, t_other.RHand_Touch_Left, t_other.RHand_Touch_Back, t_other.RHand_Touch_Right);
120 }
121
126 this->init(t_other.LHand_Touch_Left(), t_other.LHand_Touch_Back(), t_other.LHand_Touch_Right(), t_other.RHand_Touch_Left(), t_other.RHand_Touch_Back(), t_other.RHand_Touch_Right());
127 return *this;
128 }
129
134 this->init(t_other.LHand_Touch_Left, t_other.LHand_Touch_Back, t_other.LHand_Touch_Right, t_other.RHand_Touch_Left, t_other.RHand_Touch_Back, t_other.RHand_Touch_Right);
135 return *this;
136 }
137
138 bool operator ==(const SensorsHandSensors &t_other) const
139 {
140 return LHand_Touch_Left() == t_other.LHand_Touch_Left()
141 && LHand_Touch_Back() == t_other.LHand_Touch_Back()
142 && LHand_Touch_Right() == t_other.LHand_Touch_Right()
143 && RHand_Touch_Left() == t_other.RHand_Touch_Left()
144 && RHand_Touch_Back() == t_other.RHand_Touch_Back()
145 && RHand_Touch_Right() == t_other.RHand_Touch_Right();
146 }
147
148 bool operator !=(const SensorsHandSensors &t_other) const
149 {
150 return !(*this == t_other);
151 }
152
153 bool operator ==(const wb_sensors_hand_sensors &t_other) const
154 {
155 return *this == SensorsHandSensors(t_other);
156 }
157
158 bool operator !=(const wb_sensors_hand_sensors &t_other) const
159 {
160 return !(*this == t_other);
161 }
162
164 {
166 }
167
168 const bool & LHand_Touch_Left() const
169 {
171 }
172
173 void set_LHand_Touch_Left(const bool &t_newValue)
174 {
176 }
177
179 {
181 }
182
183 const bool & LHand_Touch_Back() const
184 {
186 }
187
188 void set_LHand_Touch_Back(const bool &t_newValue)
189 {
191 }
192
194 {
196 }
197
198 const bool & LHand_Touch_Right() const
199 {
201 }
202
203 void set_LHand_Touch_Right(const bool &t_newValue)
204 {
206 }
207
209 {
211 }
212
213 const bool & RHand_Touch_Left() const
214 {
216 }
217
218 void set_RHand_Touch_Left(const bool &t_newValue)
219 {
221 }
222
224 {
226 }
227
228 const bool & RHand_Touch_Back() const
229 {
231 }
232
233 void set_RHand_Touch_Back(const bool &t_newValue)
234 {
236 }
237
239 {
241 }
242
243 const bool & RHand_Touch_Right() const
244 {
246 }
247
248 void set_RHand_Touch_Right(const bool &t_newValue)
249 {
251 }
252
253#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
257 SensorsHandSensors(const std::string &t_str) {
258 this->init();
259 this->from_string(t_str);
260 }
261
262 std::string description() {
263#ifdef USE_WB_SENSORS_HAND_SENSORS_C_CONVERSION
265 wb_sensors_hand_sensors_description(this, buffer, sizeof(buffer));
266 std::string descr = buffer;
267 return descr;
268#else
269 std::ostringstream ss;
270 ss << "LHand_Touch_Left=" << (this->LHand_Touch_Left() ? "true" : "false");
271 ss << ", ";
272 ss << "LHand_Touch_Back=" << (this->LHand_Touch_Back() ? "true" : "false");
273 ss << ", ";
274 ss << "LHand_Touch_Right=" << (this->LHand_Touch_Right() ? "true" : "false");
275 ss << ", ";
276 ss << "RHand_Touch_Left=" << (this->RHand_Touch_Left() ? "true" : "false");
277 ss << ", ";
278 ss << "RHand_Touch_Back=" << (this->RHand_Touch_Back() ? "true" : "false");
279 ss << ", ";
280 ss << "RHand_Touch_Right=" << (this->RHand_Touch_Right() ? "true" : "false");
281 return ss.str();
282#endif
283 }
284
285 std::string to_string() {
286#ifdef USE_WB_SENSORS_HAND_SENSORS_C_CONVERSION
288 wb_sensors_hand_sensors_to_string(this, buffer, sizeof(buffer));
289 std::string toString = buffer;
290 return toString;
291#else
292 std::ostringstream ss;
293 ss << (this->LHand_Touch_Left() ? "true" : "false");
294 ss << ", ";
295 ss << (this->LHand_Touch_Back() ? "true" : "false");
296 ss << ", ";
297 ss << (this->LHand_Touch_Right() ? "true" : "false");
298 ss << ", ";
299 ss << (this->RHand_Touch_Left() ? "true" : "false");
300 ss << ", ";
301 ss << (this->RHand_Touch_Back() ? "true" : "false");
302 ss << ", ";
303 ss << (this->RHand_Touch_Right() ? "true" : "false");
304 return ss.str();
305#endif
306 }
307
308#ifdef USE_WB_SENSORS_HAND_SENSORS_C_CONVERSION
309 void from_string(const std::string &t_str) {
310 wb_sensors_hand_sensors_from_string(this, t_str.c_str());
311#else
312 void from_string(const std::string &t_str) {
313 char * str_cstr = const_cast<char *>(t_str.c_str());
314 size_t temp_length = strlen(str_cstr);
315 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
316 if (length < 1 || length > SENSORS_HAND_SENSORS_DESC_BUFFER_SIZE) {
317 return;
318 }
319 char var_str_buffer[SENSORS_HAND_SENSORS_DESC_BUFFER_SIZE + 1];
320 char* var_str = &var_str_buffer[0];
321 char key_buffer[18];
322 char* key = &key_buffer[0];
323 int bracecount = 0;
324 int startVar = 0;
325 int index = 0;
326 int startKey = 0;
327 int endKey = -1;
328 int varIndex = 0;
329 if (index == 0 && str_cstr[0] == '{') {
330 index = 1;
331 }
332 startVar = index;
333 startKey = startVar;
334 do {
335 for (int i = index; i < length; i++) {
336 index = i + 1;
337 if (bracecount == 0 && str_cstr[i] == '=') {
338 endKey = i - 1;
339 startVar = index;
340 continue;
341 }
342 if (bracecount == 0 && isspace(str_cstr[i])) {
343 startVar = index;
344 if (endKey == -1) {
345 startKey = index;
346 }
347 continue;
348 }
349 if (bracecount == 0 && str_cstr[i] == ',') {
350 index = i - 1;
351 break;
352 }
353 if (str_cstr[i] == '{') {
354 bracecount++;
355 continue;
356 }
357 if (str_cstr[i] == '}') {
358 bracecount--;
359 if (bracecount < 0) {
360 index = i - 1;
361 break;
362 }
363 }
364 if (i == length - 1) {
365 index = i;
366 }
367 }
368 if (endKey >= startKey && endKey - startKey < length) {
369 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
370 key[(endKey - startKey) + 1] = 0;
371 } else {
372 key[0] = 0;
373 }
374 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
375 var_str[(index - startVar) + 1] = 0;
376 bracecount = 0;
377 index += 2;
378 startVar = index;
379 startKey = startVar;
380 endKey = -1;
381 if (strlen(key) > 0) {
382 if (0 == strcmp("LHand_Touch_Left", key)) {
383 varIndex = 0;
384 } else if (0 == strcmp("LHand_Touch_Back", key)) {
385 varIndex = 1;
386 } else if (0 == strcmp("LHand_Touch_Right", key)) {
387 varIndex = 2;
388 } else if (0 == strcmp("RHand_Touch_Left", key)) {
389 varIndex = 3;
390 } else if (0 == strcmp("RHand_Touch_Back", key)) {
391 varIndex = 4;
392 } else if (0 == strcmp("RHand_Touch_Right", key)) {
393 varIndex = 5;
394 } else {
395 varIndex = -1;
396 }
397 }
398 switch (varIndex) {
399 case -1: { break; }
400 case 0:
401 {
402 this->set_LHand_Touch_Left(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
403 break;
404 }
405 case 1:
406 {
407 this->set_LHand_Touch_Back(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
408 break;
409 }
410 case 2:
411 {
412 this->set_LHand_Touch_Right(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
413 break;
414 }
415 case 3:
416 {
417 this->set_RHand_Touch_Left(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
418 break;
419 }
420 case 4:
421 {
422 this->set_RHand_Touch_Back(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
423 break;
424 }
425 case 5:
426 {
427 this->set_RHand_Touch_Right(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
428 break;
429 }
430 }
431 if (varIndex >= 0) {
432 varIndex++;
433 }
434 } while(index < length);
435#endif
436 }
437#endif
438 };
439
440}
441
442#endif
Provides a C++ wrapper around wb_sensors_hand_sensors.
void set_LHand_Touch_Right(const bool &t_newValue)
SensorsHandSensors(const struct wb_sensors_hand_sensors &t_other)
Copy Constructor.
bool operator!=(const SensorsHandSensors &t_other) const
SensorsHandSensors(bool t_LHand_Touch_Left=true, bool t_LHand_Touch_Back=true, bool t_LHand_Touch_Right=true, bool t_RHand_Touch_Left=true, bool t_RHand_Touch_Back=true, bool t_RHand_Touch_Right=true)
Create a new SensorsHandSensors.
void set_LHand_Touch_Back(const bool &t_newValue)
void set_RHand_Touch_Left(const bool &t_newValue)
void from_string(const std::string &t_str)
SensorsHandSensors(const std::string &t_str)
String Constructor.
SensorsHandSensors(const SensorsHandSensors &t_other)
Copy Constructor.
SensorsHandSensors & operator=(const SensorsHandSensors &t_other)
Copy Assignment Operator.
void set_LHand_Touch_Left(const bool &t_newValue)
bool operator==(const SensorsHandSensors &t_other) const
void set_RHand_Touch_Right(const bool &t_newValue)
void set_RHand_Touch_Back(const bool &t_newValue)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
bool RHand_Touch_Back
state of the hand capacitive sensor on the Back of Right Hand, on / off.
bool RHand_Touch_Right
state of the hand capacitive sensor on the Right side of Right Hand, on / off.
bool LHand_Touch_Right
state of the hand capacitive sensor on the Right side of Left Hand, on / off.
bool RHand_Touch_Left
state of the hand capacitive sensor on the Left side of Right Hand, on / off.
bool LHand_Touch_Left
state of the hand capacitive sensor on the Left side of Left Hand, on / off.
bool LHand_Touch_Back
state of the hand capacitive sensor on the Back of Left Hand, on / off.
const char * wb_sensors_hand_sensors_description(const struct wb_sensors_hand_sensors *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_sensors_hand_sensors_to_string(const struct wb_sensors_hand_sensors *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_sensors_hand_sensors * wb_sensors_hand_sensors_from_string(struct wb_sensors_hand_sensors *self, const char *str)
Convert from a string.
#define SENSORS_HAND_SENSORS_DESC_BUFFER_SIZE
#define SENSORS_HAND_SENSORS_TO_STRING_BUFFER_SIZE