TopicInfo.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016  
00017 
00018 #ifndef _ROS_rosserial_msgs_TopicInfo_h
00019 #define _ROS_rosserial_msgs_TopicInfo_h
00020 
00021 #include <stdint.h>
00022 #include <string.h>
00023 #include <stdlib.h>
00024 #include "ros/msg.h"
00025 
00026 namespace rosserial_msgs
00027 {
00028 
00029   class TopicInfo : public ros::Msg
00030   {
00031     public:
00032       uint16_t topic_id;
00033       const char* topic_name;
00034       const char* message_type;
00035       const char* md5sum;
00036       int32_t buffer_size;
00037       enum { ID_PUBLISHER = 0 };
00038       enum { ID_SUBSCRIBER = 1 };
00039       enum { ID_SERVICE_SERVER = 2 };
00040       enum { ID_SERVICE_CLIENT = 4 };
00041       enum { ID_PARAMETER_REQUEST = 6 };
00042       enum { ID_LOG = 7 };
00043       enum { ID_TIME = 10 };
00044       enum { ID_TX_STOP = 11 };
00045 
00046     TopicInfo():
00047       topic_id(0),
00048       topic_name(""),
00049       message_type(""),
00050       md5sum(""),
00051       buffer_size(0)
00052     {
00053     }
00054 
00055     virtual int serialize(unsigned char *outbuffer) const
00056     {
00057       int offset = 0;
00058       *(outbuffer + offset + 0) = (this->topic_id >> (8 * 0)) & 0xFF;
00059       *(outbuffer + offset + 1) = (this->topic_id >> (8 * 1)) & 0xFF;
00060       offset += sizeof(this->topic_id);
00061       uint32_t length_topic_name = strlen(this->topic_name);
00062       memcpy(outbuffer + offset, &length_topic_name, sizeof(uint32_t));
00063       offset += 4;
00064       memcpy(outbuffer + offset, this->topic_name, length_topic_name);
00065       offset += length_topic_name;
00066       uint32_t length_message_type = strlen(this->message_type);
00067       memcpy(outbuffer + offset, &length_message_type, sizeof(uint32_t));
00068       offset += 4;
00069       memcpy(outbuffer + offset, this->message_type, length_message_type);
00070       offset += length_message_type;
00071       uint32_t length_md5sum = strlen(this->md5sum);
00072       memcpy(outbuffer + offset, &length_md5sum, sizeof(uint32_t));
00073       offset += 4;
00074       memcpy(outbuffer + offset, this->md5sum, length_md5sum);
00075       offset += length_md5sum;
00076       union {
00077         int32_t real;
00078         uint32_t base;
00079       } u_buffer_size;
00080       u_buffer_size.real = this->buffer_size;
00081       *(outbuffer + offset + 0) = (u_buffer_size.base >> (8 * 0)) & 0xFF;
00082       *(outbuffer + offset + 1) = (u_buffer_size.base >> (8 * 1)) & 0xFF;
00083       *(outbuffer + offset + 2) = (u_buffer_size.base >> (8 * 2)) & 0xFF;
00084       *(outbuffer + offset + 3) = (u_buffer_size.base >> (8 * 3)) & 0xFF;
00085       offset += sizeof(this->buffer_size);
00086       return offset;
00087     }
00088 
00089     virtual int deserialize(unsigned char *inbuffer)
00090     {
00091       int offset = 0;
00092       this->topic_id =  ((uint16_t) (*(inbuffer + offset)));
00093       this->topic_id |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00094       offset += sizeof(this->topic_id);
00095       uint32_t length_topic_name;
00096       memcpy(&length_topic_name, (inbuffer + offset), sizeof(uint32_t));
00097       offset += 4;
00098       for(unsigned int k= offset; k< offset+length_topic_name; ++k){
00099           inbuffer[k-1]=inbuffer[k];
00100       }
00101       inbuffer[offset+length_topic_name-1]=0;
00102       this->topic_name = (char *)(inbuffer + offset-1);
00103       offset += length_topic_name;
00104       uint32_t length_message_type;
00105       memcpy(&length_message_type, (inbuffer + offset), sizeof(uint32_t));
00106       offset += 4;
00107       for(unsigned int k= offset; k< offset+length_message_type; ++k){
00108           inbuffer[k-1]=inbuffer[k];
00109       }
00110       inbuffer[offset+length_message_type-1]=0;
00111       this->message_type = (char *)(inbuffer + offset-1);
00112       offset += length_message_type;
00113       uint32_t length_md5sum;
00114       memcpy(&length_md5sum, (inbuffer + offset), sizeof(uint32_t));
00115       offset += 4;
00116       for(unsigned int k= offset; k< offset+length_md5sum; ++k){
00117           inbuffer[k-1]=inbuffer[k];
00118       }
00119       inbuffer[offset+length_md5sum-1]=0;
00120       this->md5sum = (char *)(inbuffer + offset-1);
00121       offset += length_md5sum;
00122       union {
00123         int32_t real;
00124         uint32_t base;
00125       } u_buffer_size;
00126       u_buffer_size.base = 0;
00127       u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00128       u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00129       u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00130       u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00131       this->buffer_size = u_buffer_size.real;
00132       offset += sizeof(this->buffer_size);
00133      return offset;
00134     }
00135 
00136     const char * getType(){ return "rosserial_msgs/TopicInfo"; };
00137     const char * getMD5(){ return "0ad51f88fc44892f8c10684077646005"; };
00138 
00139   };
00140 
00141 }
00142 #endif


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Thu Jun 6 2019 20:43:57