gusimplewhiteboard
SENSORSHeadJointSensors.hpp
Go to the documentation of this file.
1/*
2 * file SENSORSHeadJointSensors.hpp
3 *
4 * This file was generated by classgenerator from SENSORS_HeadJointSensors.txt.
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_SENSORSHeadJointSensors_h
61#define guWhiteboard_SENSORSHeadJointSensors_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#include <float.h>
72
73#undef guWhiteboard_SENSORSHeadJointSensors_DEFINED
74#define guWhiteboard_SENSORSHeadJointSensors_DEFINED
75
76#undef SENSORSHeadJointSensors_DEFINED
77#define SENSORSHeadJointSensors_DEFINED
78
79namespace guWhiteboard {
80
85
86 private:
87
91 void init(float t_HeadYaw = 0.0f, float t_HeadPitch = 0.0f) {
92 set_HeadYaw(t_HeadYaw);
93 set_HeadPitch(t_HeadPitch);
94 }
95
96 public:
97
101 SENSORSHeadJointSensors(float t_HeadYaw = 0.0f, float t_HeadPitch = 0.0f) {
102 this->init(t_HeadYaw, t_HeadPitch);
103 }
104
109 this->init(t_other.HeadYaw(), t_other.HeadPitch());
110 }
111
116 this->init(t_other.HeadYaw, t_other.HeadPitch);
117 }
118
123 this->init(t_other.HeadYaw(), t_other.HeadPitch());
124 return *this;
125 }
126
131 this->init(t_other.HeadYaw, t_other.HeadPitch);
132 return *this;
133 }
134
135 bool operator ==(const SENSORSHeadJointSensors &t_other) const
136 {
137 return fabsf(HeadYaw() - t_other.HeadYaw()) < FLT_EPSILON
138 && fabsf(HeadPitch() - t_other.HeadPitch()) < FLT_EPSILON;
139 }
140
141 bool operator !=(const SENSORSHeadJointSensors &t_other) const
142 {
143 return !(*this == t_other);
144 }
145
146 bool operator ==(const wb_sensors_headjointsensors &t_other) const
147 {
148 return *this == SENSORSHeadJointSensors(t_other);
149 }
150
151 bool operator !=(const wb_sensors_headjointsensors &t_other) const
152 {
153 return !(*this == t_other);
154 }
155
156 float & HeadYaw()
157 {
159 }
160
161 const float & HeadYaw() const
162 {
164 }
165
166 void set_HeadYaw(const float &t_newValue)
167 {
169 }
170
171 float & HeadPitch()
172 {
174 }
175
176 const float & HeadPitch() const
177 {
179 }
180
181 void set_HeadPitch(const float &t_newValue)
182 {
184 }
185
186#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
190 SENSORSHeadJointSensors(const std::string &t_str) {
191 this->init();
192 this->from_string(t_str);
193 }
194
195 std::string description() {
196#ifdef USE_WB_SENSORS_HEADJOINTSENSORS_C_CONVERSION
198 wb_sensors_headjointsensors_description(this, buffer, sizeof(buffer));
199 std::string descr = buffer;
200 return descr;
201#else
202 std::ostringstream ss;
203 ss << "HeadYaw=" << this->HeadYaw();
204 ss << ", ";
205 ss << "HeadPitch=" << this->HeadPitch();
206 return ss.str();
207#endif
208 }
209
210 std::string to_string() {
211#ifdef USE_WB_SENSORS_HEADJOINTSENSORS_C_CONVERSION
213 wb_sensors_headjointsensors_to_string(this, buffer, sizeof(buffer));
214 std::string toString = buffer;
215 return toString;
216#else
217 std::ostringstream ss;
218 ss << this->HeadYaw();
219 ss << ", ";
220 ss << this->HeadPitch();
221 return ss.str();
222#endif
223 }
224
225#ifdef USE_WB_SENSORS_HEADJOINTSENSORS_C_CONVERSION
226 void from_string(const std::string &t_str) {
227 wb_sensors_headjointsensors_from_string(this, t_str.c_str());
228#else
229 void from_string(const std::string &t_str) {
230 char * str_cstr = const_cast<char *>(t_str.c_str());
231 size_t temp_length = strlen(str_cstr);
232 int length = (temp_length <= INT_MAX) ? static_cast<int>(static_cast<ssize_t>(temp_length)) : -1;
233 if (length < 1 || length > SENSORS_HEADJOINTSENSORS_DESC_BUFFER_SIZE) {
234 return;
235 }
236 char var_str_buffer[SENSORS_HEADJOINTSENSORS_DESC_BUFFER_SIZE + 1];
237 char* var_str = &var_str_buffer[0];
238 char key_buffer[10];
239 char* key = &key_buffer[0];
240 int bracecount = 0;
241 int startVar = 0;
242 int index = 0;
243 int startKey = 0;
244 int endKey = -1;
245 int varIndex = 0;
246 if (index == 0 && str_cstr[0] == '{') {
247 index = 1;
248 }
249 startVar = index;
250 startKey = startVar;
251 do {
252 for (int i = index; i < length; i++) {
253 index = i + 1;
254 if (bracecount == 0 && str_cstr[i] == '=') {
255 endKey = i - 1;
256 startVar = index;
257 continue;
258 }
259 if (bracecount == 0 && isspace(str_cstr[i])) {
260 startVar = index;
261 if (endKey == -1) {
262 startKey = index;
263 }
264 continue;
265 }
266 if (bracecount == 0 && str_cstr[i] == ',') {
267 index = i - 1;
268 break;
269 }
270 if (str_cstr[i] == '{') {
271 bracecount++;
272 continue;
273 }
274 if (str_cstr[i] == '}') {
275 bracecount--;
276 if (bracecount < 0) {
277 index = i - 1;
278 break;
279 }
280 }
281 if (i == length - 1) {
282 index = i;
283 }
284 }
285 if (endKey >= startKey && endKey - startKey < length) {
286 strncpy(key, str_cstr + startKey, static_cast<size_t>((endKey - startKey) + 1));
287 key[(endKey - startKey) + 1] = 0;
288 } else {
289 key[0] = 0;
290 }
291 strncpy(var_str, str_cstr + startVar, static_cast<size_t>((index - startVar) + 1));
292 var_str[(index - startVar) + 1] = 0;
293 bracecount = 0;
294 index += 2;
295 startVar = index;
296 startKey = startVar;
297 endKey = -1;
298 if (strlen(key) > 0) {
299 if (0 == strcmp("HeadYaw", key)) {
300 varIndex = 0;
301 } else if (0 == strcmp("HeadPitch", key)) {
302 varIndex = 1;
303 } else {
304 varIndex = -1;
305 }
306 }
307 switch (varIndex) {
308 case -1: { break; }
309 case 0:
310 {
311 this->set_HeadYaw(static_cast<float>(atof(var_str)));
312 break;
313 }
314 case 1:
315 {
316 this->set_HeadPitch(static_cast<float>(atof(var_str)));
317 break;
318 }
319 }
320 if (varIndex >= 0) {
321 varIndex++;
322 }
323 } while(index < length);
324#endif
325 }
326#endif
327 };
328
329}
330
331#endif
Provides a C++ wrapper around wb_sensors_headjointsensors.
SENSORSHeadJointSensors & operator=(const SENSORSHeadJointSensors &t_other)
Copy Assignment Operator.
SENSORSHeadJointSensors(const std::string &t_str)
String Constructor.
bool operator==(const SENSORSHeadJointSensors &t_other) const
SENSORSHeadJointSensors(float t_HeadYaw=0.0f, float t_HeadPitch=0.0f)
Create a new SENSORSHeadJointSensors.
void from_string(const std::string &t_str)
SENSORSHeadJointSensors(const SENSORSHeadJointSensors &t_other)
Copy Constructor.
SENSORSHeadJointSensors(const struct wb_sensors_headjointsensors &t_other)
Copy Constructor.
bool operator!=(const SENSORSHeadJointSensors &t_other) const
/file APM_Interface.h
WHITEBOARD_POSTER_STRING_CONVERSION.
const char * wb_sensors_headjointsensors_description(const struct wb_sensors_headjointsensors *self, char *descString, size_t bufferSize)
Convert to a description string.
struct wb_sensors_headjointsensors * wb_sensors_headjointsensors_from_string(struct wb_sensors_headjointsensors *self, const char *str)
Convert from a string.
const char * wb_sensors_headjointsensors_to_string(const struct wb_sensors_headjointsensors *self, char *toString, size_t bufferSize)
Convert to a string.
#define SENSORS_HEADJOINTSENSORS_DESC_BUFFER_SIZE
#define SENSORS_HEADJOINTSENSORS_TO_STRING_BUFFER_SIZE