60#ifndef guWhiteboard_TopParticles_h
61#define guWhiteboard_TopParticles_h
63#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
72#undef guWhiteboard_TopParticles_DEFINED
73#define guWhiteboard_TopParticles_DEFINED
75#undef TopParticles_DEFINED
76#define TopParticles_DEFINED
78#define TOPPARTICLES_PARTICLES_ARRAY_SIZE 4
95 if (t_particles != NULLPTR) {
109 this->init(t_particles);
144 for (
int particles_0_index = 0; particles_0_index < 4; particles_0_index++)
153 return !(*
this == t_other);
163 return !(*
this == t_other);
196#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
206#ifdef USE_WB_TOP_PARTICLES_C_CONVERSION
209 std::string descr = buffer;
212 std::ostringstream ss;
213 bool particles_first =
true;
217 particles_first =
false;
225#ifdef USE_WB_TOP_PARTICLES_C_CONVERSION
228 std::string toString = buffer;
231 std::ostringstream ss;
232 bool particles_first =
true;
236 particles_first =
false;
243#ifdef USE_WB_TOP_PARTICLES_C_CONVERSION
248 char * str_cstr =
const_cast<char *
>(t_str.c_str());
249 size_t temp_length = strlen(str_cstr);
250 int length = (temp_length <= INT_MAX) ? static_cast<int>(
static_cast<ssize_t
>(temp_length)) : -1;
255 char* var_str = &var_str_buffer[0];
257 char* key = &key_buffer[0];
265 if (index == 0 && str_cstr[0] ==
'{') {
271 for (
int i = index; i < length; i++) {
273 if (bracecount == 0 && str_cstr[i] ==
'=') {
278 if (bracecount == 0 && isspace(str_cstr[i])) {
285 if (bracecount == 0 && str_cstr[i] ==
',') {
289 if (str_cstr[i] ==
'{') {
291 if (bracecount == 1) {
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(
"particles", key)) {
331 int restartIndex = index;
332 index = lastBrace + 1;
338 for (
int i = index; i < length; i++) {
340 if (bracecount == 0 && str_cstr[i] ==
'=') {
345 if (bracecount == 0 && isspace(str_cstr[i])) {
352 if (bracecount == 0 && str_cstr[i] ==
',') {
356 if (str_cstr[i] ==
'{') {
360 if (str_cstr[i] ==
'}') {
362 if (bracecount < 0) {
367 if (i == length - 1) {
371 if (endKey >= startKey && endKey - startKey < length) {
372 strncpy(key, str_cstr + startKey,
static_cast<size_t>((endKey - startKey) + 1));
373 key[(endKey - startKey) + 1] = 0;
377 strncpy(var_str, str_cstr + startVar,
static_cast<size_t>((index - startVar) + 1));
378 var_str[(index - startVar) + 1] = 0;
389 index = restartIndex;
396 }
while(index < length);
#define TOPPARTICLES_PARTICLES_ARRAY_SIZE
Provides a C++ wrapper around wb_particle_position.
void from_string(const std::string &t_str)
Provides a C++ wrapper around wb_top_particles.
const ParticlePosition * particles() const
void set_particles(const ParticlePosition &t_newValue, int t_i)
bool operator==(const TopParticles &t_other) const
ParticlePosition & particles(int t_i)
TopParticles(const struct wb_particle_position t_particles[4]=NULLPTR)
Create a new TopParticles.
const ParticlePosition topParticle()
WHITEBOARD_POSTER_STRING_CONVERSION.
bool operator!=(const TopParticles &t_other) const
TopParticles & operator=(const TopParticles &t_other)
Copy Assignment Operator.
std::string description()
TopParticles(const struct wb_top_particles &t_other)
Copy Constructor.
TopParticles(const std::string &t_str)
String Constructor.
void from_string(const std::string &t_str)
TopParticles(const TopParticles &t_other)
Copy Constructor.
size_t particles_size() const
void set_particles(const ParticlePosition *t_newValue)
const ParticlePosition & particles(int t_i) const
WHITEBOARD_POSTER_STRING_CONVERSION.
The class of the top particles in a Localization Filter.
struct wb_particle_position particles[4]
these 4 should be the constant NUM_TOP_PARTICLES
struct wb_top_particles * wb_top_particles_from_string(struct wb_top_particles *self, const char *str)
Convert from a string.
const char * wb_top_particles_description(const struct wb_top_particles *self, char *descString, size_t bufferSize)
Convert to a description string.
const char * wb_top_particles_to_string(const struct wb_top_particles *self, char *toString, size_t bufferSize)
Convert to a string.
#define TOPPARTICLES_TO_STRING_BUFFER_SIZE
#define TOPPARTICLES_DESC_BUFFER_SIZE