RequestParam.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_SERVICE_RequestParam_h
19 #define _ROS_SERVICE_RequestParam_h
20 #include <stdint.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include "ros/msg.h"
24 
25 namespace rosserial_msgs
26 {
27 
28 static const char REQUESTPARAM[] = "rosserial_msgs/RequestParam";
29 
31  {
32  public:
33  const char* name;
34 
36  name("")
37  {
38  }
39 
40  virtual int serialize(unsigned char *outbuffer) const
41  {
42  int offset = 0;
43  uint32_t length_name = strlen(this->name);
44  memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
45  offset += 4;
46  memcpy(outbuffer + offset, this->name, length_name);
47  offset += length_name;
48  return offset;
49  }
50 
51  virtual int deserialize(unsigned char *inbuffer)
52  {
53  int offset = 0;
54  uint32_t length_name;
55  memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
56  offset += 4;
57  for(unsigned int k= offset; k< offset+length_name; ++k){
58  inbuffer[k-1]=inbuffer[k];
59  }
60  inbuffer[offset+length_name-1]=0;
61  this->name = (char *)(inbuffer + offset-1);
62  offset += length_name;
63  return offset;
64  }
65 
66  const char * getType(){ return REQUESTPARAM; };
67  const char * getMD5(){ return "c1f3d28f1b044c871e6eff2e9fc3c667"; };
68 
69  };
70 
72  {
73  public:
74  uint8_t ints_length;
75  int32_t st_ints;
76  int32_t * ints;
77  uint8_t floats_length;
78  float st_floats;
79  float * floats;
80  uint8_t strings_length;
81  char* st_strings;
82  char* * strings;
83 
85  ints_length(0), ints(NULL),
86  floats_length(0), floats(NULL),
87  strings_length(0), strings(NULL)
88  {
89  }
90 
91  virtual int serialize(unsigned char *outbuffer) const
92  {
93  int offset = 0;
94  *(outbuffer + offset++) = ints_length;
95  *(outbuffer + offset++) = 0;
96  *(outbuffer + offset++) = 0;
97  *(outbuffer + offset++) = 0;
98  for( uint8_t i = 0; i < ints_length; i++){
99  union {
100  int32_t real;
101  uint32_t base;
102  } u_intsi;
103  u_intsi.real = this->ints[i];
104  *(outbuffer + offset + 0) = (u_intsi.base >> (8 * 0)) & 0xFF;
105  *(outbuffer + offset + 1) = (u_intsi.base >> (8 * 1)) & 0xFF;
106  *(outbuffer + offset + 2) = (u_intsi.base >> (8 * 2)) & 0xFF;
107  *(outbuffer + offset + 3) = (u_intsi.base >> (8 * 3)) & 0xFF;
108  offset += sizeof(this->ints[i]);
109  }
110  *(outbuffer + offset++) = floats_length;
111  *(outbuffer + offset++) = 0;
112  *(outbuffer + offset++) = 0;
113  *(outbuffer + offset++) = 0;
114  for( uint8_t i = 0; i < floats_length; i++){
115  union {
116  float real;
117  uint32_t base;
118  } u_floatsi;
119  u_floatsi.real = this->floats[i];
120  *(outbuffer + offset + 0) = (u_floatsi.base >> (8 * 0)) & 0xFF;
121  *(outbuffer + offset + 1) = (u_floatsi.base >> (8 * 1)) & 0xFF;
122  *(outbuffer + offset + 2) = (u_floatsi.base >> (8 * 2)) & 0xFF;
123  *(outbuffer + offset + 3) = (u_floatsi.base >> (8 * 3)) & 0xFF;
124  offset += sizeof(this->floats[i]);
125  }
126  *(outbuffer + offset++) = strings_length;
127  *(outbuffer + offset++) = 0;
128  *(outbuffer + offset++) = 0;
129  *(outbuffer + offset++) = 0;
130  for( uint8_t i = 0; i < strings_length; i++){
131  uint32_t length_stringsi = strlen(this->strings[i]);
132  memcpy(outbuffer + offset, &length_stringsi, sizeof(uint32_t));
133  offset += 4;
134  memcpy(outbuffer + offset, this->strings[i], length_stringsi);
135  offset += length_stringsi;
136  }
137  return offset;
138  }
139 
140  virtual int deserialize(unsigned char *inbuffer)
141  {
142  int offset = 0;
143  uint8_t ints_lengthT = *(inbuffer + offset++);
144  if(ints_lengthT > ints_length)
145  this->ints = (int32_t*)realloc(this->ints, ints_lengthT * sizeof(int32_t));
146  offset += 3;
147  ints_length = ints_lengthT;
148  for( uint8_t i = 0; i < ints_length; i++){
149  union {
150  int32_t real;
151  uint32_t base;
152  } u_st_ints;
153  u_st_ints.base = 0;
154  u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
155  u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
156  u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
157  u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
158  this->st_ints = u_st_ints.real;
159  offset += sizeof(this->st_ints);
160  memcpy( &(this->ints[i]), &(this->st_ints), sizeof(int32_t));
161  }
162  uint8_t floats_lengthT = *(inbuffer + offset++);
163  if(floats_lengthT > floats_length)
164  this->floats = (float*)realloc(this->floats, floats_lengthT * sizeof(float));
165  offset += 3;
166  floats_length = floats_lengthT;
167  for( uint8_t i = 0; i < floats_length; i++){
168  union {
169  float real;
170  uint32_t base;
171  } u_st_floats;
172  u_st_floats.base = 0;
173  u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
174  u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
175  u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
176  u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
177  this->st_floats = u_st_floats.real;
178  offset += sizeof(this->st_floats);
179  memcpy( &(this->floats[i]), &(this->st_floats), sizeof(float));
180  }
181  uint8_t strings_lengthT = *(inbuffer + offset++);
182  if(strings_lengthT > strings_length)
183  this->strings = (char**)realloc(this->strings, strings_lengthT * sizeof(char*));
184  offset += 3;
185  strings_length = strings_lengthT;
186  for( uint8_t i = 0; i < strings_length; i++){
187  uint32_t length_st_strings;
188  memcpy(&length_st_strings, (inbuffer + offset), sizeof(uint32_t));
189  offset += 4;
190  for(unsigned int k= offset; k< offset+length_st_strings; ++k){
191  inbuffer[k-1]=inbuffer[k];
192  }
193  inbuffer[offset+length_st_strings-1]=0;
194  this->st_strings = (char *)(inbuffer + offset-1);
195  offset += length_st_strings;
196  memcpy( &(this->strings[i]), &(this->st_strings), sizeof(char*));
197  }
198  return offset;
199  }
200 
201  const char * getType(){ return REQUESTPARAM; };
202  const char * getMD5(){ return "9f0e98bda65981986ddf53afa7a40e49"; };
203 
204  };
205 
206  class RequestParam {
207  public:
210  };
211 
212 }
213 #endif
virtual int serialize(unsigned char *outbuffer) const
Definition: RequestParam.h:91
RequestParamResponse Response
Definition: RequestParam.h:209
virtual int serialize(unsigned char *outbuffer) const
Definition: RequestParam.h:40
virtual int deserialize(unsigned char *inbuffer)
Definition: RequestParam.h:140
virtual int deserialize(unsigned char *inbuffer)
Definition: RequestParam.h:51
static const char REQUESTPARAM[]
Definition: RequestParam.h:28
RequestParamRequest Request
Definition: RequestParam.h:208
Definition: msg.h:26


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