Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / roscpp / Logger.h @ c1426757

History | View | Annotate | Download (1.66 KB)

1
#ifndef _ROS_roscpp_Logger_h
2
#define _ROS_roscpp_Logger_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8

    
9
namespace roscpp
10
{
11

    
12
  class Logger : public ros::Msg
13
  {
14
    public:
15
      char * name;
16
      char * level;
17

    
18
    virtual int serialize(unsigned char *outbuffer) const
19
    {
20
      int offset = 0;
21
      uint32_t * length_name = (uint32_t *)(outbuffer + offset);
22
      *length_name = strlen( (const char*) this->name);
23
      offset += 4;
24
      memcpy(outbuffer + offset, this->name, *length_name);
25
      offset += *length_name;
26
      uint32_t * length_level = (uint32_t *)(outbuffer + offset);
27
      *length_level = strlen( (const char*) this->level);
28
      offset += 4;
29
      memcpy(outbuffer + offset, this->level, *length_level);
30
      offset += *length_level;
31
      return offset;
32
    }
33

    
34
    virtual int deserialize(unsigned char *inbuffer)
35
    {
36
      int offset = 0;
37
      uint32_t length_name = *(uint32_t *)(inbuffer + offset);
38
      offset += 4;
39
      for(unsigned int k= offset; k< offset+length_name; ++k){
40
          inbuffer[k-1]=inbuffer[k];
41
      }
42
      inbuffer[offset+length_name-1]=0;
43
      this->name = (char *)(inbuffer + offset-1);
44
      offset += length_name;
45
      uint32_t length_level = *(uint32_t *)(inbuffer + offset);
46
      offset += 4;
47
      for(unsigned int k= offset; k< offset+length_level; ++k){
48
          inbuffer[k-1]=inbuffer[k];
49
      }
50
      inbuffer[offset+length_level-1]=0;
51
      this->level = (char *)(inbuffer + offset-1);
52
      offset += length_level;
53
     return offset;
54
    }
55

    
56
    const char * getType(){ return "roscpp/Logger"; };
57
    const char * getMD5(){ return "a6069a2ff40db7bd32143dd66e1f408e"; };
58

    
59
  };
60

    
61
}
62
#endif