kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
Log.h
Go to the documentation of this file.
1 #ifndef _ROS_rosgraph_msgs_Log_h
2 #define _ROS_rosgraph_msgs_Log_h
3 
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "ros/msg.h"
8 #include "std_msgs/Header.h"
9 
10 namespace rosgraph_msgs
11 {
12 
13  class Log : public ros::Msg
14  {
15  public:
17  int8_t level;
18  const char* name;
19  const char* msg;
20  const char* file;
21  const char* function;
22  uint32_t line;
23  uint8_t topics_length;
24  char* st_topics;
25  char* * topics;
26  enum { DEBUG = 1 };
27  enum { INFO = 2 };
28  enum { WARN = 4 };
29  enum { ERROR = 8 };
30  enum { FATAL = 16 };
31 
32  Log():
33  header(),
34  level(0),
35  name(""),
36  msg(""),
37  file(""),
38  function(""),
39  line(0),
40  topics_length(0), topics(NULL)
41  {
42  }
43 
44  virtual int serialize(unsigned char *outbuffer) const
45  {
46  int offset = 0;
47  offset += this->header.serialize(outbuffer + offset);
48  union {
49  int8_t real;
50  uint8_t base;
51  } u_level;
52  u_level.real = this->level;
53  *(outbuffer + offset + 0) = (u_level.base >> (8 * 0)) & 0xFF;
54  offset += sizeof(this->level);
55  uint32_t length_name = strlen(this->name);
56  memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
57  offset += 4;
58  memcpy(outbuffer + offset, this->name, length_name);
59  offset += length_name;
60  uint32_t length_msg = strlen(this->msg);
61  memcpy(outbuffer + offset, &length_msg, sizeof(uint32_t));
62  offset += 4;
63  memcpy(outbuffer + offset, this->msg, length_msg);
64  offset += length_msg;
65  uint32_t length_file = strlen(this->file);
66  memcpy(outbuffer + offset, &length_file, sizeof(uint32_t));
67  offset += 4;
68  memcpy(outbuffer + offset, this->file, length_file);
69  offset += length_file;
70  uint32_t length_function = strlen(this->function);
71  memcpy(outbuffer + offset, &length_function, sizeof(uint32_t));
72  offset += 4;
73  memcpy(outbuffer + offset, this->function, length_function);
74  offset += length_function;
75  *(outbuffer + offset + 0) = (this->line >> (8 * 0)) & 0xFF;
76  *(outbuffer + offset + 1) = (this->line >> (8 * 1)) & 0xFF;
77  *(outbuffer + offset + 2) = (this->line >> (8 * 2)) & 0xFF;
78  *(outbuffer + offset + 3) = (this->line >> (8 * 3)) & 0xFF;
79  offset += sizeof(this->line);
80  *(outbuffer + offset++) = topics_length;
81  *(outbuffer + offset++) = 0;
82  *(outbuffer + offset++) = 0;
83  *(outbuffer + offset++) = 0;
84  for( uint8_t i = 0; i < topics_length; i++){
85  uint32_t length_topicsi = strlen(this->topics[i]);
86  memcpy(outbuffer + offset, &length_topicsi, sizeof(uint32_t));
87  offset += 4;
88  memcpy(outbuffer + offset, this->topics[i], length_topicsi);
89  offset += length_topicsi;
90  }
91  return offset;
92  }
93 
94  virtual int deserialize(unsigned char *inbuffer)
95  {
96  int offset = 0;
97  offset += this->header.deserialize(inbuffer + offset);
98  union {
99  int8_t real;
100  uint8_t base;
101  } u_level;
102  u_level.base = 0;
103  u_level.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
104  this->level = u_level.real;
105  offset += sizeof(this->level);
106  uint32_t length_name;
107  memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
108  offset += 4;
109  for(unsigned int k= offset; k< offset+length_name; ++k){
110  inbuffer[k-1]=inbuffer[k];
111  }
112  inbuffer[offset+length_name-1]=0;
113  this->name = (char *)(inbuffer + offset-1);
114  offset += length_name;
115  uint32_t length_msg;
116  memcpy(&length_msg, (inbuffer + offset), sizeof(uint32_t));
117  offset += 4;
118  for(unsigned int k= offset; k< offset+length_msg; ++k){
119  inbuffer[k-1]=inbuffer[k];
120  }
121  inbuffer[offset+length_msg-1]=0;
122  this->msg = (char *)(inbuffer + offset-1);
123  offset += length_msg;
124  uint32_t length_file;
125  memcpy(&length_file, (inbuffer + offset), sizeof(uint32_t));
126  offset += 4;
127  for(unsigned int k= offset; k< offset+length_file; ++k){
128  inbuffer[k-1]=inbuffer[k];
129  }
130  inbuffer[offset+length_file-1]=0;
131  this->file = (char *)(inbuffer + offset-1);
132  offset += length_file;
133  uint32_t length_function;
134  memcpy(&length_function, (inbuffer + offset), sizeof(uint32_t));
135  offset += 4;
136  for(unsigned int k= offset; k< offset+length_function; ++k){
137  inbuffer[k-1]=inbuffer[k];
138  }
139  inbuffer[offset+length_function-1]=0;
140  this->function = (char *)(inbuffer + offset-1);
141  offset += length_function;
142  this->line = ((uint32_t) (*(inbuffer + offset)));
143  this->line |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
144  this->line |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
145  this->line |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
146  offset += sizeof(this->line);
147  uint8_t topics_lengthT = *(inbuffer + offset++);
148  if(topics_lengthT > topics_length)
149  this->topics = (char**)realloc(this->topics, topics_lengthT * sizeof(char*));
150  offset += 3;
151  topics_length = topics_lengthT;
152  for( uint8_t i = 0; i < topics_length; i++){
153  uint32_t length_st_topics;
154  memcpy(&length_st_topics, (inbuffer + offset), sizeof(uint32_t));
155  offset += 4;
156  for(unsigned int k= offset; k< offset+length_st_topics; ++k){
157  inbuffer[k-1]=inbuffer[k];
158  }
159  inbuffer[offset+length_st_topics-1]=0;
160  this->st_topics = (char *)(inbuffer + offset-1);
161  offset += length_st_topics;
162  memcpy( &(this->topics[i]), &(this->st_topics), sizeof(char*));
163  }
164  return offset;
165  }
166 
167  const char * getType(){ return "rosgraph_msgs/Log"; };
168  const char * getMD5(){ return "acffd30cd6b6de30f120938c17c593fb"; };
169 
170  };
171 
172 }
173 #endif
Definition: Log.h:26
virtual int deserialize(unsigned char *inbuffer)
Definition: Header.h:53
Definition: Log.h:28
virtual int serialize(unsigned char *outbuffer) const
Definition: Header.h:27
Definition: Log.h:27
Definition: Log.h:29
uint8_t topics_length
Definition: Log.h:23
const char * msg
Definition: Log.h:19
const char * getType()
Definition: Log.h:167
int8_t level
Definition: Log.h:17
std_msgs::Header header
Definition: Log.h:16
virtual int deserialize(unsigned char *inbuffer)
Definition: Log.h:94
Definition: Header.h:13
Definition: Log.h:30
const char * function
Definition: Log.h:21
Definition: Log.h:13
char * st_topics
Definition: Log.h:24
const char * name
Definition: Log.h:18
uint32_t line
Definition: Log.h:22
char ** topics
Definition: Log.h:25
virtual int serialize(unsigned char *outbuffer) const
Definition: Log.h:44
Log()
Definition: Log.h:32
Definition: msg.h:43
const char * file
Definition: Log.h:20
const char * getMD5()
Definition: Log.h:168