60#ifndef guWhiteboard_NaoObstacleDirection_h
61#define guWhiteboard_NaoObstacleDirection_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_NaoObstacleDirection_DEFINED
73#define guWhiteboard_NaoObstacleDirection_DEFINED
75#undef NaoObstacleDirection_DEFINED
76#define NaoObstacleDirection_DEFINED
92 void init(
bool t_left =
false,
bool t_right =
false,
bool t_front =
false) {
104 this->init(t_left, t_right, t_front);
146 return !(*
this == t_other);
156 return !(*
this == t_other);
204#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
214#ifdef USE_WB_NAO_OBSTACLE_DIRECTION_C_CONVERSION
217 std::string descr = buffer;
220 std::ostringstream ss;
221 ss <<
"left=" << (this->
left() ?
"true" :
"false");
223 ss <<
"right=" << (this->
right() ?
"true" :
"false");
225 ss <<
"front=" << (this->
front() ?
"true" :
"false");
231#ifdef USE_WB_NAO_OBSTACLE_DIRECTION_C_CONVERSION
234 std::string toString = buffer;
237 std::ostringstream ss;
238 ss << (this->
left() ?
"true" :
"false");
240 ss << (this->
right() ?
"true" :
"false");
242 ss << (this->
front() ?
"true" :
"false");
247#ifdef USE_WB_NAO_OBSTACLE_DIRECTION_C_CONVERSION
252 char * str_cstr =
const_cast<char *
>(t_str.c_str());
253 size_t temp_length = strlen(str_cstr);
254 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
259 char* var_str = &var_str_buffer[0];
261 char* key = &key_buffer[0];
268 if (index == 0 && str_cstr[0] ==
'{') {
274 for (
int i = index; i < length; i++) {
276 if (bracecount == 0 && str_cstr[i] ==
'=') {
281 if (bracecount == 0 && isspace(str_cstr[i])) {
288 if (bracecount == 0 && str_cstr[i] ==
',') {
292 if (str_cstr[i] ==
'{') {
296 if (str_cstr[i] ==
'}') {
298 if (bracecount < 0) {
303 if (i == length - 1) {
307 if (endKey >= startKey && endKey - startKey < length) {
308 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
309 key[(endKey - startKey) + 1] = 0;
313 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
314 var_str[(index - startVar) + 1] = 0;
320 if (strlen(key) > 0) {
321 if (0 == strcmp(
"left", key)) {
323 }
else if (0 == strcmp(
"right", key)) {
325 }
else if (0 == strcmp(
"front", key)) {
335 this->
set_left(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
340 this->
set_right(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
345 this->
set_front(strcmp(var_str,
"true") == 0 || strcmp(var_str,
"1") == 0);
352 }
while(index < length);
Provides a C++ wrapper around wb_nao_obstacle_direction.
const bool & left() const
std::string description()
void from_string(const std::string &t_str)
NaoObstacleDirection(const struct wb_nao_obstacle_direction &t_other)
Copy Constructor.
const bool & right() const
NaoObstacleDirection & operator=(const NaoObstacleDirection &t_other)
Copy Assignment Operator.
static NaoObstacleDirection sonar_direction(bool _left, bool _front, bool _right)
WHITEBOARD_POSTER_STRING_CONVERSION.
const bool & front() const
NaoObstacleDirection(const NaoObstacleDirection &t_other)
Copy Constructor.
NaoObstacleDirection(const std::string &t_str)
String Constructor.
NaoObstacleDirection(bool t_left=false, bool t_right=false, bool t_front=false)
Create a new NaoObstacleDirection.
void set_right(const bool &t_newValue)
void set_left(const bool &t_newValue)
bool operator==(const NaoObstacleDirection &t_other) const
void set_front(const bool &t_newValue)
bool operator!=(const NaoObstacleDirection &t_other) const
WHITEBOARD_POSTER_STRING_CONVERSION.
bool left
Do I have an obstacle 40 cm to my left (check SMSubsumption machine methods)
bool right
Do I have an obstacle 40 cm to my left (check SMSubsumption machine methods)
bool front
Do I have an obstacle 40 cm to my left (check SMSubsumption machine methods)
struct wb_nao_obstacle_direction * wb_nao_obstacle_direction_from_string(struct wb_nao_obstacle_direction *self, const char *str)
Convert from a string.
const char * wb_nao_obstacle_direction_to_string(const struct wb_nao_obstacle_direction *self, char *toString, size_t bufferSize)
Convert to a string.
const char * wb_nao_obstacle_direction_description(const struct wb_nao_obstacle_direction *self, char *descString, size_t bufferSize)
Convert to a description string.
#define NAO_OBSTACLE_DIRECTION_TO_STRING_BUFFER_SIZE
#define NAO_OBSTACLE_DIRECTION_DESC_BUFFER_SIZE