TopicInfo.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef _ROS_rosserial_msgs_TopicInfo_h
19 #define _ROS_rosserial_msgs_TopicInfo_h
20 
21 #include <stdint.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include "ros/msg.h"
25 
26 namespace rosserial_msgs
27 {
28 
29  class TopicInfo : public ros::Msg
30  {
31  public:
32  uint16_t topic_id;
33  const char* topic_name;
34  const char* message_type;
35  const char* md5sum;
36  int32_t buffer_size;
37  enum { ID_PUBLISHER = 0 };
38  enum { ID_SUBSCRIBER = 1 };
39  enum { ID_SERVICE_SERVER = 2 };
40  enum { ID_SERVICE_CLIENT = 4 };
41  enum { ID_PARAMETER_REQUEST = 6 };
42  enum { ID_LOG = 7 };
43  enum { ID_TIME = 10 };
44  enum { ID_TX_STOP = 11 };
45 
47  topic_id(0),
48  topic_name(""),
49  message_type(""),
50  md5sum(""),
51  buffer_size(0)
52  {
53  }
54 
55  virtual int serialize(unsigned char *outbuffer) const
56  {
57  int offset = 0;
58  *(outbuffer + offset + 0) = (this->topic_id >> (8 * 0)) & 0xFF;
59  *(outbuffer + offset + 1) = (this->topic_id >> (8 * 1)) & 0xFF;
60  offset += sizeof(this->topic_id);
61  uint32_t length_topic_name = strlen(this->topic_name);
62  memcpy(outbuffer + offset, &length_topic_name, sizeof(uint32_t));
63  offset += 4;
64  memcpy(outbuffer + offset, this->topic_name, length_topic_name);
65  offset += length_topic_name;
66  uint32_t length_message_type = strlen(this->message_type);
67  memcpy(outbuffer + offset, &length_message_type, sizeof(uint32_t));
68  offset += 4;
69  memcpy(outbuffer + offset, this->message_type, length_message_type);
70  offset += length_message_type;
71  uint32_t length_md5sum = strlen(this->md5sum);
72  memcpy(outbuffer + offset, &length_md5sum, sizeof(uint32_t));
73  offset += 4;
74  memcpy(outbuffer + offset, this->md5sum, length_md5sum);
75  offset += length_md5sum;
76  union {
77  int32_t real;
78  uint32_t base;
79  } u_buffer_size;
80  u_buffer_size.real = this->buffer_size;
81  *(outbuffer + offset + 0) = (u_buffer_size.base >> (8 * 0)) & 0xFF;
82  *(outbuffer + offset + 1) = (u_buffer_size.base >> (8 * 1)) & 0xFF;
83  *(outbuffer + offset + 2) = (u_buffer_size.base >> (8 * 2)) & 0xFF;
84  *(outbuffer + offset + 3) = (u_buffer_size.base >> (8 * 3)) & 0xFF;
85  offset += sizeof(this->buffer_size);
86  return offset;
87  }
88 
89  virtual int deserialize(unsigned char *inbuffer)
90  {
91  int offset = 0;
92  this->topic_id = ((uint16_t) (*(inbuffer + offset)));
93  this->topic_id |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
94  offset += sizeof(this->topic_id);
95  uint32_t length_topic_name;
96  memcpy(&length_topic_name, (inbuffer + offset), sizeof(uint32_t));
97  offset += 4;
98  for(unsigned int k= offset; k< offset+length_topic_name; ++k){
99  inbuffer[k-1]=inbuffer[k];
100  }
101  inbuffer[offset+length_topic_name-1]=0;
102  this->topic_name = (char *)(inbuffer + offset-1);
103  offset += length_topic_name;
104  uint32_t length_message_type;
105  memcpy(&length_message_type, (inbuffer + offset), sizeof(uint32_t));
106  offset += 4;
107  for(unsigned int k= offset; k< offset+length_message_type; ++k){
108  inbuffer[k-1]=inbuffer[k];
109  }
110  inbuffer[offset+length_message_type-1]=0;
111  this->message_type = (char *)(inbuffer + offset-1);
112  offset += length_message_type;
113  uint32_t length_md5sum;
114  memcpy(&length_md5sum, (inbuffer + offset), sizeof(uint32_t));
115  offset += 4;
116  for(unsigned int k= offset; k< offset+length_md5sum; ++k){
117  inbuffer[k-1]=inbuffer[k];
118  }
119  inbuffer[offset+length_md5sum-1]=0;
120  this->md5sum = (char *)(inbuffer + offset-1);
121  offset += length_md5sum;
122  union {
123  int32_t real;
124  uint32_t base;
125  } u_buffer_size;
126  u_buffer_size.base = 0;
127  u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
128  u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
129  u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
130  u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
131  this->buffer_size = u_buffer_size.real;
132  offset += sizeof(this->buffer_size);
133  return offset;
134  }
135 
136  const char * getType(){ return "rosserial_msgs/TopicInfo"; };
137  const char * getMD5(){ return "0ad51f88fc44892f8c10684077646005"; };
138 
139  };
140 
141 }
142 #endif
const char * topic_name
Definition: TopicInfo.h:33
virtual int serialize(unsigned char *outbuffer) const
Definition: TopicInfo.h:55
const char * getMD5()
Definition: TopicInfo.h:137
const char * getType()
Definition: TopicInfo.h:136
virtual int deserialize(unsigned char *inbuffer)
Definition: TopicInfo.h:89
const char * message_type
Definition: TopicInfo.h:34
Definition: msg.h:26


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Tue Oct 20 2020 03:35:57