lcmtypes_pose_t.cpp
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
35 #include <string.h>
36 #include "lcmtypes_pose_t.h"
37 
39 static int64_t __lcmtypes_pose_t_hash;
40 
42 {
43  const __lcm_hash_ptr *fp;
44  for (fp = p; fp != NULL; fp = fp->parent)
45  if (fp->v == __lcmtypes_pose_t_get_hash)
46  return 0;
47 
48  const __lcm_hash_ptr cp = { p, (void*)__lcmtypes_pose_t_get_hash };
49  (void) cp;
50 
51  int64_t hash = 0x170b77d82958082fLL
58  ;
59 
60  return (hash<<1) + ((hash>>63)&1);
61 }
62 
64 {
68  }
69 
71 }
72 
73 int __lcmtypes_pose_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_pose_t *p, int elements)
74 {
75  int pos = 0, thislen, element;
76 
77  for (element = 0; element < elements; element++) {
78 
79  thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].utime), 1);
80  if (thislen < 0) return thislen; else pos += thislen;
81 
82  thislen = __double_encode_array(buf, offset + pos, maxlen - pos, p[element].pos, 3);
83  if (thislen < 0) return thislen; else pos += thislen;
84 
85  thislen = __double_encode_array(buf, offset + pos, maxlen - pos, p[element].vel, 3);
86  if (thislen < 0) return thislen; else pos += thislen;
87 
88  thislen = __double_encode_array(buf, offset + pos, maxlen - pos, p[element].orientation, 4);
89  if (thislen < 0) return thislen; else pos += thislen;
90 
91  thislen = __double_encode_array(buf, offset + pos, maxlen - pos, p[element].rotation_rate, 3);
92  if (thislen < 0) return thislen; else pos += thislen;
93 
94  thislen = __double_encode_array(buf, offset + pos, maxlen - pos, p[element].accel, 3);
95  if (thislen < 0) return thislen; else pos += thislen;
96 
97  }
98  return pos;
99 }
100 
101 int lcmtypes_pose_t_encode(void *buf, int offset, int maxlen, const lcmtypes_pose_t *p)
102 {
103  int pos = 0, thislen;
104  int64_t hash = __lcmtypes_pose_t_get_hash();
105 
106  thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1);
107  if (thislen < 0) return thislen; else pos += thislen;
108 
109  thislen = __lcmtypes_pose_t_encode_array(buf, offset + pos, maxlen - pos, p, 1);
110  if (thislen < 0) return thislen; else pos += thislen;
111 
112  return pos;
113 }
114 
116 {
117  int size = 0, element;
118  for (element = 0; element < elements; element++) {
119 
120  size += __int64_t_encoded_array_size(&(p[element].utime), 1);
121 
122  size += __double_encoded_array_size(p[element].pos, 3);
123 
124  size += __double_encoded_array_size(p[element].vel, 3);
125 
126  size += __double_encoded_array_size(p[element].orientation, 4);
127 
128  size += __double_encoded_array_size(p[element].rotation_rate, 3);
129 
130  size += __double_encoded_array_size(p[element].accel, 3);
131 
132  }
133  return size;
134 }
135 
137 {
138  return 8 + __lcmtypes_pose_t_encoded_array_size(p, 1);
139 }
140 
141 int __lcmtypes_pose_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_pose_t *p, int elements)
142 {
143  int pos = 0, thislen, element;
144 
145  for (element = 0; element < elements; element++) {
146 
147  thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].utime), 1);
148  if (thislen < 0) return thislen; else pos += thislen;
149 
150  thislen = __double_decode_array(buf, offset + pos, maxlen - pos, p[element].pos, 3);
151  if (thislen < 0) return thislen; else pos += thislen;
152 
153  thislen = __double_decode_array(buf, offset + pos, maxlen - pos, p[element].vel, 3);
154  if (thislen < 0) return thislen; else pos += thislen;
155 
156  thislen = __double_decode_array(buf, offset + pos, maxlen - pos, p[element].orientation, 4);
157  if (thislen < 0) return thislen; else pos += thislen;
158 
159  thislen = __double_decode_array(buf, offset + pos, maxlen - pos, p[element].rotation_rate, 3);
160  if (thislen < 0) return thislen; else pos += thislen;
161 
162  thislen = __double_decode_array(buf, offset + pos, maxlen - pos, p[element].accel, 3);
163  if (thislen < 0) return thislen; else pos += thislen;
164 
165  }
166  return pos;
167 }
168 
170 {
171  int element;
172  for (element = 0; element < elements; element++) {
173 
174  __int64_t_decode_array_cleanup(&(p[element].utime), 1);
175 
176  __double_decode_array_cleanup(p[element].pos, 3);
177 
178  __double_decode_array_cleanup(p[element].vel, 3);
179 
180  __double_decode_array_cleanup(p[element].orientation, 4);
181 
182  __double_decode_array_cleanup(p[element].rotation_rate, 3);
183 
184  __double_decode_array_cleanup(p[element].accel, 3);
185 
186  }
187  return 0;
188 }
189 
190 int lcmtypes_pose_t_decode(const void *buf, int offset, int maxlen, lcmtypes_pose_t *p)
191 {
192  int pos = 0, thislen;
193  int64_t hash = __lcmtypes_pose_t_get_hash();
194 
195  int64_t this_hash;
196  thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1);
197  if (thislen < 0) return thislen; else pos += thislen;
198  if (this_hash != hash) return -1;
199 
200  thislen = __lcmtypes_pose_t_decode_array(buf, offset + pos, maxlen - pos, p, 1);
201  if (thislen < 0) return thislen; else pos += thislen;
202 
203  return pos;
204 }
205 
207 {
209 }
210 
212 {
213  int element;
214  for (element = 0; element < elements; element++) {
215 
216  __int64_t_clone_array(&(p[element].utime), &(q[element].utime), 1);
217 
218  __double_clone_array(p[element].pos, q[element].pos, 3);
219 
220  __double_clone_array(p[element].vel, q[element].vel, 3);
221 
222  __double_clone_array(p[element].orientation, q[element].orientation, 4);
223 
224  __double_clone_array(p[element].rotation_rate, q[element].rotation_rate, 3);
225 
226  __double_clone_array(p[element].accel, q[element].accel, 3);
227 
228  }
229  return 0;
230 }
231 
233 {
234  lcmtypes_pose_t *q = (lcmtypes_pose_t*) malloc(sizeof(lcmtypes_pose_t));
236  return q;
237 }
238 
240 {
242  free(p);
243 }
static int __int64_t_decode_array(const void *_buf, int offset, int maxlen, int64_t *p, int elements)
void lcmtypes_pose_t_destroy(lcmtypes_pose_t *p)
int __lcmtypes_pose_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_pose_t *p, int elements)
int __lcmtypes_pose_t_clone_array(const lcmtypes_pose_t *p, lcmtypes_pose_t *q, int elements)
THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY BY HAND!! Generated by LCM.
lcmtypes_pose_t * lcmtypes_pose_t_copy(const lcmtypes_pose_t *p)
int __lcmtypes_pose_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_pose_t *p, int elements)
#define __double_decode_array_cleanup(p, sz)
int lcmtypes_pose_t_encoded_size(const lcmtypes_pose_t *p)
int __lcmtypes_pose_t_encoded_array_size(const lcmtypes_pose_t *p, int elements)
static int __int64_t_encode_array(void *_buf, int offset, int maxlen, const int64_t *p, int elements)
int64_t __lcmtypes_pose_t_get_hash(void)
int lcmtypes_pose_t_encode(void *buf, int offset, int maxlen, const lcmtypes_pose_t *p)
static int __double_encoded_array_size(const double *p, int elements)
static int __int64_t_clone_array(const int64_t *p, int64_t *q, int elements)
int64_t __lcmtypes_pose_t_hash_recursive(const __lcm_hash_ptr *p)
static int64_t __lcmtypes_pose_t_hash
#define __double_hash_recursive(p)
#define __int64_t_hash_recursive(p)
int lcmtypes_pose_t_decode(const void *buf, int offset, int maxlen, lcmtypes_pose_t *p)
static int __double_clone_array(const double *p, double *q, int elements)
static int __int64_t_encoded_array_size(const int64_t *p, int elements)
static int __lcmtypes_pose_t_hash_computed
static int __double_decode_array(const void *_buf, int offset, int maxlen, double *p, int elements)
static int __double_encode_array(void *_buf, int offset, int maxlen, const double *p, int elements)
int lcmtypes_pose_t_decode_cleanup(lcmtypes_pose_t *p)
int __lcmtypes_pose_t_decode_array_cleanup(lcmtypes_pose_t *p, int elements)
const __lcm_hash_ptr * parent
Definition: lcm_coretypes.h:60
#define __int64_t_decode_array_cleanup(p, sz)


mit_darpa_logs_player
Author(s): Miguel Oliveira
autogenerated on Mon Mar 2 2015 01:32:15