gusimplewhiteboard
Overheating.hpp
Go to the documentation of this file.
1/*
2 * file Overheating.hpp
3 *
4 * This file was generated by classgenerator from overheating.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_Overheating_h
61#define guWhiteboard_Overheating_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>
70#include "wb_overheating.h"
71
72#undef guWhiteboard_Overheating_DEFINED
73#define guWhiteboard_Overheating_DEFINED
74
75#undef Overheating_DEFINED
76#define Overheating_DEFINED
77
78namespace guWhiteboard {
79
84
85 private:
86
90 void init(bool t_overheating = false) {
91 set_overheating(t_overheating);
92 }
93
94 public:
95
99 Overheating(bool t_overheating = false) {
100 this->init(t_overheating);
101 }
102
107 this->init(t_other.overheating());
108 }
109
113 Overheating(const struct wb_overheating &t_other): wb_overheating() {
114 this->init(t_other.overheating);
115 }
116
121 this->init(t_other.overheating());
122 return *this;
123 }
124
128 Overheating &operator = (const struct wb_overheating &t_other) {
129 this->init(t_other.overheating);
130 return *this;
131 }
132
133 bool operator ==(const Overheating &t_other) const
134 {
135 return overheating() == t_other.overheating();
136 }
137
138 bool operator !=(const Overheating &t_other) const
139 {
140 return !(*this == t_other);
141 }
142
143 bool operator ==(const wb_overheating &t_other) const
144 {
145 return *this == Overheating(t_other);
146 }
147
148 bool operator !=(const wb_overheating &t_other) const
149 {
150 return !(*this == t_other);
151 }
152
153 bool & overheating()
154 {
156 }
157
158 const bool & overheating() const
159 {
161 }
162
163 void set_overheating(const bool &t_newValue)
164 {
165 wb_overheating::overheating = t_newValue;
166 }
167
168#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
172 Overheating(const std::string &t_str) {
173 this->init();
174 this->from_string(t_str);
175 }
176
177 std::string description() {
178#ifdef USE_WB_OVERHEATING_C_CONVERSION
179 char buffer[OVERHEATING_DESC_BUFFER_SIZE];
180 wb_overheating_description(this, buffer, sizeof(buffer));
181 std::string descr = buffer;
182 return descr;
183#else
184 std::ostringstream ss;
185 ss << "overheating=" << (this->overheating() ? "true" : "false");
186 return ss.str();
187#endif
188 }
189
190 std::string to_string() {
191#ifdef USE_WB_OVERHEATING_C_CONVERSION
193 wb_overheating_to_string(this, buffer, sizeof(buffer));
194 std::string toString = buffer;
195 return toString;
196#else
197 std::ostringstream ss;
198 ss << (this->overheating() ? "true" : "false");
199 return ss.str();
200#endif
201 }
202
203#ifdef USE_WB_OVERHEATING_C_CONVERSION
204 void from_string(const std::string &t_str) {
205 wb_overheating_from_string(this, t_str.c_str());
206#else
207 void from_string(const std::string &t_str) {
208 char * str_cstr = const_cast<char *>(t_str.c_str());
209 size_t temp_length = strlen(str_cstr);
210 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
211 if (length < 1 || length > OVERHEATING_DESC_BUFFER_SIZE) {
212 return;
213 }
214 char var_str_buffer[OVERHEATING_DESC_BUFFER_SIZE + 1];
215 char* var_str = &var_str_buffer[0];
216 char key_buffer[12];
217 char* key = &key_buffer[0];
218 int bracecount = 0;
219 int startVar = 0;
220 int index = 0;
221 int startKey = 0;
222 int endKey = -1;
223 int varIndex = 0;
224 if (index == 0 && str_cstr[0] == '{') {
225 index = 1;
226 }
227 startVar = index;
228 startKey = startVar;
229 do {
230 for (int i = index; i < length; i++) {
231 index = i + 1;
232 if (bracecount == 0 && str_cstr[i] == '=') {
233 endKey = i - 1;
234 startVar = index;
235 continue;
236 }
237 if (bracecount == 0 && isspace(str_cstr[i])) {
238 startVar = index;
239 if (endKey == -1) {
240 startKey = index;
241 }
242 continue;
243 }
244 if (bracecount == 0 && str_cstr[i] == ',') {
245 index = i - 1;
246 break;
247 }
248 if (str_cstr[i] == '{') {
249 bracecount++;
250 continue;
251 }
252 if (str_cstr[i] == '}') {
253 bracecount--;
254 if (bracecount < 0) {
255 index = i - 1;
256 break;
257 }
258 }
259 if (i == length - 1) {
260 index = i;
261 }
262 }
263 if (endKey >= startKey && endKey - startKey < length) {
264 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
265 key[(endKey - startKey) + 1] = 0;
266 } else {
267 key[0] = 0;
268 }
269 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
270 var_str[(index - startVar) + 1] = 0;
271 bracecount = 0;
272 index += 2;
273 startVar = index;
274 startKey = startVar;
275 endKey = -1;
276 if (strlen(key) > 0) {
277 if (0 == strcmp("overheating", key)) {
278 varIndex = 0;
279 } else {
280 varIndex = -1;
281 }
282 }
283 switch (varIndex) {
284 case -1: { break; }
285 case 0:
286 {
287 this->set_overheating(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
288 break;
289 }
290 }
291 if (varIndex >= 0) {
292 varIndex++;
293 }
294 } while(index < length);
295#endif
296 }
297#endif
298 };
299
300}
301
302#endif
Provides a C++ wrapper around wb_overheating.
Definition: Overheating.hpp:83
bool operator==(const Overheating &t_other) const
Overheating(const struct wb_overheating &t_other)
Copy Constructor.
bool operator!=(const Overheating &t_other) const
Overheating(const std::string &t_str)
String Constructor.
void set_overheating(const bool &t_newValue)
void from_string(const std::string &t_str)
Overheating(bool t_overheating=false)
Create a new Overheating.
Definition: Overheating.hpp:99
Overheating(const Overheating &t_other)
Copy Constructor.
const bool & overheating() const
Overheating & operator=(const Overheating &t_other)
Copy Assignment Operator.
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
bool overheating
Is the leg sensors on the nao overheating?
const char * wb_overheating_to_string(const struct wb_overheating *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_overheating * wb_overheating_from_string(struct wb_overheating *self, const char *str)
Convert from a string.
const char * wb_overheating_description(const struct wb_overheating *self, char *descString, size_t bufferSize)
Convert to a description string.
#define OVERHEATING_TO_STRING_BUFFER_SIZE
#define OVERHEATING_DESC_BUFFER_SIZE