gusimplewhiteboard
TeleoperationControl.hpp
Go to the documentation of this file.
1/*
2 * file TeleoperationControl.hpp
3 *
4 * This file was generated by classgenerator from teleoperationControl.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_TeleoperationControl_h
61#define guWhiteboard_TeleoperationControl_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_TeleoperationControl_DEFINED
73#define guWhiteboard_TeleoperationControl_DEFINED
74
75#undef TeleoperationControl_DEFINED
76#define TeleoperationControl_DEFINED
77
78namespace guWhiteboard {
79
84
85 private:
86
90 void init(uint8_t t_ip = 0, int32_t t_action = 0, int32_t t_stance = 0, int32_t t_streamType = 0, int32_t t_selectedCamera = 0, std::string t_sayString = "") {
91 set_ip(t_ip);
92 set_action(t_action);
93 set_stance(t_stance);
94 set_streamType(t_streamType);
95 set_selectedCamera(t_selectedCamera);
96 gu_strlcpy(const_cast<char *>(this->sayString()), t_sayString.c_str(), 30);
97 }
98
99 public:
100
104 TeleoperationControl(uint8_t t_ip = 0, int32_t t_action = 0, int32_t t_stance = 0, int32_t t_streamType = 0, int32_t t_selectedCamera = 0, std::string t_sayString = "") {
105 this->init(t_ip, t_action, t_stance, t_streamType, t_selectedCamera, t_sayString);
106 }
107
112 this->init(t_other.ip(), t_other.action(), t_other.stance(), t_other.streamType(), t_other.selectedCamera(), t_other.sayString());
113 }
114
119 this->init(t_other.ip, t_other.action, t_other.stance, t_other.streamType, t_other.selectedCamera, t_other.sayString);
120 }
121
126 this->init(t_other.ip(), t_other.action(), t_other.stance(), t_other.streamType(), t_other.selectedCamera(), t_other.sayString());
127 return *this;
128 }
129
134 this->init(t_other.ip, t_other.action, t_other.stance, t_other.streamType, t_other.selectedCamera, t_other.sayString);
135 return *this;
136 }
137
138 bool operator ==(const TeleoperationControl &t_other) const
139 {
140 return ip() == t_other.ip()
141 && action() == t_other.action()
142 && stance() == t_other.stance()
143 && streamType() == t_other.streamType()
144 && selectedCamera() == t_other.selectedCamera()
145 && 0 == strncmp(sayString(), t_other.sayString(), 30);
146 }
147
148 bool operator !=(const TeleoperationControl &t_other) const
149 {
150 return !(*this == t_other);
151 }
152
153 bool operator ==(const wb_teleoperation_control &t_other) const
154 {
155 return *this == TeleoperationControl(t_other);
156 }
157
158 bool operator !=(const wb_teleoperation_control &t_other) const
159 {
160 return !(*this == t_other);
161 }
162
163 uint8_t & ip()
164 {
166 }
167
168 const uint8_t & ip() const
169 {
171 }
172
173 void set_ip(const uint8_t &t_newValue)
174 {
175 wb_teleoperation_control::ip = t_newValue;
176 }
177
178 int32_t & action()
179 {
181 }
182
183 const int32_t & action() const
184 {
186 }
187
188 void set_action(const int32_t &t_newValue)
189 {
191 }
192
193 int32_t & stance()
194 {
196 }
197
198 const int32_t & stance() const
199 {
201 }
202
203 void set_stance(const int32_t &t_newValue)
204 {
206 }
207
208 int32_t & streamType()
209 {
211 }
212
213 const int32_t & streamType() const
214 {
216 }
217
218 void set_streamType(const int32_t &t_newValue)
219 {
221 }
222
223 int32_t & selectedCamera()
224 {
226 }
227
228 const int32_t & selectedCamera() const
229 {
231 }
232
233 void set_selectedCamera(const int32_t &t_newValue)
234 {
236 }
237
238 const char * sayString() const
239 {
241 }
242
243 size_t sayString_size() const
244 {
245 return 30;
246 }
247
248 char & sayString(int t_i)
249 {
251 }
252
253 const char & sayString(int t_i) const
254 {
256 }
257
258 void set_sayString(const char *t_newValue)
259 {
260 strncpy(wb_teleoperation_control::sayString, t_newValue, 30);
261 }
262
263#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
267 TeleoperationControl(const std::string &t_str) {
268 this->init();
269 this->from_string(t_str);
270 }
271
272 std::string description() {
273#ifdef USE_WB_TELEOPERATION_CONTROL_C_CONVERSION
275 wb_teleoperation_control_description(this, buffer, sizeof(buffer));
276 std::string descr = buffer;
277 return descr;
278#else
279 std::ostringstream ss;
280 ss << "ip=" << static_cast<unsigned>(this->ip());
281 ss << ", ";
282 ss << "action=" << static_cast<signed>(this->action());
283 ss << ", ";
284 ss << "stance=" << static_cast<signed>(this->stance());
285 ss << ", ";
286 ss << "streamType=" << static_cast<signed>(this->streamType());
287 ss << ", ";
288 ss << "selectedCamera=" << static_cast<signed>(this->selectedCamera());
289 ss << ", ";
290 if (0 == strncmp("", this->sayString(), 1)) {
291 ss << "sayString=" << "";
292 } else {
293 ss << "sayString=" << this->sayString();
294 }
295 return ss.str();
296#endif
297 }
298
299 std::string to_string() {
300#ifdef USE_WB_TELEOPERATION_CONTROL_C_CONVERSION
302 wb_teleoperation_control_to_string(this, buffer, sizeof(buffer));
303 std::string toString = buffer;
304 return toString;
305#else
306 std::ostringstream ss;
307 ss << static_cast<unsigned>(this->ip());
308 ss << ", ";
309 ss << static_cast<signed>(this->action());
310 ss << ", ";
311 ss << static_cast<signed>(this->stance());
312 ss << ", ";
313 ss << static_cast<signed>(this->streamType());
314 ss << ", ";
315 ss << static_cast<signed>(this->selectedCamera());
316 ss << ", ";
317 if (0 == strncmp("", this->sayString(), 1)) {
318 ss << "";
319 } else {
320 ss << this->sayString();
321 }
322 return ss.str();
323#endif
324 }
325
326#ifdef USE_WB_TELEOPERATION_CONTROL_C_CONVERSION
327 void from_string(const std::string &t_str) {
328 wb_teleoperation_control_from_string(this, t_str.c_str());
329#else
330 void from_string(const std::string &t_str) {
331 char * str_cstr = const_cast<char *>(t_str.c_str());
332 size_t temp_length = strlen(str_cstr);
333 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
334 if (length < 1 || length > TELEOPERATIONCONTROL_DESC_BUFFER_SIZE) {
335 return;
336 }
337 char var_str_buffer[TELEOPERATIONCONTROL_DESC_BUFFER_SIZE + 1];
338 char* var_str = &var_str_buffer[0];
339 char key_buffer[15];
340 char* key = &key_buffer[0];
341 int bracecount = 0;
342 int startVar = 0;
343 int index = 0;
344 int startKey = 0;
345 int endKey = -1;
346 int varIndex = 0;
347 if (index == 0 && str_cstr[0] == '{') {
348 index = 1;
349 }
350 startVar = index;
351 startKey = startVar;
352 do {
353 for (int i = index; i < length; i++) {
354 index = i + 1;
355 if (bracecount == 0 && str_cstr[i] == '=') {
356 endKey = i - 1;
357 startVar = index;
358 continue;
359 }
360 if (bracecount == 0 && isspace(str_cstr[i])) {
361 startVar = index;
362 if (endKey == -1) {
363 startKey = index;
364 }
365 continue;
366 }
367 if (bracecount == 0 && str_cstr[i] == ',') {
368 index = i - 1;
369 break;
370 }
371 if (str_cstr[i] == '{') {
372 bracecount++;
373 continue;
374 }
375 if (str_cstr[i] == '}') {
376 bracecount--;
377 if (bracecount < 0) {
378 index = i - 1;
379 break;
380 }
381 }
382 if (i == length - 1) {
383 index = i;
384 }
385 }
386 if (endKey >= startKey && endKey - startKey < length) {
387 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
388 key[(endKey - startKey) + 1] = 0;
389 } else {
390 key[0] = 0;
391 }
392 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
393 var_str[(index - startVar) + 1] = 0;
394 bracecount = 0;
395 index += 2;
396 startVar = index;
397 startKey = startVar;
398 endKey = -1;
399 if (strlen(key) > 0) {
400 if (0 == strcmp("ip", key)) {
401 varIndex = 0;
402 } else if (0 == strcmp("action", key)) {
403 varIndex = 1;
404 } else if (0 == strcmp("stance", key)) {
405 varIndex = 2;
406 } else if (0 == strcmp("streamType", key)) {
407 varIndex = 3;
408 } else if (0 == strcmp("selectedCamera", key)) {
409 varIndex = 4;
410 } else if (0 == strcmp("sayString", key)) {
411 varIndex = 5;
412 } else {
413 varIndex = -1;
414 }
415 }
416 switch (varIndex) {
417 case -1: { break; }
418 case 0:
419 {
420 this->set_ip(static_cast<uint8_t>(atoi(var_str)));
421 break;
422 }
423 case 1:
424 {
425 this->set_action(static_cast<int32_t>(atoi(var_str)));
426 break;
427 }
428 case 2:
429 {
430 this->set_stance(static_cast<int32_t>(atoi(var_str)));
431 break;
432 }
433 case 3:
434 {
435 this->set_streamType(static_cast<int32_t>(atoi(var_str)));
436 break;
437 }
438 case 4:
439 {
440 this->set_selectedCamera(static_cast<int32_t>(atoi(var_str)));
441 break;
442 }
443 case 5:
444 {
445 strncpy(wb_teleoperation_control::sayString, var_str, 30);
446 break;
447 }
448 }
449 if (varIndex >= 0) {
450 varIndex++;
451 }
452 } while(index < length);
453#endif
454 }
455#endif
456 };
457
458}
459
460#endif
Provides a C++ wrapper around wb_teleoperation_control.
void set_ip(const uint8_t &t_newValue)
void set_selectedCamera(const int32_t &t_newValue)
void set_action(const int32_t &t_newValue)
bool operator!=(const TeleoperationControl &t_other) const
void set_streamType(const int32_t &t_newValue)
TeleoperationControl(uint8_t t_ip=0, int32_t t_action=0, int32_t t_stance=0, int32_t t_streamType=0, int32_t t_selectedCamera=0, std::string t_sayString="")
Create a new TeleoperationControl.
void set_sayString(const char *t_newValue)
TeleoperationControl(const std::string &t_str)
String Constructor.
void from_string(const std::string &t_str)
const char & sayString(int t_i) const
TeleoperationControl(const struct wb_teleoperation_control &t_other)
Copy Constructor.
TeleoperationControl(const TeleoperationControl &t_other)
Copy Constructor.
void set_stance(const int32_t &t_newValue)
bool operator==(const TeleoperationControl &t_other) const
TeleoperationControl & operator=(const TeleoperationControl &t_other)
Copy Assignment Operator.
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
char sayString[30]
String passed to Say_t.
int32_t streamType
Use enum StreamingType (Vision_Control.h)
int32_t selectedCamera
VisionCamera.
int32_t action
Use guWhiteboard::Motions::action enum values!
uint8_t ip
Last octet of IP address.
int32_t stance
guWhiteboard::Motions::stance
struct wb_teleoperation_control * wb_teleoperation_control_from_string(struct wb_teleoperation_control *self, const char *str)
Convert from a string.
const char * wb_teleoperation_control_description(const struct wb_teleoperation_control *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_teleoperation_control_to_string(const struct wb_teleoperation_control *self, char *toString, size_t bufferSize)
Convert to a string.
#define TELEOPERATIONCONTROL_DESC_BUFFER_SIZE
#define TELEOPERATIONCONTROL_TO_STRING_BUFFER_SIZE