gusimplewhiteboard
MissionPriorityForObstacles.hpp
Go to the documentation of this file.
1/*
2 * file MissionPriorityForObstacles.hpp
3 *
4 * This file was generated by classgenerator from mission_priority_for_obstacles.gen.
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_MissionPriorityForObstacles_h
61#define guWhiteboard_MissionPriorityForObstacles_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_MissionPriorityForObstacles_DEFINED
73#define guWhiteboard_MissionPriorityForObstacles_DEFINED
74
75#undef MissionPriorityForObstacles_DEFINED
76#define MissionPriorityForObstacles_DEFINED
77
78
79
80namespace guWhiteboard {
81
86
87 private:
88
92 void init(bool t_ignore_obstacles = true) {
93 set_ignore_obstacles(t_ignore_obstacles);
94 }
95
96 public:
97
101 MissionPriorityForObstacles(bool t_ignore_obstacles = true) {
102 this->init(t_ignore_obstacles);
103 }
104
109 this->init(t_other.ignore_obstacles());
110 }
111
116 this->init(t_other.ignore_obstacles);
117 }
118
123 this->init(t_other.ignore_obstacles());
124 return *this;
125 }
126
131 this->init(t_other.ignore_obstacles);
132 return *this;
133 }
134
135 bool operator ==(const MissionPriorityForObstacles &t_other) const
136 {
137 return ignore_obstacles() == t_other.ignore_obstacles();
138 }
139
140 bool operator !=(const MissionPriorityForObstacles &t_other) const
141 {
142 return !(*this == t_other);
143 }
144
146 {
147 return *this == MissionPriorityForObstacles(t_other);
148 }
149
151 {
152 return !(*this == t_other);
153 }
154
156 {
158 }
159
160 const bool & ignore_obstacles() const
161 {
163 }
164
165 void set_ignore_obstacles(const bool &t_newValue)
166 {
168 }
169
170#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
174 MissionPriorityForObstacles(const std::string &t_str) {
175 this->init();
176 this->from_string(t_str);
177 }
178
179 std::string description() {
180#ifdef USE_WB_MISSION_PRIORITY_FOR_OBSTACLES_C_CONVERSION
182 wb_mission_priority_for_obstacles_description(this, buffer, sizeof(buffer));
183 std::string descr = buffer;
184 return descr;
185#else
186 std::ostringstream ss;
187 ss << "ignore_obstacles=" << (this->ignore_obstacles() ? "true" : "false");
188 return ss.str();
189#endif
190 }
191
192 std::string to_string() {
193#ifdef USE_WB_MISSION_PRIORITY_FOR_OBSTACLES_C_CONVERSION
195 wb_mission_priority_for_obstacles_to_string(this, buffer, sizeof(buffer));
196 std::string toString = buffer;
197 return toString;
198#else
199 std::ostringstream ss;
200 ss << (this->ignore_obstacles() ? "true" : "false");
201 return ss.str();
202#endif
203 }
204
205#ifdef USE_WB_MISSION_PRIORITY_FOR_OBSTACLES_C_CONVERSION
206 void from_string(const std::string &t_str) {
208#else
209 void from_string(const std::string &t_str) {
210 char * str_cstr = const_cast<char *>(t_str.c_str());
211 size_t temp_length = strlen(str_cstr);
212 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
213 if (length < 1 || length > MISSION_PRIORITY_FOR_OBSTACLES_DESC_BUFFER_SIZE) {
214 return;
215 }
217 char* var_str = &var_str_buffer[0];
218 char key_buffer[17];
219 char* key = &key_buffer[0];
220 int bracecount = 0;
221 int startVar = 0;
222 int index = 0;
223 int startKey = 0;
224 int endKey = -1;
225 int varIndex = 0;
226 if (index == 0 && str_cstr[0] == '{') {
227 index = 1;
228 }
229 startVar = index;
230 startKey = startVar;
231 do {
232 for (int i = index; i < length; i++) {
233 index = i + 1;
234 if (bracecount == 0 && str_cstr[i] == '=') {
235 endKey = i - 1;
236 startVar = index;
237 continue;
238 }
239 if (bracecount == 0 && isspace(str_cstr[i])) {
240 startVar = index;
241 if (endKey == -1) {
242 startKey = index;
243 }
244 continue;
245 }
246 if (bracecount == 0 && str_cstr[i] == ',') {
247 index = i - 1;
248 break;
249 }
250 if (str_cstr[i] == '{') {
251 bracecount++;
252 continue;
253 }
254 if (str_cstr[i] == '}') {
255 bracecount--;
256 if (bracecount < 0) {
257 index = i - 1;
258 break;
259 }
260 }
261 if (i == length - 1) {
262 index = i;
263 }
264 }
265 if (endKey >= startKey && endKey - startKey < length) {
266 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
267 key[(endKey - startKey) + 1] = 0;
268 } else {
269 key[0] = 0;
270 }
271 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
272 var_str[(index - startVar) + 1] = 0;
273 bracecount = 0;
274 index += 2;
275 startVar = index;
276 startKey = startVar;
277 endKey = -1;
278 if (strlen(key) > 0) {
279 if (0 == strcmp("ignore_obstacles", key)) {
280 varIndex = 0;
281 } else {
282 varIndex = -1;
283 }
284 }
285 switch (varIndex) {
286 case -1: { break; }
287 case 0:
288 {
289 this->set_ignore_obstacles(strcmp(var_str, "true") == 0 || strcmp(var_str, "1") == 0);
290 break;
291 }
292 }
293 if (varIndex >= 0) {
294 varIndex++;
295 }
296 } while(index < length);
297#endif
298 }
299#endif
300
301 public:
302 };
303
304}
305
306#endif
Provides a C++ wrapper around wb_mission_priority_for_obstacles.
bool operator==(const MissionPriorityForObstacles &t_other) const
MissionPriorityForObstacles(const std::string &t_str)
String Constructor.
bool operator!=(const MissionPriorityForObstacles &t_other) const
MissionPriorityForObstacles(const struct wb_mission_priority_for_obstacles &t_other)
Copy Constructor.
MissionPriorityForObstacles(const MissionPriorityForObstacles &t_other)
Copy Constructor.
MissionPriorityForObstacles(bool t_ignore_obstacles=true)
Create a new MissionPriorityForObstacles.
MissionPriorityForObstacles & operator=(const MissionPriorityForObstacles &t_other)
Copy Assignment Operator.
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
bool ignore_obstacles
walk ahead with high priority on target so do not deviate because of obstacles detected by sonar.
const char * wb_mission_priority_for_obstacles_to_string(const struct wb_mission_priority_for_obstacles *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_mission_priority_for_obstacles_description(const struct wb_mission_priority_for_obstacles *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_mission_priority_for_obstacles * wb_mission_priority_for_obstacles_from_string(struct wb_mission_priority_for_obstacles *self, const char *str)
Convert from a string.
#define MISSION_PRIORITY_FOR_OBSTACLES_DESC_BUFFER_SIZE
#define MISSION_PRIORITY_FOR_OBSTACLES_TO_STRING_BUFFER_SIZE