Go to the documentation of this file.00001 #ifndef ros_rosserial_msgs_TopicInfo_h
00002 #define ros_rosserial_msgs_TopicInfo_h
00003
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "../ros/msg.h"
00008
00009 namespace rosserial_msgs
00010 {
00011
00012 class TopicInfo : public ros::Msg
00013 {
00014 public:
00015 unsigned int topic_id;
00016 char * topic_name;
00017 char * message_type;
00018 char * md5_checksum;
00019 enum { ID_PUBLISHER = 0 };
00020 enum { ID_SUBSCRIBER = 1 };
00021 enum { ID_SERVICE_SERVER = 2 };
00022 enum { ID_SERVICE_CLIENT = 3 };
00023 enum { ID_PARAMETER_REQUEST = 4 };
00024 enum { ID_LOG = 5 };
00025 enum { ID_TIME = 10 };
00026
00027 virtual int serialize(unsigned char *outbuffer)
00028 {
00029 int offset = 0;
00030 union {
00031 unsigned int real;
00032 unsigned int base;
00033 } u_topic_id;
00034 u_topic_id.real = this->topic_id;
00035 *(outbuffer + offset + 0) = (u_topic_id.base >> (8 * 0)) & 0xFF;
00036 *(outbuffer + offset + 1) = (u_topic_id.base >> (8 * 1)) & 0xFF;
00037 offset += sizeof(this->topic_id);
00038 long * length_topic_name = (long *)(outbuffer + offset);
00039 *length_topic_name = strlen( (const char*) this->topic_name);
00040 offset += 4;
00041 memcpy(outbuffer + offset, this->topic_name, *length_topic_name);
00042 offset += *length_topic_name;
00043 long * length_message_type = (long *)(outbuffer + offset);
00044 *length_message_type = strlen( (const char*) this->message_type);
00045 offset += 4;
00046 memcpy(outbuffer + offset, this->message_type, *length_message_type);
00047 offset += *length_message_type;
00048 long * length_md5_checksum = (long *)(outbuffer + offset);
00049 *length_md5_checksum = strlen( (const char*) this->md5_checksum);
00050 offset += 4;
00051 memcpy(outbuffer + offset, this->md5_checksum, *length_md5_checksum);
00052 offset += *length_md5_checksum;
00053 return offset;
00054 }
00055
00056 virtual int deserialize(unsigned char *inbuffer)
00057 {
00058 int offset = 0;
00059 union {
00060 unsigned int real;
00061 unsigned int base;
00062 } u_topic_id;
00063 u_topic_id.base = 0;
00064 u_topic_id.base |= ((typeof(u_topic_id.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00065 u_topic_id.base |= ((typeof(u_topic_id.base)) (*(inbuffer + offset + 1))) << (8 * 1);
00066 this->topic_id = u_topic_id.real;
00067 offset += sizeof(this->topic_id);
00068 uint32_t length_topic_name = *(uint32_t *)(inbuffer + offset);
00069 offset += 4;
00070 for(unsigned int k= offset; k< offset+length_topic_name; ++k){
00071 inbuffer[k-1]=inbuffer[k];
00072 }
00073 inbuffer[offset+length_topic_name-1]=0;
00074 this->topic_name = (char *)(inbuffer + offset-1);
00075 offset += length_topic_name;
00076 uint32_t length_message_type = *(uint32_t *)(inbuffer + offset);
00077 offset += 4;
00078 for(unsigned int k= offset; k< offset+length_message_type; ++k){
00079 inbuffer[k-1]=inbuffer[k];
00080 }
00081 inbuffer[offset+length_message_type-1]=0;
00082 this->message_type = (char *)(inbuffer + offset-1);
00083 offset += length_message_type;
00084 uint32_t length_md5_checksum = *(uint32_t *)(inbuffer + offset);
00085 offset += 4;
00086 for(unsigned int k= offset; k< offset+length_md5_checksum; ++k){
00087 inbuffer[k-1]=inbuffer[k];
00088 }
00089 inbuffer[offset+length_md5_checksum-1]=0;
00090 this->md5_checksum = (char *)(inbuffer + offset-1);
00091 offset += length_md5_checksum;
00092 return offset;
00093 }
00094
00095 const char * getType(){ return "rosserial_msgs/TopicInfo"; };
00096
00097 };
00098
00099 }
00100 #endif