Irfan Tito Kurniawan / ros_lib
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RouteSegment.h Source File

RouteSegment.h

00001 #ifndef _ROS_geographic_msgs_RouteSegment_h
00002 #define _ROS_geographic_msgs_RouteSegment_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "uuid_msgs/UniqueID.h"
00009 #include "geographic_msgs/KeyValue.h"
00010 
00011 namespace geographic_msgs
00012 {
00013 
00014   class RouteSegment : public ros::Msg
00015   {
00016     public:
00017       typedef uuid_msgs::UniqueID _id_type;
00018       _id_type id;
00019       typedef uuid_msgs::UniqueID _start_type;
00020       _start_type start;
00021       typedef uuid_msgs::UniqueID _end_type;
00022       _end_type end;
00023       uint32_t props_length;
00024       typedef geographic_msgs::KeyValue _props_type;
00025       _props_type st_props;
00026       _props_type * props;
00027 
00028     RouteSegment():
00029       id(),
00030       start(),
00031       end(),
00032       props_length(0), props(NULL)
00033     {
00034     }
00035 
00036     virtual int serialize(unsigned char *outbuffer) const
00037     {
00038       int offset = 0;
00039       offset += this->id.serialize(outbuffer + offset);
00040       offset += this->start.serialize(outbuffer + offset);
00041       offset += this->end.serialize(outbuffer + offset);
00042       *(outbuffer + offset + 0) = (this->props_length >> (8 * 0)) & 0xFF;
00043       *(outbuffer + offset + 1) = (this->props_length >> (8 * 1)) & 0xFF;
00044       *(outbuffer + offset + 2) = (this->props_length >> (8 * 2)) & 0xFF;
00045       *(outbuffer + offset + 3) = (this->props_length >> (8 * 3)) & 0xFF;
00046       offset += sizeof(this->props_length);
00047       for( uint32_t i = 0; i < props_length; i++){
00048       offset += this->props[i].serialize(outbuffer + offset);
00049       }
00050       return offset;
00051     }
00052 
00053     virtual int deserialize(unsigned char *inbuffer)
00054     {
00055       int offset = 0;
00056       offset += this->id.deserialize(inbuffer + offset);
00057       offset += this->start.deserialize(inbuffer + offset);
00058       offset += this->end.deserialize(inbuffer + offset);
00059       uint32_t props_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00060       props_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00061       props_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00062       props_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00063       offset += sizeof(this->props_length);
00064       if(props_lengthT > props_length)
00065         this->props = (geographic_msgs::KeyValue*)realloc(this->props, props_lengthT * sizeof(geographic_msgs::KeyValue));
00066       props_length = props_lengthT;
00067       for( uint32_t i = 0; i < props_length; i++){
00068       offset += this->st_props.deserialize(inbuffer + offset);
00069         memcpy( &(this->props[i]), &(this->st_props), sizeof(geographic_msgs::KeyValue));
00070       }
00071      return offset;
00072     }
00073 
00074     const char * getType(){ return "geographic_msgs/RouteSegment"; };
00075     const char * getMD5(){ return "8583d1e2ddf1891c3934a5d2ed9a799c"; };
00076 
00077   };
00078 
00079 }
00080 #endif