gusimplewhiteboard
FilteredArrayBallSightings.hpp
Go to the documentation of this file.
1/*
2 * file FilteredArrayBallSightings.hpp
3 *
4 * This file was generated by classgenerator from Filtered_ArrayBallSightings.txt.
5 * DO NOT CHANGE MANUALLY!
6 *
7 * Copyright © 2021 Vlad Estivill-Castro. 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 Vlad Estivill-Castro.
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_FilteredArrayBallSightings_h
61#define guWhiteboard_FilteredArrayBallSightings_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_FilteredArrayBallSightings_DEFINED
73#define guWhiteboard_FilteredArrayBallSightings_DEFINED
74
75#undef FilteredArrayBallSightings_DEFINED
76#define FilteredArrayBallSightings_DEFINED
77
79
80namespace guWhiteboard {
81
86
87 private:
88
92 void init(const struct wb_filtered_vision_object t_objects[2] = NULLPTR) {
93 if (t_objects != NULLPTR) {
95 } else {
98 }
99 }
100
101 public:
102
106 FilteredArrayBallSightings(const struct wb_filtered_vision_object t_objects[2] = NULLPTR) {
107 this->init(t_objects);
108 }
109
114 this->init(t_other.objects());
115 }
116
121 this->init(t_other.objects);
122 }
123
128 this->init(t_other.objects());
129 return *this;
130 }
131
136 this->init(t_other.objects);
137 return *this;
138 }
139
140 bool operator ==(const FilteredArrayBallSightings &t_other) const
141 {
142 for (int objects_0_index = 0; objects_0_index < 2; objects_0_index++)
143 {
144 if (!(FilteredVisionObject(objects(objects_0_index)) == FilteredVisionObject(t_other.objects(objects_0_index)))) return false;
145 }
146 return true;
147 }
148
149 bool operator !=(const FilteredArrayBallSightings &t_other) const
150 {
151 return !(*this == t_other);
152 }
153
155 {
156 return *this == FilteredArrayBallSightings(t_other);
157 }
158
160 {
161 return !(*this == t_other);
162 }
163
165 {
166 return static_cast<const FilteredVisionObject *>(&(wb_filtered_arrayballsightings::objects[0]));
167 }
168
169 size_t objects_size() const
170 {
172 }
173
175 {
176 return const_cast<FilteredVisionObject &>(static_cast<const FilteredVisionObject &>(wb_filtered_arrayballsightings::objects[t_i]));
177 }
178
179 const FilteredVisionObject & objects(int t_i) const
180 {
181 return static_cast<const FilteredVisionObject &>(wb_filtered_arrayballsightings::objects[t_i]);
182 }
183
184 void set_objects(const FilteredVisionObject *t_newValue)
185 {
187 }
188
189 void set_objects(const FilteredVisionObject &t_newValue, int t_i)
190 {
192 }
193
194#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
198 FilteredArrayBallSightings(const std::string &t_str) {
199 this->init();
200 this->from_string(t_str);
201 }
202
203 std::string description() {
204#ifdef USE_WB_FILTERED_ARRAYBALLSIGHTINGS_C_CONVERSION
206 wb_filtered_arrayballsightings_description(this, buffer, sizeof(buffer));
207 std::string descr = buffer;
208 return descr;
209#else
210 std::ostringstream ss;
211 bool objects_first = true;
212 ss << "objects={";
213 for (int i = 0; i < FILTERED_ARRAYBALLSIGHTINGS_OBJECTS_ARRAY_SIZE; i++) {
214 ss << (objects_first ? "" : ", ") << "{" << FilteredVisionObject(this->objects(i)).description() << "}";
215 objects_first = false;
216 }
217 ss << "}";
218 return ss.str();
219#endif
220 }
221
222 std::string to_string() {
223#ifdef USE_WB_FILTERED_ARRAYBALLSIGHTINGS_C_CONVERSION
225 wb_filtered_arrayballsightings_to_string(this, buffer, sizeof(buffer));
226 std::string toString = buffer;
227 return toString;
228#else
229 std::ostringstream ss;
230 bool objects_first = true;
231 ss << "{";
232 for (int i = 0; i < FILTERED_ARRAYBALLSIGHTINGS_OBJECTS_ARRAY_SIZE; i++) {
233 ss << (objects_first ? "" : ", ") << "{" << FilteredVisionObject(this->objects(i)).to_string() << "}";
234 objects_first = false;
235 }
236 ss << "}";
237 return ss.str();
238#endif
239 }
240
241#ifdef USE_WB_FILTERED_ARRAYBALLSIGHTINGS_C_CONVERSION
242 void from_string(const std::string &t_str) {
244#else
245 void from_string(const std::string &t_str) {
246 char * str_cstr = const_cast<char *>(t_str.c_str());
247 size_t temp_length = strlen(str_cstr);
248 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
249 if (length < 1 || length > FILTERED_ARRAYBALLSIGHTINGS_DESC_BUFFER_SIZE) {
250 return;
251 }
252 char var_str_buffer[FILTERED_ARRAYBALLSIGHTINGS_DESC_BUFFER_SIZE + 1];
253 char* var_str = &var_str_buffer[0];
254 char key_buffer[8];
255 char* key = &key_buffer[0];
256 int bracecount = 0;
257 int lastBrace = -1;
258 int startVar = 0;
259 int index = 0;
260 int startKey = 0;
261 int endKey = -1;
262 int varIndex = 0;
263 if (index == 0 && str_cstr[0] == '{') {
264 index = 1;
265 }
266 startVar = index;
267 startKey = startVar;
268 do {
269 for (int i = index; i < length; i++) {
270 index = i + 1;
271 if (bracecount == 0 && str_cstr[i] == '=') {
272 endKey = i - 1;
273 startVar = index;
274 continue;
275 }
276 if (bracecount == 0 && isspace(str_cstr[i])) {
277 startVar = index;
278 if (endKey == -1) {
279 startKey = index;
280 }
281 continue;
282 }
283 if (bracecount == 0 && str_cstr[i] == ',') {
284 index = i - 1;
285 break;
286 }
287 if (str_cstr[i] == '{') {
288 bracecount++;
289 if (bracecount == 1) {
290 lastBrace = i;
291 }
292 continue;
293 }
294 if (str_cstr[i] == '}') {
295 bracecount--;
296 if (bracecount < 0) {
297 index = i - 1;
298 break;
299 }
300 }
301 if (i == length - 1) {
302 index = i;
303 }
304 }
305 if (endKey >= startKey && endKey - startKey < length) {
306 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
307 key[(endKey - startKey) + 1] = 0;
308 } else {
309 key[0] = 0;
310 }
311 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
312 var_str[(index - startVar) + 1] = 0;
313 bracecount = 0;
314 index += 2;
315 startVar = index;
316 startKey = startVar;
317 endKey = -1;
318 if (strlen(key) > 0) {
319 if (0 == strcmp("objects", key)) {
320 varIndex = 0;
321 } else {
322 varIndex = -1;
323 }
324 }
325 switch (varIndex) {
326 case -1: { break; }
327 case 0:
328 {
329 int restartIndex = index;
330 index = lastBrace + 1;
331 startVar = index;
332 startKey = startVar;
333 endKey = -1;
334 bracecount = 0;
335 for (int objects_0_index = 0; objects_0_index < FILTERED_ARRAYBALLSIGHTINGS_OBJECTS_ARRAY_SIZE; objects_0_index++) {
336 for (int i = index; i < length; i++) {
337 index = i + 1;
338 if (bracecount == 0 && str_cstr[i] == '=') {
339 endKey = i - 1;
340 startVar = index;
341 continue;
342 }
343 if (bracecount == 0 && isspace(str_cstr[i])) {
344 startVar = index;
345 if (endKey == -1) {
346 startKey = index;
347 }
348 continue;
349 }
350 if (bracecount == 0 && str_cstr[i] == ',') {
351 index = i - 1;
352 break;
353 }
354 if (str_cstr[i] == '{') {
355 bracecount++;
356 continue;
357 }
358 if (str_cstr[i] == '}') {
359 bracecount--;
360 if (bracecount < 0) {
361 index = i - 1;
362 break;
363 }
364 }
365 if (i == length - 1) {
366 index = i;
367 }
368 }
369 if (endKey >= startKey && endKey - startKey < length) {
370 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
371 key[(endKey - startKey) + 1] = 0;
372 } else {
373 key[0] = 0;
374 }
375 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
376 var_str[(index - startVar) + 1] = 0;
377 bracecount = 0;
378 index += 2;
379 startVar = index;
380 startKey = startVar;
381 endKey = -1;
383 objects_0_temp.from_string(var_str);
384 struct wb_filtered_vision_object objects_0 = objects_0_temp;
385 this->set_objects(objects_0, objects_0_index);
386 }
387 index = restartIndex;
388 break;
389 }
390 }
391 if (varIndex >= 0) {
392 varIndex++;
393 }
394 } while(index < length);
395#endif
396 }
397#endif
398 };
399
400}
401
402#endif
Provides a C++ wrapper around wb_filtered_arrayballsightings.
FilteredArrayBallSightings(const struct wb_filtered_arrayballsightings &t_other)
Copy Constructor.
FilteredArrayBallSightings & operator=(const FilteredArrayBallSightings &t_other)
Copy Assignment Operator.
void set_objects(const FilteredVisionObject &t_newValue, int t_i)
bool operator!=(const FilteredArrayBallSightings &t_other) const
const FilteredVisionObject * objects() const
FilteredArrayBallSightings(const std::string &t_str)
String Constructor.
const FilteredVisionObject & objects(int t_i) const
void set_objects(const FilteredVisionObject *t_newValue)
bool operator==(const FilteredArrayBallSightings &t_other) const
FilteredArrayBallSightings(const struct wb_filtered_vision_object t_objects[2]=NULLPTR)
Create a new FilteredArrayBallSightings.
FilteredArrayBallSightings(const FilteredArrayBallSightings &t_other)
Copy Constructor.
Provides a C++ wrapper around wb_filtered_vision_object.
void from_string(const std::string &t_str)
/file APM_Interface.h
The class of landmarks filtered regarding goal sightings.
struct wb_filtered_vision_object objects[2]
the array containing filtered balls on separate cameras reported by vision FVO_NUM_CAMERAS =2
WHITEBOARD_POSTER_STRING_CONVERSION.
const char * wb_filtered_arrayballsightings_description(const struct wb_filtered_arrayballsightings *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_filtered_arrayballsightings_to_string(const struct wb_filtered_arrayballsightings *self, char *toString, size_t bufferSize)
Convert to a string.
struct wb_filtered_arrayballsightings * wb_filtered_arrayballsightings_from_string(struct wb_filtered_arrayballsightings *self, const char *str)
Convert from a string.
#define FILTERED_ARRAYBALLSIGHTINGS_DESC_BUFFER_SIZE
#define FILTERED_ARRAYBALLSIGHTINGS_TO_STRING_BUFFER_SIZE
#define FILTERED_ARRAYBALLSIGHTINGS_OBJECTS_ARRAY_SIZE
WHITEBOARD_POSTER_STRING_CONVERSION.