Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NodeletList.h Source File

NodeletList.h

00001 #ifndef _ROS_SERVICE_NodeletList_h
00002 #define _ROS_SERVICE_NodeletList_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 
00008 namespace nodelet
00009 {
00010 
00011 static const char NODELETLIST[] = "nodelet/NodeletList";
00012 
00013   class NodeletListRequest : public ros::Msg
00014   {
00015     public:
00016 
00017     NodeletListRequest()
00018     {
00019     }
00020 
00021     virtual int serialize(unsigned char *outbuffer) const
00022     {
00023       int offset = 0;
00024       return offset;
00025     }
00026 
00027     virtual int deserialize(unsigned char *inbuffer)
00028     {
00029       int offset = 0;
00030      return offset;
00031     }
00032 
00033     const char * getType(){ return NODELETLIST; };
00034     const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; };
00035 
00036   };
00037 
00038   class NodeletListResponse : public ros::Msg
00039   {
00040     public:
00041       uint32_t nodelets_length;
00042       typedef char* _nodelets_type;
00043       _nodelets_type st_nodelets;
00044       _nodelets_type * nodelets;
00045 
00046     NodeletListResponse():
00047       nodelets_length(0), nodelets(NULL)
00048     {
00049     }
00050 
00051     virtual int serialize(unsigned char *outbuffer) const
00052     {
00053       int offset = 0;
00054       *(outbuffer + offset + 0) = (this->nodelets_length >> (8 * 0)) & 0xFF;
00055       *(outbuffer + offset + 1) = (this->nodelets_length >> (8 * 1)) & 0xFF;
00056       *(outbuffer + offset + 2) = (this->nodelets_length >> (8 * 2)) & 0xFF;
00057       *(outbuffer + offset + 3) = (this->nodelets_length >> (8 * 3)) & 0xFF;
00058       offset += sizeof(this->nodelets_length);
00059       for( uint32_t i = 0; i < nodelets_length; i++){
00060       uint32_t length_nodeletsi = strlen(this->nodelets[i]);
00061       varToArr(outbuffer + offset, length_nodeletsi);
00062       offset += 4;
00063       memcpy(outbuffer + offset, this->nodelets[i], length_nodeletsi);
00064       offset += length_nodeletsi;
00065       }
00066       return offset;
00067     }
00068 
00069     virtual int deserialize(unsigned char *inbuffer)
00070     {
00071       int offset = 0;
00072       uint32_t nodelets_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00073       nodelets_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00074       nodelets_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00075       nodelets_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00076       offset += sizeof(this->nodelets_length);
00077       if(nodelets_lengthT > nodelets_length)
00078         this->nodelets = (char**)realloc(this->nodelets, nodelets_lengthT * sizeof(char*));
00079       nodelets_length = nodelets_lengthT;
00080       for( uint32_t i = 0; i < nodelets_length; i++){
00081       uint32_t length_st_nodelets;
00082       arrToVar(length_st_nodelets, (inbuffer + offset));
00083       offset += 4;
00084       for(unsigned int k= offset; k< offset+length_st_nodelets; ++k){
00085           inbuffer[k-1]=inbuffer[k];
00086       }
00087       inbuffer[offset+length_st_nodelets-1]=0;
00088       this->st_nodelets = (char *)(inbuffer + offset-1);
00089       offset += length_st_nodelets;
00090         memcpy( &(this->nodelets[i]), &(this->st_nodelets), sizeof(char*));
00091       }
00092      return offset;
00093     }
00094 
00095     const char * getType(){ return NODELETLIST; };
00096     const char * getMD5(){ return "99c7b10e794f5600b8030e697e946ca7"; };
00097 
00098   };
00099 
00100   class NodeletList {
00101     public:
00102     typedef NodeletListRequest Request;
00103     typedef NodeletListResponse Response;
00104   };
00105 
00106 }
00107 #endif