VisualDisplay2DInterface.cpp

00001 
00002 /***************************************************************************
00003  *  VisualDisplay2DInterface.cpp - Fawkes BlackBoard Interface - VisualDisplay2DInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2009  Tim Niemueller
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #include <interfaces/VisualDisplay2DInterface.h>
00025 
00026 #include <core/exceptions/software.h>
00027 
00028 #include <cstring>
00029 #include <cstdlib>
00030 
00031 namespace fawkes {
00032 
00033 /** @class VisualDisplay2DInterface <interfaces/VisualDisplay2DInterface.h>
00034  * VisualDisplay2DInterface Fawkes BlackBoard Interface.
00035  * 
00036       This interface provides can be used by graphing applications to
00037       provide a graphing service to other components. This is intended
00038       to be used for debugging purposes. Usage of the interface should
00039       be optional to turn it off during a competition. 
00040 
00041       Add* messages will add the given object permanently, so the
00042       graphical display can be considered as a scenegraph. The message
00043       ID is becomes the ID and can be used to delete the object using
00044       the DeleteObjectMessage. With the DeleteAll message all objects
00045       can be removed (shall only remove objects added by the same
00046       sender, thus data drawn by other senders is not touched).
00047 
00048       The units shall be in meters and radians. Color is given as four
00049       byte RGBA value, one byte for each R, G, B and Alpha.
00050     
00051  * @ingroup FawkesInterfaces
00052  */
00053 
00054 
00055 
00056 /** Constructor */
00057 VisualDisplay2DInterface::VisualDisplay2DInterface() : Interface()
00058 {
00059   data_size = sizeof(VisualDisplay2DInterface_data_t);
00060   data_ptr  = malloc(data_size);
00061   data      = (VisualDisplay2DInterface_data_t *)data_ptr;
00062   data_ts   = (interface_data_ts_t *)data_ptr;
00063   memset(data_ptr, 0, data_size);
00064   add_fieldinfo(IFT_UINT32, "counter", 1, &data->counter);
00065   add_messageinfo("AddCartLineMessage");
00066   add_messageinfo("AddCartCircleMessage");
00067   add_messageinfo("AddCartRectMessage");
00068   add_messageinfo("AddCartTextMessage");
00069   add_messageinfo("DeleteObjectMessage");
00070   add_messageinfo("DeleteAllMessage");
00071   unsigned char tmp_hash[] = {0xd9, 0x2, 0xad, 0xbb, 0x7a, 0x47, 0x40, 0x6a, 0x4f, 0x6d, 0xfa, 0xa, 0x20, 0x35, 0xe6, 0x1};
00072   set_hash(tmp_hash);
00073 }
00074 
00075 /** Destructor */
00076 VisualDisplay2DInterface::~VisualDisplay2DInterface()
00077 {
00078   free(data_ptr);
00079 }
00080 /** Convert LineStyle constant to string.
00081  * @param value value to convert to string
00082  * @return constant value as string.
00083  */
00084 const char *
00085 VisualDisplay2DInterface::tostring_LineStyle(LineStyle value) const
00086 {
00087   switch (value) {
00088   case LS_SOLID: return "LS_SOLID";
00089   case LS_DASHED: return "LS_DASHED";
00090   case LS_DOTTED: return "LS_DOTTED";
00091   case LS_DASH_DOTTED: return "LS_DASH_DOTTED";
00092   default: return "UNKNOWN";
00093   }
00094 }
00095 /** Convert Anchor constant to string.
00096  * @param value value to convert to string
00097  * @return constant value as string.
00098  */
00099 const char *
00100 VisualDisplay2DInterface::tostring_Anchor(Anchor value) const
00101 {
00102   switch (value) {
00103   case CENTERED: return "CENTERED";
00104   case NORTH: return "NORTH";
00105   case EAST: return "EAST";
00106   case SOUTH: return "SOUTH";
00107   case WEST: return "WEST";
00108   case NORTH_EAST: return "NORTH_EAST";
00109   case SOUTH_EAST: return "SOUTH_EAST";
00110   case SOUTH_WEST: return "SOUTH_WEST";
00111   case NORTH_WEST: return "NORTH_WEST";
00112   default: return "UNKNOWN";
00113   }
00114 }
00115 /* Methods */
00116 /** Get counter value.
00117  * Field
00118  * @return counter value
00119  */
00120 uint32_t
00121 VisualDisplay2DInterface::counter() const
00122 {
00123   return data->counter;
00124 }
00125 
00126 /** Get maximum length of counter value.
00127  * @return length of counter value, can be length of the array or number of 
00128  * maximum number of characters for a string
00129  */
00130 size_t
00131 VisualDisplay2DInterface::maxlenof_counter() const
00132 {
00133   return 1;
00134 }
00135 
00136 /** Set counter value.
00137  * Field
00138  * @param new_counter new counter value
00139  */
00140 void
00141 VisualDisplay2DInterface::set_counter(const uint32_t new_counter)
00142 {
00143   data->counter = new_counter;
00144   data_changed = true;
00145 }
00146 
00147 /* =========== message create =========== */
00148 Message *
00149 VisualDisplay2DInterface::create_message(const char *type) const
00150 {
00151   if ( strncmp("AddCartLineMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00152     return new AddCartLineMessage();
00153   } else if ( strncmp("AddCartCircleMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00154     return new AddCartCircleMessage();
00155   } else if ( strncmp("AddCartRectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00156     return new AddCartRectMessage();
00157   } else if ( strncmp("AddCartTextMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00158     return new AddCartTextMessage();
00159   } else if ( strncmp("DeleteObjectMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00160     return new DeleteObjectMessage();
00161   } else if ( strncmp("DeleteAllMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00162     return new DeleteAllMessage();
00163   } else {
00164     throw UnknownTypeException("The given type '%s' does not match any known "
00165                                "message type for this interface type.", type);
00166   }
00167 }
00168 
00169 
00170 /** Copy values from other interface.
00171  * @param other other interface to copy values from
00172  */
00173 void
00174 VisualDisplay2DInterface::copy_values(const Interface *other)
00175 {
00176   const VisualDisplay2DInterface *oi = dynamic_cast<const VisualDisplay2DInterface *>(other);
00177   if (oi == NULL) {
00178     throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00179                                 type(), other->type());
00180   }
00181   memcpy(data, oi->data, sizeof(VisualDisplay2DInterface_data_t));
00182 }
00183 
00184 const char *
00185 VisualDisplay2DInterface::enum_tostring(const char *enumtype, int val) const
00186 {
00187   if (strcmp(enumtype, "LineStyle") == 0) {
00188     return tostring_LineStyle((LineStyle)val);
00189   }
00190   if (strcmp(enumtype, "Anchor") == 0) {
00191     return tostring_Anchor((Anchor)val);
00192   }
00193   throw UnknownTypeException("Unknown enum type %s", enumtype);
00194 }
00195 
00196 /* =========== messages =========== */
00197 /** @class VisualDisplay2DInterface::AddCartLineMessage <interfaces/VisualDisplay2DInterface.h>
00198  * AddCartLineMessage Fawkes BlackBoard Interface Message.
00199  * 
00200     
00201  */
00202 
00203 
00204 /** Constructor with initial values.
00205  * @param ini_x initial value for x
00206  * @param ini_y initial value for y
00207  * @param ini_style initial value for style
00208  * @param ini_color initial value for color
00209  */
00210 VisualDisplay2DInterface::AddCartLineMessage::AddCartLineMessage(const float * ini_x, const float * ini_y, const LineStyle ini_style, const uint8_t * ini_color) : Message("AddCartLineMessage")
00211 {
00212   data_size = sizeof(AddCartLineMessage_data_t);
00213   data_ptr  = malloc(data_size);
00214   memset(data_ptr, 0, data_size);
00215   data      = (AddCartLineMessage_data_t *)data_ptr;
00216   data_ts   = (message_data_ts_t *)data_ptr;
00217   memcpy(data->x, ini_x, sizeof(float) * 2);
00218   memcpy(data->y, ini_y, sizeof(float) * 2);
00219   data->style = ini_style;
00220   memcpy(data->color, ini_color, sizeof(uint8_t) * 4);
00221   add_fieldinfo(IFT_FLOAT, "x", 2, &data->x);
00222   add_fieldinfo(IFT_FLOAT, "y", 2, &data->y);
00223   add_fieldinfo(IFT_ENUM, "style", 1, &data->style, "LineStyle");
00224   add_fieldinfo(IFT_BYTE, "color", 4, &data->color);
00225 }
00226 /** Constructor */
00227 VisualDisplay2DInterface::AddCartLineMessage::AddCartLineMessage() : Message("AddCartLineMessage")
00228 {
00229   data_size = sizeof(AddCartLineMessage_data_t);
00230   data_ptr  = malloc(data_size);
00231   memset(data_ptr, 0, data_size);
00232   data      = (AddCartLineMessage_data_t *)data_ptr;
00233   data_ts   = (message_data_ts_t *)data_ptr;
00234   add_fieldinfo(IFT_FLOAT, "x", 2, &data->x);
00235   add_fieldinfo(IFT_FLOAT, "y", 2, &data->y);
00236   add_fieldinfo(IFT_ENUM, "style", 1, &data->style, "LineStyle");
00237   add_fieldinfo(IFT_BYTE, "color", 4, &data->color);
00238 }
00239 
00240 /** Destructor */
00241 VisualDisplay2DInterface::AddCartLineMessage::~AddCartLineMessage()
00242 {
00243   free(data_ptr);
00244 }
00245 
00246 /** Copy constructor.
00247  * @param m message to copy from
00248  */
00249 VisualDisplay2DInterface::AddCartLineMessage::AddCartLineMessage(const AddCartLineMessage *m) : Message("AddCartLineMessage")
00250 {
00251   data_size = m->data_size;
00252   data_ptr  = malloc(data_size);
00253   memcpy(data_ptr, m->data_ptr, data_size);
00254   data      = (AddCartLineMessage_data_t *)data_ptr;
00255   data_ts   = (message_data_ts_t *)data_ptr;
00256 }
00257 
00258 /* Methods */
00259 /** Get x value.
00260  * X coordinates of two points
00261  * @return x value
00262  */
00263 float *
00264 VisualDisplay2DInterface::AddCartLineMessage::x() const
00265 {
00266   return data->x;
00267 }
00268 
00269 /** Get x value at given index.
00270  * X coordinates of two points
00271  * @param index index of value
00272  * @return x value
00273  * @exception Exception thrown if index is out of bounds
00274  */
00275 float
00276 VisualDisplay2DInterface::AddCartLineMessage::x(unsigned int index) const
00277 {
00278   if (index > 2) {
00279     throw Exception("Index value %u out of bounds (0..2)", index);
00280   }
00281   return data->x[index];
00282 }
00283 
00284 /** Get maximum length of x value.
00285  * @return length of x value, can be length of the array or number of 
00286  * maximum number of characters for a string
00287  */
00288 size_t
00289 VisualDisplay2DInterface::AddCartLineMessage::maxlenof_x() const
00290 {
00291   return 2;
00292 }
00293 
00294 /** Set x value.
00295  * X coordinates of two points
00296  * @param new_x new x value
00297  */
00298 void
00299 VisualDisplay2DInterface::AddCartLineMessage::set_x(const float * new_x)
00300 {
00301   memcpy(data->x, new_x, sizeof(float) * 2);
00302 }
00303 
00304 /** Set x value at given index.
00305  * X coordinates of two points
00306  * @param new_x new x value
00307  * @param index index for of the value
00308  */
00309 void
00310 VisualDisplay2DInterface::AddCartLineMessage::set_x(unsigned int index, const float new_x)
00311 {
00312   if (index > 2) {
00313     throw Exception("Index value %u out of bounds (0..2)", index);
00314   }
00315   data->x[index] = new_x;
00316 }
00317 /** Get y value.
00318  * Y coordinates of two
00319     points
00320  * @return y value
00321  */
00322 float *
00323 VisualDisplay2DInterface::AddCartLineMessage::y() const
00324 {
00325   return data->y;
00326 }
00327 
00328 /** Get y value at given index.
00329  * Y coordinates of two
00330     points
00331  * @param index index of value
00332  * @return y value
00333  * @exception Exception thrown if index is out of bounds
00334  */
00335 float
00336 VisualDisplay2DInterface::AddCartLineMessage::y(unsigned int index) const
00337 {
00338   if (index > 2) {
00339     throw Exception("Index value %u out of bounds (0..2)", index);
00340   }
00341   return data->y[index];
00342 }
00343 
00344 /** Get maximum length of y value.
00345  * @return length of y value, can be length of the array or number of 
00346  * maximum number of characters for a string
00347  */
00348 size_t
00349 VisualDisplay2DInterface::AddCartLineMessage::maxlenof_y() const
00350 {
00351   return 2;
00352 }
00353 
00354 /** Set y value.
00355  * Y coordinates of two
00356     points
00357  * @param new_y new y value
00358  */
00359 void
00360 VisualDisplay2DInterface::AddCartLineMessage::set_y(const float * new_y)
00361 {
00362   memcpy(data->y, new_y, sizeof(float) * 2);
00363 }
00364 
00365 /** Set y value at given index.
00366  * Y coordinates of two
00367     points
00368  * @param new_y new y value
00369  * @param index index for of the value
00370  */
00371 void
00372 VisualDisplay2DInterface::AddCartLineMessage::set_y(unsigned int index, const float new_y)
00373 {
00374   if (index > 2) {
00375     throw Exception("Index value %u out of bounds (0..2)", index);
00376   }
00377   data->y[index] = new_y;
00378 }
00379 /** Get style value.
00380  * Style of this object.
00381  * @return style value
00382  */
00383 VisualDisplay2DInterface::LineStyle
00384 VisualDisplay2DInterface::AddCartLineMessage::style() const
00385 {
00386   return data->style;
00387 }
00388 
00389 /** Get maximum length of style value.
00390  * @return length of style value, can be length of the array or number of 
00391  * maximum number of characters for a string
00392  */
00393 size_t
00394 VisualDisplay2DInterface::AddCartLineMessage::maxlenof_style() const
00395 {
00396   return 1;
00397 }
00398 
00399 /** Set style value.
00400  * Style of this object.
00401  * @param new_style new style value
00402  */
00403 void
00404 VisualDisplay2DInterface::AddCartLineMessage::set_style(const LineStyle new_style)
00405 {
00406   data->style = new_style;
00407 }
00408 
00409 /** Get color value.
00410  * Color in RGBA
00411  * @return color value
00412  */
00413 uint8_t *
00414 VisualDisplay2DInterface::AddCartLineMessage::color() const
00415 {
00416   return data->color;
00417 }
00418 
00419 /** Get color value at given index.
00420  * Color in RGBA
00421  * @param index index of value
00422  * @return color value
00423  * @exception Exception thrown if index is out of bounds
00424  */
00425 uint8_t
00426 VisualDisplay2DInterface::AddCartLineMessage::color(unsigned int index) const
00427 {
00428   if (index > 4) {
00429     throw Exception("Index value %u out of bounds (0..4)", index);
00430   }
00431   return data->color[index];
00432 }
00433 
00434 /** Get maximum length of color value.
00435  * @return length of color value, can be length of the array or number of 
00436  * maximum number of characters for a string
00437  */
00438 size_t
00439 VisualDisplay2DInterface::AddCartLineMessage::maxlenof_color() const
00440 {
00441   return 4;
00442 }
00443 
00444 /** Set color value.
00445  * Color in RGBA
00446  * @param new_color new color value
00447  */
00448 void
00449 VisualDisplay2DInterface::AddCartLineMessage::set_color(const uint8_t * new_color)
00450 {
00451   memcpy(data->color, new_color, sizeof(uint8_t) * 4);
00452 }
00453 
00454 /** Set color value at given index.
00455  * Color in RGBA
00456  * @param new_color new color value
00457  * @param index index for of the value
00458  */
00459 void
00460 VisualDisplay2DInterface::AddCartLineMessage::set_color(unsigned int index, const uint8_t new_color)
00461 {
00462   if (index > 4) {
00463     throw Exception("Index value %u out of bounds (0..4)", index);
00464   }
00465   data->color[index] = new_color;
00466 }
00467 /** Clone this message.
00468  * Produces a message of the same type as this message and copies the
00469  * data to the new message.
00470  * @return clone of this message
00471  */
00472 Message *
00473 VisualDisplay2DInterface::AddCartLineMessage::clone() const
00474 {
00475   return new VisualDisplay2DInterface::AddCartLineMessage(this);
00476 }
00477 /** @class VisualDisplay2DInterface::AddCartCircleMessage <interfaces/VisualDisplay2DInterface.h>
00478  * AddCartCircleMessage Fawkes BlackBoard Interface Message.
00479  * 
00480     
00481  */
00482 
00483 
00484 /** Constructor with initial values.
00485  * @param ini_x initial value for x
00486  * @param ini_y initial value for y
00487  * @param ini_radius initial value for radius
00488  * @param ini_style initial value for style
00489  * @param ini_color initial value for color
00490  */
00491 VisualDisplay2DInterface::AddCartCircleMessage::AddCartCircleMessage(const float ini_x, const float ini_y, const float ini_radius, const LineStyle ini_style, const uint8_t * ini_color) : Message("AddCartCircleMessage")
00492 {
00493   data_size = sizeof(AddCartCircleMessage_data_t);
00494   data_ptr  = malloc(data_size);
00495   memset(data_ptr, 0, data_size);
00496   data      = (AddCartCircleMessage_data_t *)data_ptr;
00497   data_ts   = (message_data_ts_t *)data_ptr;
00498   data->x = ini_x;
00499   data->y = ini_y;
00500   data->radius = ini_radius;
00501   data->style = ini_style;
00502   memcpy(data->color, ini_color, sizeof(uint8_t) * 4);
00503   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00504   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00505   add_fieldinfo(IFT_FLOAT, "radius", 1, &data->radius);
00506   add_fieldinfo(IFT_ENUM, "style", 1, &data->style, "LineStyle");
00507   add_fieldinfo(IFT_BYTE, "color", 4, &data->color);
00508 }
00509 /** Constructor */
00510 VisualDisplay2DInterface::AddCartCircleMessage::AddCartCircleMessage() : Message("AddCartCircleMessage")
00511 {
00512   data_size = sizeof(AddCartCircleMessage_data_t);
00513   data_ptr  = malloc(data_size);
00514   memset(data_ptr, 0, data_size);
00515   data      = (AddCartCircleMessage_data_t *)data_ptr;
00516   data_ts   = (message_data_ts_t *)data_ptr;
00517   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00518   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00519   add_fieldinfo(IFT_FLOAT, "radius", 1, &data->radius);
00520   add_fieldinfo(IFT_ENUM, "style", 1, &data->style, "LineStyle");
00521   add_fieldinfo(IFT_BYTE, "color", 4, &data->color);
00522 }
00523 
00524 /** Destructor */
00525 VisualDisplay2DInterface::AddCartCircleMessage::~AddCartCircleMessage()
00526 {
00527   free(data_ptr);
00528 }
00529 
00530 /** Copy constructor.
00531  * @param m message to copy from
00532  */
00533 VisualDisplay2DInterface::AddCartCircleMessage::AddCartCircleMessage(const AddCartCircleMessage *m) : Message("AddCartCircleMessage")
00534 {
00535   data_size = m->data_size;
00536   data_ptr  = malloc(data_size);
00537   memcpy(data_ptr, m->data_ptr, data_size);
00538   data      = (AddCartCircleMessage_data_t *)data_ptr;
00539   data_ts   = (message_data_ts_t *)data_ptr;
00540 }
00541 
00542 /* Methods */
00543 /** Get x value.
00544  * X coordinate of center point
00545  * @return x value
00546  */
00547 float
00548 VisualDisplay2DInterface::AddCartCircleMessage::x() const
00549 {
00550   return data->x;
00551 }
00552 
00553 /** Get maximum length of x value.
00554  * @return length of x value, can be length of the array or number of 
00555  * maximum number of characters for a string
00556  */
00557 size_t
00558 VisualDisplay2DInterface::AddCartCircleMessage::maxlenof_x() const
00559 {
00560   return 1;
00561 }
00562 
00563 /** Set x value.
00564  * X coordinate of center point
00565  * @param new_x new x value
00566  */
00567 void
00568 VisualDisplay2DInterface::AddCartCircleMessage::set_x(const float new_x)
00569 {
00570   data->x = new_x;
00571 }
00572 
00573 /** Get y value.
00574  * Y coordinate of center point
00575  * @return y value
00576  */
00577 float
00578 VisualDisplay2DInterface::AddCartCircleMessage::y() const
00579 {
00580   return data->y;
00581 }
00582 
00583 /** Get maximum length of y value.
00584  * @return length of y value, can be length of the array or number of 
00585  * maximum number of characters for a string
00586  */
00587 size_t
00588 VisualDisplay2DInterface::AddCartCircleMessage::maxlenof_y() const
00589 {
00590   return 1;
00591 }
00592 
00593 /** Set y value.
00594  * Y coordinate of center point
00595  * @param new_y new y value
00596  */
00597 void
00598 VisualDisplay2DInterface::AddCartCircleMessage::set_y(const float new_y)
00599 {
00600   data->y = new_y;
00601 }
00602 
00603 /** Get radius value.
00604  * Radius of the circle.
00605  * @return radius value
00606  */
00607 float
00608 VisualDisplay2DInterface::AddCartCircleMessage::radius() const
00609 {
00610   return data->radius;
00611 }
00612 
00613 /** Get maximum length of radius value.
00614  * @return length of radius value, can be length of the array or number of 
00615  * maximum number of characters for a string
00616  */
00617 size_t
00618 VisualDisplay2DInterface::AddCartCircleMessage::maxlenof_radius() const
00619 {
00620   return 1;
00621 }
00622 
00623 /** Set radius value.
00624  * Radius of the circle.
00625  * @param new_radius new radius value
00626  */
00627 void
00628 VisualDisplay2DInterface::AddCartCircleMessage::set_radius(const float new_radius)
00629 {
00630   data->radius = new_radius;
00631 }
00632 
00633 /** Get style value.
00634  * Style of this object.
00635  * @return style value
00636  */
00637 VisualDisplay2DInterface::LineStyle
00638 VisualDisplay2DInterface::AddCartCircleMessage::style() const
00639 {
00640   return data->style;
00641 }
00642 
00643 /** Get maximum length of style value.
00644  * @return length of style value, can be length of the array or number of 
00645  * maximum number of characters for a string
00646  */
00647 size_t
00648 VisualDisplay2DInterface::AddCartCircleMessage::maxlenof_style() const
00649 {
00650   return 1;
00651 }
00652 
00653 /** Set style value.
00654  * Style of this object.
00655  * @param new_style new style value
00656  */
00657 void
00658 VisualDisplay2DInterface::AddCartCircleMessage::set_style(const LineStyle new_style)
00659 {
00660   data->style = new_style;
00661 }
00662 
00663 /** Get color value.
00664  * Color in RGBA
00665  * @return color value
00666  */
00667 uint8_t *
00668 VisualDisplay2DInterface::AddCartCircleMessage::color() const
00669 {
00670   return data->color;
00671 }
00672 
00673 /** Get color value at given index.
00674  * Color in RGBA
00675  * @param index index of value
00676  * @return color value
00677  * @exception Exception thrown if index is out of bounds
00678  */
00679 uint8_t
00680 VisualDisplay2DInterface::AddCartCircleMessage::color(unsigned int index) const
00681 {
00682   if (index > 4) {
00683     throw Exception("Index value %u out of bounds (0..4)", index);
00684   }
00685   return data->color[index];
00686 }
00687 
00688 /** Get maximum length of color value.
00689  * @return length of color value, can be length of the array or number of 
00690  * maximum number of characters for a string
00691  */
00692 size_t
00693 VisualDisplay2DInterface::AddCartCircleMessage::maxlenof_color() const
00694 {
00695   return 4;
00696 }
00697 
00698 /** Set color value.
00699  * Color in RGBA
00700  * @param new_color new color value
00701  */
00702 void
00703 VisualDisplay2DInterface::AddCartCircleMessage::set_color(const uint8_t * new_color)
00704 {
00705   memcpy(data->color, new_color, sizeof(uint8_t) * 4);
00706 }
00707 
00708 /** Set color value at given index.
00709  * Color in RGBA
00710  * @param new_color new color value
00711  * @param index index for of the value
00712  */
00713 void
00714 VisualDisplay2DInterface::AddCartCircleMessage::set_color(unsigned int index, const uint8_t new_color)
00715 {
00716   if (index > 4) {
00717     throw Exception("Index value %u out of bounds (0..4)", index);
00718   }
00719   data->color[index] = new_color;
00720 }
00721 /** Clone this message.
00722  * Produces a message of the same type as this message and copies the
00723  * data to the new message.
00724  * @return clone of this message
00725  */
00726 Message *
00727 VisualDisplay2DInterface::AddCartCircleMessage::clone() const
00728 {
00729   return new VisualDisplay2DInterface::AddCartCircleMessage(this);
00730 }
00731 /** @class VisualDisplay2DInterface::AddCartRectMessage <interfaces/VisualDisplay2DInterface.h>
00732  * AddCartRectMessage Fawkes BlackBoard Interface Message.
00733  * 
00734     
00735  */
00736 
00737 
00738 /** Constructor with initial values.
00739  * @param ini_x initial value for x
00740  * @param ini_y initial value for y
00741  * @param ini_width initial value for width
00742  * @param ini_height initial value for height
00743  * @param ini_style initial value for style
00744  * @param ini_color initial value for color
00745  */
00746 VisualDisplay2DInterface::AddCartRectMessage::AddCartRectMessage(const float ini_x, const float ini_y, const float ini_width, const float ini_height, const LineStyle ini_style, const uint8_t * ini_color) : Message("AddCartRectMessage")
00747 {
00748   data_size = sizeof(AddCartRectMessage_data_t);
00749   data_ptr  = malloc(data_size);
00750   memset(data_ptr, 0, data_size);
00751   data      = (AddCartRectMessage_data_t *)data_ptr;
00752   data_ts   = (message_data_ts_t *)data_ptr;
00753   data->x = ini_x;
00754   data->y = ini_y;
00755   data->width = ini_width;
00756   data->height = ini_height;
00757   data->style = ini_style;
00758   memcpy(data->color, ini_color, sizeof(uint8_t) * 4);
00759   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00760   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00761   add_fieldinfo(IFT_FLOAT, "width", 1, &data->width);
00762   add_fieldinfo(IFT_FLOAT, "height", 1, &data->height);
00763   add_fieldinfo(IFT_ENUM, "style", 1, &data->style, "LineStyle");
00764   add_fieldinfo(IFT_BYTE, "color", 4, &data->color);
00765 }
00766 /** Constructor */
00767 VisualDisplay2DInterface::AddCartRectMessage::AddCartRectMessage() : Message("AddCartRectMessage")
00768 {
00769   data_size = sizeof(AddCartRectMessage_data_t);
00770   data_ptr  = malloc(data_size);
00771   memset(data_ptr, 0, data_size);
00772   data      = (AddCartRectMessage_data_t *)data_ptr;
00773   data_ts   = (message_data_ts_t *)data_ptr;
00774   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
00775   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
00776   add_fieldinfo(IFT_FLOAT, "width", 1, &data->width);
00777   add_fieldinfo(IFT_FLOAT, "height", 1, &data->height);
00778   add_fieldinfo(IFT_ENUM, "style", 1, &data->style, "LineStyle");
00779   add_fieldinfo(IFT_BYTE, "color", 4, &data->color);
00780 }
00781 
00782 /** Destructor */
00783 VisualDisplay2DInterface::AddCartRectMessage::~AddCartRectMessage()
00784 {
00785   free(data_ptr);
00786 }
00787 
00788 /** Copy constructor.
00789  * @param m message to copy from
00790  */
00791 VisualDisplay2DInterface::AddCartRectMessage::AddCartRectMessage(const AddCartRectMessage *m) : Message("AddCartRectMessage")
00792 {
00793   data_size = m->data_size;
00794   data_ptr  = malloc(data_size);
00795   memcpy(data_ptr, m->data_ptr, data_size);
00796   data      = (AddCartRectMessage_data_t *)data_ptr;
00797   data_ts   = (message_data_ts_t *)data_ptr;
00798 }
00799 
00800 /* Methods */
00801 /** Get x value.
00802  * X coordinate of lower right corner
00803  * @return x value
00804  */
00805 float
00806 VisualDisplay2DInterface::AddCartRectMessage::x() const
00807 {
00808   return data->x;
00809 }
00810 
00811 /** Get maximum length of x value.
00812  * @return length of x value, can be length of the array or number of 
00813  * maximum number of characters for a string
00814  */
00815 size_t
00816 VisualDisplay2DInterface::AddCartRectMessage::maxlenof_x() const
00817 {
00818   return 1;
00819 }
00820 
00821 /** Set x value.
00822  * X coordinate of lower right corner
00823  * @param new_x new x value
00824  */
00825 void
00826 VisualDisplay2DInterface::AddCartRectMessage::set_x(const float new_x)
00827 {
00828   data->x = new_x;
00829 }
00830 
00831 /** Get y value.
00832  * Y coordinate of lower right corner
00833  * @return y value
00834  */
00835 float
00836 VisualDisplay2DInterface::AddCartRectMessage::y() const
00837 {
00838   return data->y;
00839 }
00840 
00841 /** Get maximum length of y value.
00842  * @return length of y value, can be length of the array or number of 
00843  * maximum number of characters for a string
00844  */
00845 size_t
00846 VisualDisplay2DInterface::AddCartRectMessage::maxlenof_y() const
00847 {
00848   return 1;
00849 }
00850 
00851 /** Set y value.
00852  * Y coordinate of lower right corner
00853  * @param new_y new y value
00854  */
00855 void
00856 VisualDisplay2DInterface::AddCartRectMessage::set_y(const float new_y)
00857 {
00858   data->y = new_y;
00859 }
00860 
00861 /** Get width value.
00862  * Width of rectangle
00863  * @return width value
00864  */
00865 float
00866 VisualDisplay2DInterface::AddCartRectMessage::width() const
00867 {
00868   return data->width;
00869 }
00870 
00871 /** Get maximum length of width value.
00872  * @return length of width value, can be length of the array or number of 
00873  * maximum number of characters for a string
00874  */
00875 size_t
00876 VisualDisplay2DInterface::AddCartRectMessage::maxlenof_width() const
00877 {
00878   return 1;
00879 }
00880 
00881 /** Set width value.
00882  * Width of rectangle
00883  * @param new_width new width value
00884  */
00885 void
00886 VisualDisplay2DInterface::AddCartRectMessage::set_width(const float new_width)
00887 {
00888   data->width = new_width;
00889 }
00890 
00891 /** Get height value.
00892  * Height of rectangle
00893  * @return height value
00894  */
00895 float
00896 VisualDisplay2DInterface::AddCartRectMessage::height() const
00897 {
00898   return data->height;
00899 }
00900 
00901 /** Get maximum length of height value.
00902  * @return length of height value, can be length of the array or number of 
00903  * maximum number of characters for a string
00904  */
00905 size_t
00906 VisualDisplay2DInterface::AddCartRectMessage::maxlenof_height() const
00907 {
00908   return 1;
00909 }
00910 
00911 /** Set height value.
00912  * Height of rectangle
00913  * @param new_height new height value
00914  */
00915 void
00916 VisualDisplay2DInterface::AddCartRectMessage::set_height(const float new_height)
00917 {
00918   data->height = new_height;
00919 }
00920 
00921 /** Get style value.
00922  * Style of this object.
00923  * @return style value
00924  */
00925 VisualDisplay2DInterface::LineStyle
00926 VisualDisplay2DInterface::AddCartRectMessage::style() const
00927 {
00928   return data->style;
00929 }
00930 
00931 /** Get maximum length of style value.
00932  * @return length of style value, can be length of the array or number of 
00933  * maximum number of characters for a string
00934  */
00935 size_t
00936 VisualDisplay2DInterface::AddCartRectMessage::maxlenof_style() const
00937 {
00938   return 1;
00939 }
00940 
00941 /** Set style value.
00942  * Style of this object.
00943  * @param new_style new style value
00944  */
00945 void
00946 VisualDisplay2DInterface::AddCartRectMessage::set_style(const LineStyle new_style)
00947 {
00948   data->style = new_style;
00949 }
00950 
00951 /** Get color value.
00952  * Color in RGBA
00953  * @return color value
00954  */
00955 uint8_t *
00956 VisualDisplay2DInterface::AddCartRectMessage::color() const
00957 {
00958   return data->color;
00959 }
00960 
00961 /** Get color value at given index.
00962  * Color in RGBA
00963  * @param index index of value
00964  * @return color value
00965  * @exception Exception thrown if index is out of bounds
00966  */
00967 uint8_t
00968 VisualDisplay2DInterface::AddCartRectMessage::color(unsigned int index) const
00969 {
00970   if (index > 4) {
00971     throw Exception("Index value %u out of bounds (0..4)", index);
00972   }
00973   return data->color[index];
00974 }
00975 
00976 /** Get maximum length of color value.
00977  * @return length of color value, can be length of the array or number of 
00978  * maximum number of characters for a string
00979  */
00980 size_t
00981 VisualDisplay2DInterface::AddCartRectMessage::maxlenof_color() const
00982 {
00983   return 4;
00984 }
00985 
00986 /** Set color value.
00987  * Color in RGBA
00988  * @param new_color new color value
00989  */
00990 void
00991 VisualDisplay2DInterface::AddCartRectMessage::set_color(const uint8_t * new_color)
00992 {
00993   memcpy(data->color, new_color, sizeof(uint8_t) * 4);
00994 }
00995 
00996 /** Set color value at given index.
00997  * Color in RGBA
00998  * @param new_color new color value
00999  * @param index index for of the value
01000  */
01001 void
01002 VisualDisplay2DInterface::AddCartRectMessage::set_color(unsigned int index, const uint8_t new_color)
01003 {
01004   if (index > 4) {
01005     throw Exception("Index value %u out of bounds (0..4)", index);
01006   }
01007   data->color[index] = new_color;
01008 }
01009 /** Clone this message.
01010  * Produces a message of the same type as this message and copies the
01011  * data to the new message.
01012  * @return clone of this message
01013  */
01014 Message *
01015 VisualDisplay2DInterface::AddCartRectMessage::clone() const
01016 {
01017   return new VisualDisplay2DInterface::AddCartRectMessage(this);
01018 }
01019 /** @class VisualDisplay2DInterface::AddCartTextMessage <interfaces/VisualDisplay2DInterface.h>
01020  * AddCartTextMessage Fawkes BlackBoard Interface Message.
01021  * 
01022     
01023  */
01024 
01025 
01026 /** Constructor with initial values.
01027  * @param ini_x initial value for x
01028  * @param ini_y initial value for y
01029  * @param ini_text initial value for text
01030  * @param ini_anchor initial value for anchor
01031  * @param ini_size initial value for size
01032  * @param ini_color initial value for color
01033  */
01034 VisualDisplay2DInterface::AddCartTextMessage::AddCartTextMessage(const float ini_x, const float ini_y, const char * ini_text, const Anchor ini_anchor, const float ini_size, const uint8_t * ini_color) : Message("AddCartTextMessage")
01035 {
01036   data_size = sizeof(AddCartTextMessage_data_t);
01037   data_ptr  = malloc(data_size);
01038   memset(data_ptr, 0, data_size);
01039   data      = (AddCartTextMessage_data_t *)data_ptr;
01040   data_ts   = (message_data_ts_t *)data_ptr;
01041   data->x = ini_x;
01042   data->y = ini_y;
01043   strncpy(data->text, ini_text, 128);
01044   data->anchor = ini_anchor;
01045   data->size = ini_size;
01046   memcpy(data->color, ini_color, sizeof(uint8_t) * 4);
01047   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
01048   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
01049   add_fieldinfo(IFT_STRING, "text", 128, data->text);
01050   add_fieldinfo(IFT_ENUM, "anchor", 1, &data->anchor, "Anchor");
01051   add_fieldinfo(IFT_FLOAT, "size", 1, &data->size);
01052   add_fieldinfo(IFT_BYTE, "color", 4, &data->color);
01053 }
01054 /** Constructor */
01055 VisualDisplay2DInterface::AddCartTextMessage::AddCartTextMessage() : Message("AddCartTextMessage")
01056 {
01057   data_size = sizeof(AddCartTextMessage_data_t);
01058   data_ptr  = malloc(data_size);
01059   memset(data_ptr, 0, data_size);
01060   data      = (AddCartTextMessage_data_t *)data_ptr;
01061   data_ts   = (message_data_ts_t *)data_ptr;
01062   add_fieldinfo(IFT_FLOAT, "x", 1, &data->x);
01063   add_fieldinfo(IFT_FLOAT, "y", 1, &data->y);
01064   add_fieldinfo(IFT_STRING, "text", 128, data->text);
01065   add_fieldinfo(IFT_ENUM, "anchor", 1, &data->anchor, "Anchor");
01066   add_fieldinfo(IFT_FLOAT, "size", 1, &data->size);
01067   add_fieldinfo(IFT_BYTE, "color", 4, &data->color);
01068 }
01069 
01070 /** Destructor */
01071 VisualDisplay2DInterface::AddCartTextMessage::~AddCartTextMessage()
01072 {
01073   free(data_ptr);
01074 }
01075 
01076 /** Copy constructor.
01077  * @param m message to copy from
01078  */
01079 VisualDisplay2DInterface::AddCartTextMessage::AddCartTextMessage(const AddCartTextMessage *m) : Message("AddCartTextMessage")
01080 {
01081   data_size = m->data_size;
01082   data_ptr  = malloc(data_size);
01083   memcpy(data_ptr, m->data_ptr, data_size);
01084   data      = (AddCartTextMessage_data_t *)data_ptr;
01085   data_ts   = (message_data_ts_t *)data_ptr;
01086 }
01087 
01088 /* Methods */
01089 /** Get x value.
01090  * X coordinate of upper left corner
01091  * @return x value
01092  */
01093 float
01094 VisualDisplay2DInterface::AddCartTextMessage::x() const
01095 {
01096   return data->x;
01097 }
01098 
01099 /** Get maximum length of x value.
01100  * @return length of x value, can be length of the array or number of 
01101  * maximum number of characters for a string
01102  */
01103 size_t
01104 VisualDisplay2DInterface::AddCartTextMessage::maxlenof_x() const
01105 {
01106   return 1;
01107 }
01108 
01109 /** Set x value.
01110  * X coordinate of upper left corner
01111  * @param new_x new x value
01112  */
01113 void
01114 VisualDisplay2DInterface::AddCartTextMessage::set_x(const float new_x)
01115 {
01116   data->x = new_x;
01117 }
01118 
01119 /** Get y value.
01120  * Y coordinate of upper left corner
01121  * @return y value
01122  */
01123 float
01124 VisualDisplay2DInterface::AddCartTextMessage::y() const
01125 {
01126   return data->y;
01127 }
01128 
01129 /** Get maximum length of y value.
01130  * @return length of y value, can be length of the array or number of 
01131  * maximum number of characters for a string
01132  */
01133 size_t
01134 VisualDisplay2DInterface::AddCartTextMessage::maxlenof_y() const
01135 {
01136   return 1;
01137 }
01138 
01139 /** Set y value.
01140  * Y coordinate of upper left corner
01141  * @param new_y new y value
01142  */
01143 void
01144 VisualDisplay2DInterface::AddCartTextMessage::set_y(const float new_y)
01145 {
01146   data->y = new_y;
01147 }
01148 
01149 /** Get text value.
01150  * Width of rectangle
01151  * @return text value
01152  */
01153 char *
01154 VisualDisplay2DInterface::AddCartTextMessage::text() const
01155 {
01156   return data->text;
01157 }
01158 
01159 /** Get maximum length of text value.
01160  * @return length of text value, can be length of the array or number of 
01161  * maximum number of characters for a string
01162  */
01163 size_t
01164 VisualDisplay2DInterface::AddCartTextMessage::maxlenof_text() const
01165 {
01166   return 128;
01167 }
01168 
01169 /** Set text value.
01170  * Width of rectangle
01171  * @param new_text new text value
01172  */
01173 void
01174 VisualDisplay2DInterface::AddCartTextMessage::set_text(const char * new_text)
01175 {
01176   strncpy(data->text, new_text, sizeof(data->text));
01177 }
01178 
01179 /** Get anchor value.
01180  * Anchor which marks the
01181       alignment to the given point.
01182  * @return anchor value
01183  */
01184 VisualDisplay2DInterface::Anchor
01185 VisualDisplay2DInterface::AddCartTextMessage::anchor() const
01186 {
01187   return data->anchor;
01188 }
01189 
01190 /** Get maximum length of anchor value.
01191  * @return length of anchor value, can be length of the array or number of 
01192  * maximum number of characters for a string
01193  */
01194 size_t
01195 VisualDisplay2DInterface::AddCartTextMessage::maxlenof_anchor() const
01196 {
01197   return 1;
01198 }
01199 
01200 /** Set anchor value.
01201  * Anchor which marks the
01202       alignment to the given point.
01203  * @param new_anchor new anchor value
01204  */
01205 void
01206 VisualDisplay2DInterface::AddCartTextMessage::set_anchor(const Anchor new_anchor)
01207 {
01208   data->anchor = new_anchor;
01209 }
01210 
01211 /** Get size value.
01212  * Font size (max height in m).
01213  * @return size value
01214  */
01215 float
01216 VisualDisplay2DInterface::AddCartTextMessage::size() const
01217 {
01218   return data->size;
01219 }
01220 
01221 /** Get maximum length of size value.
01222  * @return length of size value, can be length of the array or number of 
01223  * maximum number of characters for a string
01224  */
01225 size_t
01226 VisualDisplay2DInterface::AddCartTextMessage::maxlenof_size() const
01227 {
01228   return 1;
01229 }
01230 
01231 /** Set size value.
01232  * Font size (max height in m).
01233  * @param new_size new size value
01234  */
01235 void
01236 VisualDisplay2DInterface::AddCartTextMessage::set_size(const float new_size)
01237 {
01238   data->size = new_size;
01239 }
01240 
01241 /** Get color value.
01242  * Color in RGBA
01243  * @return color value
01244  */
01245 uint8_t *
01246 VisualDisplay2DInterface::AddCartTextMessage::color() const
01247 {
01248   return data->color;
01249 }
01250 
01251 /** Get color value at given index.
01252  * Color in RGBA
01253  * @param index index of value
01254  * @return color value
01255  * @exception Exception thrown if index is out of bounds
01256  */
01257 uint8_t
01258 VisualDisplay2DInterface::AddCartTextMessage::color(unsigned int index) const
01259 {
01260   if (index > 4) {
01261     throw Exception("Index value %u out of bounds (0..4)", index);
01262   }
01263   return data->color[index];
01264 }
01265 
01266 /** Get maximum length of color value.
01267  * @return length of color value, can be length of the array or number of 
01268  * maximum number of characters for a string
01269  */
01270 size_t
01271 VisualDisplay2DInterface::AddCartTextMessage::maxlenof_color() const
01272 {
01273   return 4;
01274 }
01275 
01276 /** Set color value.
01277  * Color in RGBA
01278  * @param new_color new color value
01279  */
01280 void
01281 VisualDisplay2DInterface::AddCartTextMessage::set_color(const uint8_t * new_color)
01282 {
01283   memcpy(data->color, new_color, sizeof(uint8_t) * 4);
01284 }
01285 
01286 /** Set color value at given index.
01287  * Color in RGBA
01288  * @param new_color new color value
01289  * @param index index for of the value
01290  */
01291 void
01292 VisualDisplay2DInterface::AddCartTextMessage::set_color(unsigned int index, const uint8_t new_color)
01293 {
01294   if (index > 4) {
01295     throw Exception("Index value %u out of bounds (0..4)", index);
01296   }
01297   data->color[index] = new_color;
01298 }
01299 /** Clone this message.
01300  * Produces a message of the same type as this message and copies the
01301  * data to the new message.
01302  * @return clone of this message
01303  */
01304 Message *
01305 VisualDisplay2DInterface::AddCartTextMessage::clone() const
01306 {
01307   return new VisualDisplay2DInterface::AddCartTextMessage(this);
01308 }
01309 /** @class VisualDisplay2DInterface::DeleteObjectMessage <interfaces/VisualDisplay2DInterface.h>
01310  * DeleteObjectMessage Fawkes BlackBoard Interface Message.
01311  * 
01312     
01313  */
01314 
01315 
01316 /** Constructor with initial values.
01317  * @param ini_object_id initial value for object_id
01318  */
01319 VisualDisplay2DInterface::DeleteObjectMessage::DeleteObjectMessage(const uint32_t ini_object_id) : Message("DeleteObjectMessage")
01320 {
01321   data_size = sizeof(DeleteObjectMessage_data_t);
01322   data_ptr  = malloc(data_size);
01323   memset(data_ptr, 0, data_size);
01324   data      = (DeleteObjectMessage_data_t *)data_ptr;
01325   data_ts   = (message_data_ts_t *)data_ptr;
01326   data->object_id = ini_object_id;
01327   add_fieldinfo(IFT_UINT32, "object_id", 1, &data->object_id);
01328 }
01329 /** Constructor */
01330 VisualDisplay2DInterface::DeleteObjectMessage::DeleteObjectMessage() : Message("DeleteObjectMessage")
01331 {
01332   data_size = sizeof(DeleteObjectMessage_data_t);
01333   data_ptr  = malloc(data_size);
01334   memset(data_ptr, 0, data_size);
01335   data      = (DeleteObjectMessage_data_t *)data_ptr;
01336   data_ts   = (message_data_ts_t *)data_ptr;
01337   add_fieldinfo(IFT_UINT32, "object_id", 1, &data->object_id);
01338 }
01339 
01340 /** Destructor */
01341 VisualDisplay2DInterface::DeleteObjectMessage::~DeleteObjectMessage()
01342 {
01343   free(data_ptr);
01344 }
01345 
01346 /** Copy constructor.
01347  * @param m message to copy from
01348  */
01349 VisualDisplay2DInterface::DeleteObjectMessage::DeleteObjectMessage(const DeleteObjectMessage *m) : Message("DeleteObjectMessage")
01350 {
01351   data_size = m->data_size;
01352   data_ptr  = malloc(data_size);
01353   memcpy(data_ptr, m->data_ptr, data_size);
01354   data      = (DeleteObjectMessage_data_t *)data_ptr;
01355   data_ts   = (message_data_ts_t *)data_ptr;
01356 }
01357 
01358 /* Methods */
01359 /** Get object_id value.
01360  * Object ID, which is
01361     the message ID of the Add* message.
01362  * @return object_id value
01363  */
01364 uint32_t
01365 VisualDisplay2DInterface::DeleteObjectMessage::object_id() const
01366 {
01367   return data->object_id;
01368 }
01369 
01370 /** Get maximum length of object_id value.
01371  * @return length of object_id value, can be length of the array or number of 
01372  * maximum number of characters for a string
01373  */
01374 size_t
01375 VisualDisplay2DInterface::DeleteObjectMessage::maxlenof_object_id() const
01376 {
01377   return 1;
01378 }
01379 
01380 /** Set object_id value.
01381  * Object ID, which is
01382     the message ID of the Add* message.
01383  * @param new_object_id new object_id value
01384  */
01385 void
01386 VisualDisplay2DInterface::DeleteObjectMessage::set_object_id(const uint32_t new_object_id)
01387 {
01388   data->object_id = new_object_id;
01389 }
01390 
01391 /** Clone this message.
01392  * Produces a message of the same type as this message and copies the
01393  * data to the new message.
01394  * @return clone of this message
01395  */
01396 Message *
01397 VisualDisplay2DInterface::DeleteObjectMessage::clone() const
01398 {
01399   return new VisualDisplay2DInterface::DeleteObjectMessage(this);
01400 }
01401 /** @class VisualDisplay2DInterface::DeleteAllMessage <interfaces/VisualDisplay2DInterface.h>
01402  * DeleteAllMessage Fawkes BlackBoard Interface Message.
01403  * 
01404     
01405  */
01406 
01407 
01408 /** Constructor */
01409 VisualDisplay2DInterface::DeleteAllMessage::DeleteAllMessage() : Message("DeleteAllMessage")
01410 {
01411   data_size = sizeof(DeleteAllMessage_data_t);
01412   data_ptr  = malloc(data_size);
01413   memset(data_ptr, 0, data_size);
01414   data      = (DeleteAllMessage_data_t *)data_ptr;
01415   data_ts   = (message_data_ts_t *)data_ptr;
01416 }
01417 
01418 /** Destructor */
01419 VisualDisplay2DInterface::DeleteAllMessage::~DeleteAllMessage()
01420 {
01421   free(data_ptr);
01422 }
01423 
01424 /** Copy constructor.
01425  * @param m message to copy from
01426  */
01427 VisualDisplay2DInterface::DeleteAllMessage::DeleteAllMessage(const DeleteAllMessage *m) : Message("DeleteAllMessage")
01428 {
01429   data_size = m->data_size;
01430   data_ptr  = malloc(data_size);
01431   memcpy(data_ptr, m->data_ptr, data_size);
01432   data      = (DeleteAllMessage_data_t *)data_ptr;
01433   data_ts   = (message_data_ts_t *)data_ptr;
01434 }
01435 
01436 /* Methods */
01437 /** Clone this message.
01438  * Produces a message of the same type as this message and copies the
01439  * data to the new message.
01440  * @return clone of this message
01441  */
01442 Message *
01443 VisualDisplay2DInterface::DeleteAllMessage::clone() const
01444 {
01445   return new VisualDisplay2DInterface::DeleteAllMessage(this);
01446 }
01447 /** Check if message is valid and can be enqueued.
01448  * @param message Message to check
01449  * @return true if the message is valid, false otherwise.
01450  */
01451 bool
01452 VisualDisplay2DInterface::message_valid(const Message *message) const
01453 {
01454   const AddCartLineMessage *m0 = dynamic_cast<const AddCartLineMessage *>(message);
01455   if ( m0 != NULL ) {
01456     return true;
01457   }
01458   const AddCartCircleMessage *m1 = dynamic_cast<const AddCartCircleMessage *>(message);
01459   if ( m1 != NULL ) {
01460     return true;
01461   }
01462   const AddCartRectMessage *m2 = dynamic_cast<const AddCartRectMessage *>(message);
01463   if ( m2 != NULL ) {
01464     return true;
01465   }
01466   const AddCartTextMessage *m3 = dynamic_cast<const AddCartTextMessage *>(message);
01467   if ( m3 != NULL ) {
01468     return true;
01469   }
01470   const DeleteObjectMessage *m4 = dynamic_cast<const DeleteObjectMessage *>(message);
01471   if ( m4 != NULL ) {
01472     return true;
01473   }
01474   const DeleteAllMessage *m5 = dynamic_cast<const DeleteAllMessage *>(message);
01475   if ( m5 != NULL ) {
01476     return true;
01477   }
01478   return false;
01479 }
01480 
01481 /// @cond INTERNALS
01482 EXPORT_INTERFACE(VisualDisplay2DInterface)
01483 /// @endcond
01484 
01485 
01486 } // end namespace fawkes

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1