catchrobo2022 / Mbed 2 deprecated catchrobo2022_mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MouseEvent.h Source File

MouseEvent.h

00001 #ifndef _ROS_image_view2_MouseEvent_h
00002 #define _ROS_image_view2_MouseEvent_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 
00010 namespace image_view2
00011 {
00012 
00013   class MouseEvent : public ros::Msg
00014   {
00015     public:
00016       typedef std_msgs::Header _header_type;
00017       _header_type header;
00018       typedef int32_t _type_type;
00019       _type_type type;
00020       typedef int32_t _key_type;
00021       _key_type key;
00022       typedef int32_t _x_type;
00023       _x_type x;
00024       typedef int32_t _y_type;
00025       _y_type y;
00026       typedef int32_t _width_type;
00027       _width_type width;
00028       typedef int32_t _height_type;
00029       _height_type height;
00030       enum { KEY_PRESSED = 1 };
00031       enum { MOUSE_LEFT_UP = 2 };
00032       enum { MOUSE_LEFT_DOWN = 3 };
00033       enum { MOUSE_MOVE = 4 };
00034       enum { MOUSE_RIGHT_DOWN = 5 };
00035 
00036     MouseEvent():
00037       header(),
00038       type(0),
00039       key(0),
00040       x(0),
00041       y(0),
00042       width(0),
00043       height(0)
00044     {
00045     }
00046 
00047     virtual int serialize(unsigned char *outbuffer) const
00048     {
00049       int offset = 0;
00050       offset += this->header.serialize(outbuffer + offset);
00051       union {
00052         int32_t real;
00053         uint32_t base;
00054       } u_type;
00055       u_type.real = this->type;
00056       *(outbuffer + offset + 0) = (u_type.base >> (8 * 0)) & 0xFF;
00057       *(outbuffer + offset + 1) = (u_type.base >> (8 * 1)) & 0xFF;
00058       *(outbuffer + offset + 2) = (u_type.base >> (8 * 2)) & 0xFF;
00059       *(outbuffer + offset + 3) = (u_type.base >> (8 * 3)) & 0xFF;
00060       offset += sizeof(this->type);
00061       union {
00062         int32_t real;
00063         uint32_t base;
00064       } u_key;
00065       u_key.real = this->key;
00066       *(outbuffer + offset + 0) = (u_key.base >> (8 * 0)) & 0xFF;
00067       *(outbuffer + offset + 1) = (u_key.base >> (8 * 1)) & 0xFF;
00068       *(outbuffer + offset + 2) = (u_key.base >> (8 * 2)) & 0xFF;
00069       *(outbuffer + offset + 3) = (u_key.base >> (8 * 3)) & 0xFF;
00070       offset += sizeof(this->key);
00071       union {
00072         int32_t real;
00073         uint32_t base;
00074       } u_x;
00075       u_x.real = this->x;
00076       *(outbuffer + offset + 0) = (u_x.base >> (8 * 0)) & 0xFF;
00077       *(outbuffer + offset + 1) = (u_x.base >> (8 * 1)) & 0xFF;
00078       *(outbuffer + offset + 2) = (u_x.base >> (8 * 2)) & 0xFF;
00079       *(outbuffer + offset + 3) = (u_x.base >> (8 * 3)) & 0xFF;
00080       offset += sizeof(this->x);
00081       union {
00082         int32_t real;
00083         uint32_t base;
00084       } u_y;
00085       u_y.real = this->y;
00086       *(outbuffer + offset + 0) = (u_y.base >> (8 * 0)) & 0xFF;
00087       *(outbuffer + offset + 1) = (u_y.base >> (8 * 1)) & 0xFF;
00088       *(outbuffer + offset + 2) = (u_y.base >> (8 * 2)) & 0xFF;
00089       *(outbuffer + offset + 3) = (u_y.base >> (8 * 3)) & 0xFF;
00090       offset += sizeof(this->y);
00091       union {
00092         int32_t real;
00093         uint32_t base;
00094       } u_width;
00095       u_width.real = this->width;
00096       *(outbuffer + offset + 0) = (u_width.base >> (8 * 0)) & 0xFF;
00097       *(outbuffer + offset + 1) = (u_width.base >> (8 * 1)) & 0xFF;
00098       *(outbuffer + offset + 2) = (u_width.base >> (8 * 2)) & 0xFF;
00099       *(outbuffer + offset + 3) = (u_width.base >> (8 * 3)) & 0xFF;
00100       offset += sizeof(this->width);
00101       union {
00102         int32_t real;
00103         uint32_t base;
00104       } u_height;
00105       u_height.real = this->height;
00106       *(outbuffer + offset + 0) = (u_height.base >> (8 * 0)) & 0xFF;
00107       *(outbuffer + offset + 1) = (u_height.base >> (8 * 1)) & 0xFF;
00108       *(outbuffer + offset + 2) = (u_height.base >> (8 * 2)) & 0xFF;
00109       *(outbuffer + offset + 3) = (u_height.base >> (8 * 3)) & 0xFF;
00110       offset += sizeof(this->height);
00111       return offset;
00112     }
00113 
00114     virtual int deserialize(unsigned char *inbuffer)
00115     {
00116       int offset = 0;
00117       offset += this->header.deserialize(inbuffer + offset);
00118       union {
00119         int32_t real;
00120         uint32_t base;
00121       } u_type;
00122       u_type.base = 0;
00123       u_type.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00124       u_type.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00125       u_type.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00126       u_type.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00127       this->type = u_type.real;
00128       offset += sizeof(this->type);
00129       union {
00130         int32_t real;
00131         uint32_t base;
00132       } u_key;
00133       u_key.base = 0;
00134       u_key.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00135       u_key.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00136       u_key.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00137       u_key.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00138       this->key = u_key.real;
00139       offset += sizeof(this->key);
00140       union {
00141         int32_t real;
00142         uint32_t base;
00143       } u_x;
00144       u_x.base = 0;
00145       u_x.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00146       u_x.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00147       u_x.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00148       u_x.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00149       this->x = u_x.real;
00150       offset += sizeof(this->x);
00151       union {
00152         int32_t real;
00153         uint32_t base;
00154       } u_y;
00155       u_y.base = 0;
00156       u_y.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00157       u_y.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00158       u_y.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00159       u_y.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00160       this->y = u_y.real;
00161       offset += sizeof(this->y);
00162       union {
00163         int32_t real;
00164         uint32_t base;
00165       } u_width;
00166       u_width.base = 0;
00167       u_width.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00168       u_width.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00169       u_width.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00170       u_width.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00171       this->width = u_width.real;
00172       offset += sizeof(this->width);
00173       union {
00174         int32_t real;
00175         uint32_t base;
00176       } u_height;
00177       u_height.base = 0;
00178       u_height.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00179       u_height.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00180       u_height.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00181       u_height.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00182       this->height = u_height.real;
00183       offset += sizeof(this->height);
00184      return offset;
00185     }
00186 
00187     virtual const char * getType(){ return "image_view2/MouseEvent"; };
00188     virtual const char * getMD5(){ return "7ffa73624c1be385169a9e6e23460224"; };
00189 
00190   };
00191 
00192 }
00193 #endif