gusimplewhiteboard
TemperatureSensors.hpp
Go to the documentation of this file.
1/*
2 * file TemperatureSensors.hpp
3 *
4 * This file was generated by classgenerator from temperature_sensors.gen.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Morgan McColl. 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 Morgan McColl.
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_TemperatureSensors_h
61#define guWhiteboard_TemperatureSensors_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_TemperatureSensors_DEFINED
73#define guWhiteboard_TemperatureSensors_DEFINED
74
75#undef TemperatureSensors_DEFINED
76#define TemperatureSensors_DEFINED
77
78namespace guWhiteboard {
79
84
85 private:
86
90 void init(bool t_LKneePitch = false, bool t_LAnklePitch = false, bool t_LAnkleRoll = false, bool t_RKneePitch = false, bool t_RAnklePitch = false, bool t_RAnkleRoll = false) {
91 set_LKneePitch(t_LKneePitch);
92 set_LAnklePitch(t_LAnklePitch);
93 set_LAnkleRoll(t_LAnkleRoll);
94 set_RKneePitch(t_RKneePitch);
95 set_RAnklePitch(t_RAnklePitch);
96 set_RAnkleRoll(t_RAnkleRoll);
97 }
98
99 public:
100
104 TemperatureSensors(bool t_LKneePitch = false, bool t_LAnklePitch = false, bool t_LAnkleRoll = false, bool t_RKneePitch = false, bool t_RAnklePitch = false, bool t_RAnkleRoll = false) {
105 this->init(t_LKneePitch, t_LAnklePitch, t_LAnkleRoll, t_RKneePitch, t_RAnklePitch, t_RAnkleRoll);
106 }
107
112 this->init(t_other.LKneePitch(), t_other.LAnklePitch(), t_other.LAnkleRoll(), t_other.RKneePitch(), t_other.RAnklePitch(), t_other.RAnkleRoll());
113 }
114
119 this->init(t_other.LKneePitch, t_other.LAnklePitch, t_other.LAnkleRoll, t_other.RKneePitch, t_other.RAnklePitch, t_other.RAnkleRoll);
120 }
121
126 this->init(t_other.LKneePitch(), t_other.LAnklePitch(), t_other.LAnkleRoll(), t_other.RKneePitch(), t_other.RAnklePitch(), t_other.RAnkleRoll());
127 return *this;
128 }
129
134 this->init(t_other.LKneePitch, t_other.LAnklePitch, t_other.LAnkleRoll, t_other.RKneePitch, t_other.RAnklePitch, t_other.RAnkleRoll);
135 return *this;
136 }
137
138 bool operator ==(const TemperatureSensors &t_other) const
139 {
140 return LKneePitch() == t_other.LKneePitch()
141 && LAnklePitch() == t_other.LAnklePitch()
142 && LAnkleRoll() == t_other.LAnkleRoll()
143 && RKneePitch() == t_other.RKneePitch()
144 && RAnklePitch() == t_other.RAnklePitch()
145 && RAnkleRoll() == t_other.RAnkleRoll();
146 }
147
148 bool operator !=(const TemperatureSensors &t_other) const
149 {
150 return !(*this == t_other);
151 }
152
153 bool operator ==(const wb_temperature_sensors &t_other) const
154 {
155 return *this == TemperatureSensors(t_other);
156 }
157
158 bool operator !=(const wb_temperature_sensors &t_other) const
159 {
160 return !(*this == t_other);
161 }
162
163 bool & LKneePitch()
164 {
166 }
167
168 const bool & LKneePitch() const
169 {
171 }
172
173 void set_LKneePitch(const bool &t_newValue)
174 {
176 }
177
178 bool & LAnklePitch()
179 {
181 }
182
183 const bool & LAnklePitch() const
184 {
186 }
187
188 void set_LAnklePitch(const bool &t_newValue)
189 {
191 }
192
193 bool & LAnkleRoll()
194 {
196 }
197
198 const bool & LAnkleRoll() const
199 {
201 }
202
203 void set_LAnkleRoll(const bool &t_newValue)
204 {
206 }
207
208 bool & RKneePitch()
209 {
211 }
212
213 const bool & RKneePitch() const
214 {
216 }
217
218 void set_RKneePitch(const bool &t_newValue)
219 {
221 }
222
223 bool & RAnklePitch()
224 {
226 }
227
228 const bool & RAnklePitch() const
229 {
231 }
232
233 void set_RAnklePitch(const bool &t_newValue)
234 {
236 }
237
238 bool & RAnkleRoll()
239 {
241 }
242
243 const bool & RAnkleRoll() const
244 {
246 }
247
248 void set_RAnkleRoll(const bool &t_newValue)
249 {
251 }
252
253#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
257 TemperatureSensors(const std::string &t_str) {
258 this->init();
259 this->from_string(t_str);
260 }
261
262 std::string description() {
263#ifdef USE_WB_TEMPERATURE_SENSORS_C_CONVERSION
265 wb_temperature_sensors_description(this, buffer, sizeof(buffer));
266 std::string descr = buffer;
267 return descr;
268#else
269 std::ostringstream ss;
270 ss << "LKneePitch=" << (this->LKneePitch() ? "true" : "false");
271 ss << ", ";
272 ss << "LAnklePitch=" << (this->LAnklePitch() ? "true" : "false");
273 ss << ", ";
274 ss << "LAnkleRoll=" << (this->LAnkleRoll() ? "true" : "false");
275 ss << ", ";
276 ss << "RKneePitch=" << (this->RKneePitch() ? "true" : "false");
277 ss << ", ";
278 ss << "RAnklePitch=" << (this->RAnklePitch() ? "true" : "false");
279 ss << ", ";
280 ss << "RAnkleRoll=" << (this->RAnkleRoll() ? "true" : "false");
281 return ss.str();
282#endif
283 }
284
285 std::string to_string() {
286#ifdef USE_WB_TEMPERATURE_SENSORS_C_CONVERSION
288 wb_temperature_sensors_to_string(this, buffer, sizeof(buffer));
289 std::string toString = buffer;
290 return toString;
291#else
292 std::ostringstream ss;
293 ss << (this->LKneePitch() ? "true" : "false");
294 ss << ", ";
295 ss << (this->LAnklePitch() ? "true" : "false");
296 ss << ", ";
297 ss << (this->LAnkleRoll() ? "true" : "false");
298 ss << ", ";
299 ss << (this->RKneePitch() ? "true" : "false");
300 ss << ", ";
301 ss << (this->RAnklePitch() ? "true" : "false");
302 ss << ", ";
303 ss << (this->RAnkleRoll() ? "true" : "false");
304 return ss.str();
305#endif
306 }
307
308#ifdef USE_WB_TEMPERATURE_SENSORS_C_CONVERSION
309 void from_string(const std::string &t_str) {
310 wb_temperature_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 > TEMPERATURE_SENSORS_DESC_BUFFER_SIZE) {
317 return;
318 }
319 char var_str_buffer[TEMPERATURE_SENSORS_DESC_BUFFER_SIZE + 1];
320 char* var_str = &var_str_buffer[0];
321 char key_buffer[12];
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("LKneePitch", key)) {
383 varIndex = 0;
384 } else if (0 == strcmp("LAnklePitch", key)) {
385 varIndex = 1;
386 } else if (0 == strcmp("LAnkleRoll", key)) {
387 varIndex = 2;
388 } else if (0 == strcmp("RKneePitch", key)) {
389 varIndex = 3;
390 } else if (0 == strcmp("RAnklePitch", key)) {
391 varIndex = 4;
392 } else if (0 == strcmp("RAnkleRoll", 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_LKneePitch(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
403 break;
404 }
405 case 1:
406 {
407 this->set_LAnklePitch(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
408 break;
409 }
410 case 2:
411 {
412 this->set_LAnkleRoll(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
413 break;
414 }
415 case 3:
416 {
417 this->set_RKneePitch(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
418 break;
419 }
420 case 4:
421 {
422 this->set_RAnklePitch(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
423 break;
424 }
425 case 5:
426 {
427 this->set_RAnkleRoll(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_temperature_sensors.
TemperatureSensors(bool t_LKneePitch=false, bool t_LAnklePitch=false, bool t_LAnkleRoll=false, bool t_RKneePitch=false, bool t_RAnklePitch=false, bool t_RAnkleRoll=false)
Create a new TemperatureSensors.
void set_RAnkleRoll(const bool &t_newValue)
TemperatureSensors & operator=(const TemperatureSensors &t_other)
Copy Assignment Operator.
TemperatureSensors(const struct wb_temperature_sensors &t_other)
Copy Constructor.
void set_LAnklePitch(const bool &t_newValue)
void set_LAnkleRoll(const bool &t_newValue)
TemperatureSensors(const std::string &t_str)
String Constructor.
void set_LKneePitch(const bool &t_newValue)
bool operator==(const TemperatureSensors &t_other) const
void set_RAnklePitch(const bool &t_newValue)
TemperatureSensors(const TemperatureSensors &t_other)
Copy Constructor.
bool operator!=(const TemperatureSensors &t_other) const
void set_RKneePitch(const bool &t_newValue)
void from_string(const std::string &t_str)
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
bool RAnkleRoll
Is the right ankle roll overheating.
bool LAnklePitch
Is the left ankle pitch overheating.
bool LAnkleRoll
Is the left ankle roll overheating.
bool LKneePitch
Is the left knee pitch overheating.
bool RKneePitch
Is the right knee pitch overheating.
bool RAnklePitch
Is the right ankle pitch overheating.
const char * wb_temperature_sensors_to_string(const struct wb_temperature_sensors *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_temperature_sensors * wb_temperature_sensors_from_string(struct wb_temperature_sensors *self, const char *str)
Convert from a string.
const char * wb_temperature_sensors_description(const struct wb_temperature_sensors *self, char *descString, size_t bufferSize)
Convert to a description string.
#define TEMPERATURE_SENSORS_TO_STRING_BUFFER_SIZE
#define TEMPERATURE_SENSORS_DESC_BUFFER_SIZE