Gary Servin / ros_lib_indigo

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MenuEntry.h Source File

MenuEntry.h

00001 #ifndef _ROS_visualization_msgs_MenuEntry_h
00002 #define _ROS_visualization_msgs_MenuEntry_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace visualization_msgs
00010 {
00011 
00012   class MenuEntry : public ros::Msg
00013   {
00014     public:
00015       uint32_t id;
00016       uint32_t parent_id;
00017       const char* title;
00018       const char* command;
00019       uint8_t command_type;
00020       enum { FEEDBACK = 0 };
00021       enum { ROSRUN = 1 };
00022       enum { ROSLAUNCH = 2 };
00023 
00024     MenuEntry():
00025       id(0),
00026       parent_id(0),
00027       title(""),
00028       command(""),
00029       command_type(0)
00030     {
00031     }
00032 
00033     virtual int serialize(unsigned char *outbuffer) const
00034     {
00035       int offset = 0;
00036       *(outbuffer + offset + 0) = (this->id >> (8 * 0)) & 0xFF;
00037       *(outbuffer + offset + 1) = (this->id >> (8 * 1)) & 0xFF;
00038       *(outbuffer + offset + 2) = (this->id >> (8 * 2)) & 0xFF;
00039       *(outbuffer + offset + 3) = (this->id >> (8 * 3)) & 0xFF;
00040       offset += sizeof(this->id);
00041       *(outbuffer + offset + 0) = (this->parent_id >> (8 * 0)) & 0xFF;
00042       *(outbuffer + offset + 1) = (this->parent_id >> (8 * 1)) & 0xFF;
00043       *(outbuffer + offset + 2) = (this->parent_id >> (8 * 2)) & 0xFF;
00044       *(outbuffer + offset + 3) = (this->parent_id >> (8 * 3)) & 0xFF;
00045       offset += sizeof(this->parent_id);
00046       uint32_t length_title = strlen(this->title);
00047       memcpy(outbuffer + offset, &length_title, sizeof(uint32_t));
00048       offset += 4;
00049       memcpy(outbuffer + offset, this->title, length_title);
00050       offset += length_title;
00051       uint32_t length_command = strlen(this->command);
00052       memcpy(outbuffer + offset, &length_command, sizeof(uint32_t));
00053       offset += 4;
00054       memcpy(outbuffer + offset, this->command, length_command);
00055       offset += length_command;
00056       *(outbuffer + offset + 0) = (this->command_type >> (8 * 0)) & 0xFF;
00057       offset += sizeof(this->command_type);
00058       return offset;
00059     }
00060 
00061     virtual int deserialize(unsigned char *inbuffer)
00062     {
00063       int offset = 0;
00064       this->id =  ((uint32_t) (*(inbuffer + offset)));
00065       this->id |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00066       this->id |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00067       this->id |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00068       offset += sizeof(this->id);
00069       this->parent_id =  ((uint32_t) (*(inbuffer + offset)));
00070       this->parent_id |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00071       this->parent_id |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00072       this->parent_id |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00073       offset += sizeof(this->parent_id);
00074       uint32_t length_title;
00075       memcpy(&length_title, (inbuffer + offset), sizeof(uint32_t));
00076       offset += 4;
00077       for(unsigned int k= offset; k< offset+length_title; ++k){
00078           inbuffer[k-1]=inbuffer[k];
00079       }
00080       inbuffer[offset+length_title-1]=0;
00081       this->title = (char *)(inbuffer + offset-1);
00082       offset += length_title;
00083       uint32_t length_command;
00084       memcpy(&length_command, (inbuffer + offset), sizeof(uint32_t));
00085       offset += 4;
00086       for(unsigned int k= offset; k< offset+length_command; ++k){
00087           inbuffer[k-1]=inbuffer[k];
00088       }
00089       inbuffer[offset+length_command-1]=0;
00090       this->command = (char *)(inbuffer + offset-1);
00091       offset += length_command;
00092       this->command_type =  ((uint8_t) (*(inbuffer + offset)));
00093       offset += sizeof(this->command_type);
00094      return offset;
00095     }
00096 
00097     const char * getType(){ return "visualization_msgs/MenuEntry"; };
00098     const char * getMD5(){ return "b90ec63024573de83b57aa93eb39be2d"; };
00099 
00100   };
00101 
00102 }
00103 #endif