gusimplewhiteboard
GuVrTeleopVulkanControl.hpp
Go to the documentation of this file.
1/*
2 * file GuVrTeleopVulkanControl.hpp
3 *
4 * This file was generated by classgenerator from gu_vr_teleop_vulkan_control.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Carl Lusty. 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 Carl Lusty.
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_GuVrTeleopVulkanControl_h
61#define guWhiteboard_GuVrTeleopVulkanControl_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_GuVrTeleopVulkanControl_DEFINED
73#define guWhiteboard_GuVrTeleopVulkanControl_DEFINED
74
75#undef GuVrTeleopVulkanControl_DEFINED
76#define GuVrTeleopVulkanControl_DEFINED
77
78namespace guWhiteboard {
79
84
85 private:
86
90 void init(enum VRControlMovementOptions t_movementOptions = VRResting, enum VRControlWalkingOptions t_walkingOptions = NUM_VR_CONTROL_WALKING_OPTIONS) {
91 set_movementOptions(t_movementOptions);
92 set_walkingOptions(t_walkingOptions);
93 }
94
95 public:
96
101 this->init(t_movementOptions, t_walkingOptions);
102 }
103
108 this->init(t_other.movementOptions(), t_other.walkingOptions());
109 }
110
115 this->init(t_other.movementOptions, t_other.walkingOptions);
116 }
117
122 this->init(t_other.movementOptions(), t_other.walkingOptions());
123 return *this;
124 }
125
130 this->init(t_other.movementOptions, t_other.walkingOptions);
131 return *this;
132 }
133
134 bool operator ==(const GuVrTeleopVulkanControl &t_other) const
135 {
136 return movementOptions() == t_other.movementOptions()
137 && walkingOptions() == t_other.walkingOptions();
138 }
139
140 bool operator !=(const GuVrTeleopVulkanControl &t_other) const
141 {
142 return !(*this == t_other);
143 }
144
146 {
147 return *this == GuVrTeleopVulkanControl(t_other);
148 }
149
151 {
152 return !(*this == t_other);
153 }
154
156 {
158 }
159
161 {
163 }
164
166 {
168 }
169
171 {
173 }
174
176 {
178 }
179
180 void set_walkingOptions(const enum VRControlWalkingOptions &t_newValue)
181 {
183 }
184
185#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
189 GuVrTeleopVulkanControl(const std::string &t_str) {
190 this->init();
191 this->from_string(t_str);
192 }
193
194 std::string description() {
195#ifdef USE_WB_GU_VR_TELEOP_VULKAN_CONTROL_C_CONVERSION
197 wb_gu_vr_teleop_vulkan_control_description(this, buffer, sizeof(buffer));
198 std::string descr = buffer;
199 return descr;
200#else
201 std::ostringstream ss;
202 switch (this->movementOptions()) {
203 case VRResting:
204 {
205 ss << "movementOptions=" << "VRResting";
206 break;
207 }
208 case VRStanding:
209 {
210 ss << "movementOptions=" << "VRStanding";
211 break;
212 }
213 case VRWalking:
214 {
215 ss << "movementOptions=" << "VRWalking";
216 break;
217 }
218 }
219 ss << ", ";
220 switch (this->walkingOptions()) {
222 {
223 ss << "walkingOptions=" << "NUM_VR_CONTROL_WALKING_OPTIONS";
224 break;
225 }
226 case VRMovementBack:
227 {
228 ss << "walkingOptions=" << "VRMovementBack";
229 break;
230 }
232 {
233 ss << "walkingOptions=" << "VRMovementForward";
234 break;
235 }
236 case VRMovementLeft:
237 {
238 ss << "walkingOptions=" << "VRMovementLeft";
239 break;
240 }
241 case VRMovementRight:
242 {
243 ss << "walkingOptions=" << "VRMovementRight";
244 break;
245 }
247 {
248 ss << "walkingOptions=" << "VRMovementRotateLeft";
249 break;
250 }
252 {
253 ss << "walkingOptions=" << "VRMovementRotateRight";
254 break;
255 }
256 }
257 return ss.str();
258#endif
259 }
260
261 std::string to_string() {
262#ifdef USE_WB_GU_VR_TELEOP_VULKAN_CONTROL_C_CONVERSION
264 wb_gu_vr_teleop_vulkan_control_to_string(this, buffer, sizeof(buffer));
265 std::string toString = buffer;
266 return toString;
267#else
268 std::ostringstream ss;
269 switch (this->movementOptions()) {
270 case VRResting:
271 {
272 ss << "VRResting";
273 break;
274 }
275 case VRStanding:
276 {
277 ss << "VRStanding";
278 break;
279 }
280 case VRWalking:
281 {
282 ss << "VRWalking";
283 break;
284 }
285 }
286 ss << ", ";
287 switch (this->walkingOptions()) {
289 {
290 ss << "NUM_VR_CONTROL_WALKING_OPTIONS";
291 break;
292 }
293 case VRMovementBack:
294 {
295 ss << "VRMovementBack";
296 break;
297 }
299 {
300 ss << "VRMovementForward";
301 break;
302 }
303 case VRMovementLeft:
304 {
305 ss << "VRMovementLeft";
306 break;
307 }
308 case VRMovementRight:
309 {
310 ss << "VRMovementRight";
311 break;
312 }
314 {
315 ss << "VRMovementRotateLeft";
316 break;
317 }
319 {
320 ss << "VRMovementRotateRight";
321 break;
322 }
323 }
324 return ss.str();
325#endif
326 }
327
328#ifdef USE_WB_GU_VR_TELEOP_VULKAN_CONTROL_C_CONVERSION
329 void from_string(const std::string &t_str) {
331#else
332 void from_string(const std::string &t_str) {
333 char * str_cstr = const_cast<char *>(t_str.c_str());
334 size_t temp_length = strlen(str_cstr);
335 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
336 if (length < 1 || length > GU_VR_TELEOP_VULKAN_CONTROL_DESC_BUFFER_SIZE) {
337 return;
338 }
339 char var_str_buffer[GU_VR_TELEOP_VULKAN_CONTROL_DESC_BUFFER_SIZE + 1];
340 char* var_str = &var_str_buffer[0];
341 char key_buffer[16];
342 char* key = &key_buffer[0];
343 int bracecount = 0;
344 int startVar = 0;
345 int index = 0;
346 int startKey = 0;
347 int endKey = -1;
348 int varIndex = 0;
349 if (index == 0 && str_cstr[0] == '{') {
350 index = 1;
351 }
352 startVar = index;
353 startKey = startVar;
354 do {
355 for (int i = index; i < length; i++) {
356 index = i + 1;
357 if (bracecount == 0 && str_cstr[i] == '=') {
358 endKey = i - 1;
359 startVar = index;
360 continue;
361 }
362 if (bracecount == 0 && isspace(str_cstr[i])) {
363 startVar = index;
364 if (endKey == -1) {
365 startKey = index;
366 }
367 continue;
368 }
369 if (bracecount == 0 && str_cstr[i] == ',') {
370 index = i - 1;
371 break;
372 }
373 if (str_cstr[i] == '{') {
374 bracecount++;
375 continue;
376 }
377 if (str_cstr[i] == '}') {
378 bracecount--;
379 if (bracecount < 0) {
380 index = i - 1;
381 break;
382 }
383 }
384 if (i == length - 1) {
385 index = i;
386 }
387 }
388 if (endKey >= startKey && endKey - startKey < length) {
389 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
390 key[(endKey - startKey) + 1] = 0;
391 } else {
392 key[0] = 0;
393 }
394 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
395 var_str[(index - startVar) + 1] = 0;
396 bracecount = 0;
397 index += 2;
398 startVar = index;
399 startKey = startVar;
400 endKey = -1;
401 if (strlen(key) > 0) {
402 if (0 == strcmp("movementOptions", key)) {
403 varIndex = 0;
404 } else if (0 == strcmp("walkingOptions", key)) {
405 varIndex = 1;
406 } else {
407 varIndex = -1;
408 }
409 }
410 switch (varIndex) {
411 case -1: { break; }
412 case 0:
413 {
414 if (strcmp("VRResting", var_str) == 0) {
415#pragma clang diagnostic push
416#pragma clang diagnostic ignored "-Wbad-function-cast"
418#pragma clang diagnostic pop
419 } else if (strcmp("VRStanding", var_str) == 0) {
420#pragma clang diagnostic push
421#pragma clang diagnostic ignored "-Wbad-function-cast"
423#pragma clang diagnostic pop
424 } else if (strcmp("VRWalking", var_str) == 0) {
425#pragma clang diagnostic push
426#pragma clang diagnostic ignored "-Wbad-function-cast"
428#pragma clang diagnostic pop
429 } else {
430#pragma clang diagnostic push
431#pragma clang diagnostic ignored "-Wbad-function-cast"
432 this->set_movementOptions(static_cast<enum VRControlMovementOptions>(atoi(var_str)));
433#pragma clang diagnostic pop
434 }
435 break;
436 }
437 case 1:
438 {
439 if (strcmp("NUM_VR_CONTROL_WALKING_OPTIONS", var_str) == 0) {
440#pragma clang diagnostic push
441#pragma clang diagnostic ignored "-Wbad-function-cast"
443#pragma clang diagnostic pop
444 } else if (strcmp("VRMovementBack", var_str) == 0) {
445#pragma clang diagnostic push
446#pragma clang diagnostic ignored "-Wbad-function-cast"
448#pragma clang diagnostic pop
449 } else if (strcmp("VRMovementForward", var_str) == 0) {
450#pragma clang diagnostic push
451#pragma clang diagnostic ignored "-Wbad-function-cast"
453#pragma clang diagnostic pop
454 } else if (strcmp("VRMovementLeft", var_str) == 0) {
455#pragma clang diagnostic push
456#pragma clang diagnostic ignored "-Wbad-function-cast"
458#pragma clang diagnostic pop
459 } else if (strcmp("VRMovementRight", var_str) == 0) {
460#pragma clang diagnostic push
461#pragma clang diagnostic ignored "-Wbad-function-cast"
463#pragma clang diagnostic pop
464 } else if (strcmp("VRMovementRotateLeft", var_str) == 0) {
465#pragma clang diagnostic push
466#pragma clang diagnostic ignored "-Wbad-function-cast"
468#pragma clang diagnostic pop
469 } else if (strcmp("VRMovementRotateRight", var_str) == 0) {
470#pragma clang diagnostic push
471#pragma clang diagnostic ignored "-Wbad-function-cast"
473#pragma clang diagnostic pop
474 } else {
475#pragma clang diagnostic push
476#pragma clang diagnostic ignored "-Wbad-function-cast"
477 this->set_walkingOptions(static_cast<enum VRControlWalkingOptions>(atoi(var_str)));
478#pragma clang diagnostic pop
479 }
480 break;
481 }
482 }
483 if (varIndex >= 0) {
484 varIndex++;
485 }
486 } while(index < length);
487#endif
488 }
489#endif
490 };
491
492}
493
494#endif
Provides a C++ wrapper around wb_gu_vr_teleop_vulkan_control.
enum VRControlWalkingOptions & walkingOptions() const
GuVrTeleopVulkanControl(const std::string &t_str)
String Constructor.
void set_walkingOptions(const enum VRControlWalkingOptions &t_newValue)
enum VRControlMovementOptions & movementOptions() const
void set_movementOptions(const enum VRControlMovementOptions &t_newValue)
bool operator!=(const GuVrTeleopVulkanControl &t_other) const
GuVrTeleopVulkanControl & operator=(const GuVrTeleopVulkanControl &t_other)
Copy Assignment Operator.
GuVrTeleopVulkanControl(enum VRControlMovementOptions t_movementOptions=VRResting, enum VRControlWalkingOptions t_walkingOptions=NUM_VR_CONTROL_WALKING_OPTIONS)
Create a new GuVrTeleopVulkanControl.
GuVrTeleopVulkanControl(const struct wb_gu_vr_teleop_vulkan_control &t_other)
Copy Constructor.
enum VRControlWalkingOptions & walkingOptions()
enum VRControlMovementOptions & movementOptions()
bool operator==(const GuVrTeleopVulkanControl &t_other) const
void from_string(const std::string &t_str)
GuVrTeleopVulkanControl(const GuVrTeleopVulkanControl &t_other)
Copy Constructor.
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
enum VRControlMovementOptions movementOptions
controls the robots movement
enum VRControlWalkingOptions walkingOptions
controls the direction of high-level walk commands
const char * wb_gu_vr_teleop_vulkan_control_description(const struct wb_gu_vr_teleop_vulkan_control *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_gu_vr_teleop_vulkan_control * wb_gu_vr_teleop_vulkan_control_from_string(struct wb_gu_vr_teleop_vulkan_control *self, const char *str)
Convert from a string.
const char * wb_gu_vr_teleop_vulkan_control_to_string(const struct wb_gu_vr_teleop_vulkan_control *self, char *toString, size_t bufferSize)
Convert to a string.
#define GU_VR_TELEOP_VULKAN_CONTROL_TO_STRING_BUFFER_SIZE
#define GU_VR_TELEOP_VULKAN_CONTROL_DESC_BUFFER_SIZE
@ NUM_VR_CONTROL_WALKING_OPTIONS