kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
TopicInfo.h
Go to the documentation of this file.
1 #ifndef _ROS_rosserial_msgs_TopicInfo_h
2 #define _ROS_rosserial_msgs_TopicInfo_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 
9 namespace rosserial_msgs
10 {
11 
12  class TopicInfo : public ros::Msg
13  {
14  public:
15  uint16_t topic_id;
16  const char* topic_name;
17  const char* message_type;
18  const char* md5sum;
19  int32_t buffer_size;
20  enum { ID_PUBLISHER = 0 };
21  enum { ID_SUBSCRIBER = 1 };
22  enum { ID_SERVICE_SERVER = 2 };
23  enum { ID_SERVICE_CLIENT = 4 };
24  enum { ID_PARAMETER_REQUEST = 6 };
25  enum { ID_LOG = 7 };
26  enum { ID_TIME = 10 };
27  enum { ID_TX_STOP = 11 };
28 
30  topic_id(0),
31  topic_name(""),
32  message_type(""),
33  md5sum(""),
34  buffer_size(0)
35  {
36  }
37 
38  virtual int serialize(unsigned char *outbuffer) const
39  {
40  int offset = 0;
41  *(outbuffer + offset + 0) = (this->topic_id >> (8 * 0)) & 0xFF;
42  *(outbuffer + offset + 1) = (this->topic_id >> (8 * 1)) & 0xFF;
43  offset += sizeof(this->topic_id);
44  uint32_t length_topic_name = strlen(this->topic_name);
45  memcpy(outbuffer + offset, &length_topic_name, sizeof(uint32_t));
46  offset += 4;
47  memcpy(outbuffer + offset, this->topic_name, length_topic_name);
48  offset += length_topic_name;
49  uint32_t length_message_type = strlen(this->message_type);
50  memcpy(outbuffer + offset, &length_message_type, sizeof(uint32_t));
51  offset += 4;
52  memcpy(outbuffer + offset, this->message_type, length_message_type);
53  offset += length_message_type;
54  uint32_t length_md5sum = strlen(this->md5sum);
55  memcpy(outbuffer + offset, &length_md5sum, sizeof(uint32_t));
56  offset += 4;
57  memcpy(outbuffer + offset, this->md5sum, length_md5sum);
58  offset += length_md5sum;
59  union {
60  int32_t real;
61  uint32_t base;
62  } u_buffer_size;
63  u_buffer_size.real = this->buffer_size;
64  *(outbuffer + offset + 0) = (u_buffer_size.base >> (8 * 0)) & 0xFF;
65  *(outbuffer + offset + 1) = (u_buffer_size.base >> (8 * 1)) & 0xFF;
66  *(outbuffer + offset + 2) = (u_buffer_size.base >> (8 * 2)) & 0xFF;
67  *(outbuffer + offset + 3) = (u_buffer_size.base >> (8 * 3)) & 0xFF;
68  offset += sizeof(this->buffer_size);
69  return offset;
70  }
71 
72  virtual int deserialize(unsigned char *inbuffer)
73  {
74  int offset = 0;
75  this->topic_id = ((uint16_t) (*(inbuffer + offset)));
76  this->topic_id |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
77  offset += sizeof(this->topic_id);
78  uint32_t length_topic_name;
79  memcpy(&length_topic_name, (inbuffer + offset), sizeof(uint32_t));
80  offset += 4;
81  for(unsigned int k= offset; k< offset+length_topic_name; ++k){
82  inbuffer[k-1]=inbuffer[k];
83  }
84  inbuffer[offset+length_topic_name-1]=0;
85  this->topic_name = (char *)(inbuffer + offset-1);
86  offset += length_topic_name;
87  uint32_t length_message_type;
88  memcpy(&length_message_type, (inbuffer + offset), sizeof(uint32_t));
89  offset += 4;
90  for(unsigned int k= offset; k< offset+length_message_type; ++k){
91  inbuffer[k-1]=inbuffer[k];
92  }
93  inbuffer[offset+length_message_type-1]=0;
94  this->message_type = (char *)(inbuffer + offset-1);
95  offset += length_message_type;
96  uint32_t length_md5sum;
97  memcpy(&length_md5sum, (inbuffer + offset), sizeof(uint32_t));
98  offset += 4;
99  for(unsigned int k= offset; k< offset+length_md5sum; ++k){
100  inbuffer[k-1]=inbuffer[k];
101  }
102  inbuffer[offset+length_md5sum-1]=0;
103  this->md5sum = (char *)(inbuffer + offset-1);
104  offset += length_md5sum;
105  union {
106  int32_t real;
107  uint32_t base;
108  } u_buffer_size;
109  u_buffer_size.base = 0;
110  u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
111  u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
112  u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
113  u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
114  this->buffer_size = u_buffer_size.real;
115  offset += sizeof(this->buffer_size);
116  return offset;
117  }
118 
119  const char * getType(){ return "rosserial_msgs/TopicInfo"; };
120  const char * getMD5(){ return "0ad51f88fc44892f8c10684077646005"; };
121 
122  };
123 
124 }
125 #endif
Definition: TopicInfo.h:12
const char * topic_name
Definition: TopicInfo.h:16
virtual int serialize(unsigned char *outbuffer) const
Definition: TopicInfo.h:38
Definition: TopicInfo.h:25
const char * getMD5()
Definition: TopicInfo.h:120
const char * md5sum
Definition: TopicInfo.h:18
const char * getType()
Definition: TopicInfo.h:119
Definition: TopicInfo.h:20
int32_t buffer_size
Definition: TopicInfo.h:19
virtual int deserialize(unsigned char *inbuffer)
Definition: TopicInfo.h:72
Definition: TopicInfo.h:27
const char * message_type
Definition: TopicInfo.h:17
TopicInfo()
Definition: TopicInfo.h:29
Definition: msg.h:43
Definition: TopicInfo.h:26
uint16_t topic_id
Definition: TopicInfo.h:15