lcmtypes_velodyne_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_velodyne_t.h"
37 
40 
42 {
43  const __lcm_hash_ptr *fp;
44  for (fp = p; fp != NULL; fp = fp->parent)
46  return 0;
47 
48  const __lcm_hash_ptr cp = { p, (void*)__lcmtypes_velodyne_t_get_hash };
49  (void) cp;
50 
51  int64_t hash = 0xb6befe08f6d416d3LL
55  ;
56 
57  return (hash<<1) + ((hash>>63)&1);
58 }
59 
61 {
65  }
66 
68 }
69 
70 int __lcmtypes_velodyne_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_velodyne_t *p, int elements)
71 {
72  int pos = 0, thislen, element;
73 
74  for (element = 0; element < elements; element++) {
75 
76  thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].utime), 1);
77  if (thislen < 0) return thislen; else pos += thislen;
78 
79  thislen = __int32_t_encode_array(buf, offset + pos, maxlen - pos, &(p[element].datalen), 1);
80  if (thislen < 0) return thislen; else pos += thislen;
81 
82  thislen = __byte_encode_array(buf, offset + pos, maxlen - pos, p[element].data, p[element].datalen);
83  if (thislen < 0) return thislen; else pos += thislen;
84 
85  }
86  return pos;
87 }
88 
89 int lcmtypes_velodyne_t_encode(void *buf, int offset, int maxlen, const lcmtypes_velodyne_t *p)
90 {
91  int pos = 0, thislen;
92  int64_t hash = __lcmtypes_velodyne_t_get_hash();
93 
94  thislen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1);
95  if (thislen < 0) return thislen; else pos += thislen;
96 
97  thislen = __lcmtypes_velodyne_t_encode_array(buf, offset + pos, maxlen - pos, p, 1);
98  if (thislen < 0) return thislen; else pos += thislen;
99 
100  return pos;
101 }
102 
104 {
105  int size = 0, element;
106  for (element = 0; element < elements; element++) {
107 
108  size += __int64_t_encoded_array_size(&(p[element].utime), 1);
109 
110  size += __int32_t_encoded_array_size(&(p[element].datalen), 1);
111 
112  size += __byte_encoded_array_size(p[element].data, p[element].datalen);
113 
114  }
115  return size;
116 }
117 
119 {
121 }
122 
123 int __lcmtypes_velodyne_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_velodyne_t *p, int elements)
124 {
125  int pos = 0, thislen, element;
126 
127  for (element = 0; element < elements; element++) {
128 
129  thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].utime), 1);
130  if (thislen < 0) return thislen; else pos += thislen;
131 
132  thislen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &(p[element].datalen), 1);
133  if (thislen < 0) return thislen; else pos += thislen;
134 
135  p[element].data = (uint8_t*) lcm_malloc(sizeof(uint8_t) * p[element].datalen);
136  thislen = __byte_decode_array(buf, offset + pos, maxlen - pos, p[element].data, p[element].datalen);
137  if (thislen < 0) return thislen; else pos += thislen;
138 
139  }
140  return pos;
141 }
142 
144 {
145  int element;
146  for (element = 0; element < elements; element++) {
147 
148  __int64_t_decode_array_cleanup(&(p[element].utime), 1);
149 
150  __int32_t_decode_array_cleanup(&(p[element].datalen), 1);
151 
152  __byte_decode_array_cleanup(p[element].data, p[element].datalen);
153  if (p[element].data) free(p[element].data);
154 
155  }
156  return 0;
157 }
158 
159 int lcmtypes_velodyne_t_decode(const void *buf, int offset, int maxlen, lcmtypes_velodyne_t *p)
160 {
161  int pos = 0, thislen;
162  int64_t hash = __lcmtypes_velodyne_t_get_hash();
163 
164  int64_t this_hash;
165  thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &this_hash, 1);
166  if (thislen < 0) return thislen; else pos += thislen;
167  if (this_hash != hash) return -1;
168 
169  thislen = __lcmtypes_velodyne_t_decode_array(buf, offset + pos, maxlen - pos, p, 1);
170  if (thislen < 0) return thislen; else pos += thislen;
171 
172  return pos;
173 }
174 
176 {
178 }
179 
181 {
182  int element;
183  for (element = 0; element < elements; element++) {
184 
185  __int64_t_clone_array(&(p[element].utime), &(q[element].utime), 1);
186 
187  __int32_t_clone_array(&(p[element].datalen), &(q[element].datalen), 1);
188 
189  q[element].data = (uint8_t*) lcm_malloc(sizeof(uint8_t) * q[element].datalen);
190  __byte_clone_array(p[element].data, q[element].data, p[element].datalen);
191 
192  }
193  return 0;
194 }
195 
197 {
200  return q;
201 }
202 
204 {
206  free(p);
207 }
static void * lcm_malloc(size_t sz)
static int __lcmtypes_velodyne_t_hash_computed
int64_t __lcmtypes_velodyne_t_get_hash(void)
#define __byte_decode_array_cleanup(p, sz)
Definition: lcm_coretypes.h:79
static int __int32_t_encoded_array_size(const int32_t *p, int elements)
static int __int64_t_decode_array(const void *_buf, int offset, int maxlen, int64_t *p, int elements)
int __lcmtypes_velodyne_t_clone_array(const lcmtypes_velodyne_t *p, lcmtypes_velodyne_t *q, int elements)
static int __byte_encode_array(void *_buf, int offset, int maxlen, const uint8_t *p, int elements)
Definition: lcm_coretypes.h:87
int __lcmtypes_velodyne_t_decode_array(const void *buf, int offset, int maxlen, lcmtypes_velodyne_t *p, int elements)
lcmtypes_velodyne_t * lcmtypes_velodyne_t_copy(const lcmtypes_velodyne_t *p)
int lcmtypes_velodyne_t_encode(void *buf, int offset, int maxlen, const lcmtypes_velodyne_t *p)
int __lcmtypes_velodyne_t_decode_array_cleanup(lcmtypes_velodyne_t *p, int elements)
#define __byte_hash_recursive(p)
Definition: lcm_coretypes.h:78
static int __int64_t_encode_array(void *_buf, int offset, int maxlen, const int64_t *p, int elements)
static int __int32_t_clone_array(const int32_t *p, int32_t *q, int elements)
static int __int32_t_decode_array(const void *_buf, int offset, int maxlen, int32_t *p, int elements)
static int __int64_t_clone_array(const int64_t *p, int64_t *q, int elements)
#define __int32_t_hash_recursive(p)
int lcmtypes_velodyne_t_decode(const void *buf, int offset, int maxlen, lcmtypes_velodyne_t *p)
int64_t __lcmtypes_velodyne_t_hash_recursive(const __lcm_hash_ptr *p)
int lcmtypes_velodyne_t_encoded_size(const lcmtypes_velodyne_t *p)
THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY BY HAND!! Generated by LCM.
#define __int64_t_hash_recursive(p)
static int __int32_t_encode_array(void *_buf, int offset, int maxlen, const int32_t *p, int elements)
static int64_t __lcmtypes_velodyne_t_hash
static int __byte_encoded_array_size(const uint8_t *p, int elements)
Definition: lcm_coretypes.h:82
int lcmtypes_velodyne_t_decode_cleanup(lcmtypes_velodyne_t *p)
static int __int64_t_encoded_array_size(const int64_t *p, int elements)
int __lcmtypes_velodyne_t_encode_array(void *buf, int offset, int maxlen, const lcmtypes_velodyne_t *p, int elements)
int __lcmtypes_velodyne_t_encoded_array_size(const lcmtypes_velodyne_t *p, int elements)
static int __byte_decode_array(const void *_buf, int offset, int maxlen, uint8_t *p, int elements)
Definition: lcm_coretypes.h:98
#define __int32_t_decode_array_cleanup(p, sz)
const __lcm_hash_ptr * parent
Definition: lcm_coretypes.h:60
#define __int64_t_decode_array_cleanup(p, sz)
void lcmtypes_velodyne_t_destroy(lcmtypes_velodyne_t *p)
static int __byte_clone_array(const uint8_t *p, uint8_t *q, int elements)


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