Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / topic_tools / MuxSelect.h @ c1426757

History | View | Annotate | Download (2.32 KB)

1
#ifndef _ROS_SERVICE_MuxSelect_h
2
#define _ROS_SERVICE_MuxSelect_h
3
#include <stdint.h>
4
#include <string.h>
5
#include <stdlib.h>
6
#include "ros/msg.h"
7

    
8
namespace topic_tools
9
{
10

    
11
static const char MUXSELECT[] = "topic_tools/MuxSelect";
12

    
13
  class MuxSelectRequest : public ros::Msg
14
  {
15
    public:
16
      char * topic;
17

    
18
    virtual int serialize(unsigned char *outbuffer) const
19
    {
20
      int offset = 0;
21
      uint32_t * length_topic = (uint32_t *)(outbuffer + offset);
22
      *length_topic = strlen( (const char*) this->topic);
23
      offset += 4;
24
      memcpy(outbuffer + offset, this->topic, *length_topic);
25
      offset += *length_topic;
26
      return offset;
27
    }
28

    
29
    virtual int deserialize(unsigned char *inbuffer)
30
    {
31
      int offset = 0;
32
      uint32_t length_topic = *(uint32_t *)(inbuffer + offset);
33
      offset += 4;
34
      for(unsigned int k= offset; k< offset+length_topic; ++k){
35
          inbuffer[k-1]=inbuffer[k];
36
      }
37
      inbuffer[offset+length_topic-1]=0;
38
      this->topic = (char *)(inbuffer + offset-1);
39
      offset += length_topic;
40
     return offset;
41
    }
42

    
43
    const char * getType(){ return MUXSELECT; };
44
    const char * getMD5(){ return "d8f94bae31b356b24d0427f80426d0c3"; };
45

    
46
  };
47

    
48
  class MuxSelectResponse : public ros::Msg
49
  {
50
    public:
51
      char * prev_topic;
52

    
53
    virtual int serialize(unsigned char *outbuffer) const
54
    {
55
      int offset = 0;
56
      uint32_t * length_prev_topic = (uint32_t *)(outbuffer + offset);
57
      *length_prev_topic = strlen( (const char*) this->prev_topic);
58
      offset += 4;
59
      memcpy(outbuffer + offset, this->prev_topic, *length_prev_topic);
60
      offset += *length_prev_topic;
61
      return offset;
62
    }
63

    
64
    virtual int deserialize(unsigned char *inbuffer)
65
    {
66
      int offset = 0;
67
      uint32_t length_prev_topic = *(uint32_t *)(inbuffer + offset);
68
      offset += 4;
69
      for(unsigned int k= offset; k< offset+length_prev_topic; ++k){
70
          inbuffer[k-1]=inbuffer[k];
71
      }
72
      inbuffer[offset+length_prev_topic-1]=0;
73
      this->prev_topic = (char *)(inbuffer + offset-1);
74
      offset += length_prev_topic;
75
     return offset;
76
    }
77

    
78
    const char * getType(){ return MUXSELECT; };
79
    const char * getMD5(){ return "3db0a473debdbafea387c9e49358c320"; };
80

    
81
  };
82

    
83
  class MuxSelect {
84
    public:
85
    typedef MuxSelectRequest Request;
86
    typedef MuxSelectResponse Response;
87
  };
88

    
89
}
90
#endif