general.h
Go to the documentation of this file.
1 /***********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
5  * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
6  *
7  * THE BSD LICENSE
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *************************************************************************/
30 
31 #ifndef RTABMAP_FLANN_GENERAL_H_
32 #define RTABMAP_FLANN_GENERAL_H_
33 
34 #include "defines.h"
35 #include <stdexcept>
36 #include <cassert>
37 #include <limits.h>
38 
39 namespace rtflann
40 {
41 
42 class FLANNException : public std::runtime_error
43 {
44 public:
45  FLANNException(const char* message) : std::runtime_error(message) { }
46 
47  FLANNException(const std::string& message) : std::runtime_error(message) { }
48 };
49 
50 
51 template <typename T>
53 {
54  static const flann_datatype_t value = FLANN_NONE;
55 };
56 
57 template<>
59 {
60  static const flann_datatype_t value = FLANN_INT8;
61 };
62 
63 template<>
64 struct flann_datatype_value<short>
65 {
66  static const flann_datatype_t value = FLANN_INT16;
67 };
68 
69 template<>
71 {
72  static const flann_datatype_t value = FLANN_INT32;
73 };
74 
75 #ifdef LLONG_MAX
76 template<>
77 struct flann_datatype_value<long long>
78 {
79  static const flann_datatype_t value = FLANN_INT64;
80 };
81 #endif
82 
83 template<>
84 struct flann_datatype_value<unsigned char>
85 {
86  static const flann_datatype_t value = FLANN_UINT8;
87 };
88 
89 template<>
90 struct flann_datatype_value<unsigned short>
91 {
92  static const flann_datatype_t value = FLANN_UINT16;
93 };
94 
95 template<>
96 struct flann_datatype_value<unsigned int>
97 {
98  static const flann_datatype_t value = FLANN_UINT32;
99 };
100 
101 #ifdef ULLONG_MAX
102 template<>
103 struct flann_datatype_value<unsigned long long>
104 {
105  static const flann_datatype_t value = FLANN_UINT64;
106 };
107 #endif
108 
109 
110 template<>
111 struct flann_datatype_value<float>
112 {
113  static const flann_datatype_t value = FLANN_FLOAT32;
114 };
115 
116 template<>
117 struct flann_datatype_value<double>
118 {
119  static const flann_datatype_t value = FLANN_FLOAT64;
120 };
121 
122 
123 
124 template <flann_datatype_t datatype>
126 {
127  typedef void type;
128 };
129 
130 template<>
132 {
133  typedef char type;
134 };
135 
136 template<>
138 {
139  typedef short type;
140 };
141 
142 template<>
144 {
145  typedef int type;
146 };
147 
148 #ifdef LLONG_MAX
149 template<>
151 {
152  typedef long long type;
153 };
154 #endif
155 
156 template<>
158 {
159  typedef unsigned char type;
160 };
161 
162 
163 template<>
165 {
166  typedef unsigned short type;
167 };
168 
169 template<>
171 {
172  typedef unsigned int type;
173 };
174 
175 #ifdef ULLONG_MAX
176 template<>
178 {
179  typedef unsigned long long type;
180 };
181 #endif
182 
183 template<>
185 {
186  typedef float type;
187 };
188 
189 template<>
191 {
192  typedef double type;
193 };
194 
195 
197 {
198  switch (type) {
199  case FLANN_INT8:
201  case FLANN_INT16:
203  case FLANN_INT32:
205  case FLANN_INT64:
207  case FLANN_UINT8:
209  case FLANN_UINT16:
211  case FLANN_UINT32:
213  case FLANN_UINT64:
215  case FLANN_FLOAT32:
217  case FLANN_FLOAT64:
219  default:
220  return 0;
221  }
222 }
223 
224 }
225 
226 
227 #endif /* RTABMAP_FLANN_GENERAL_H_ */
size_t flann_datatype_size(flann_datatype_t type)
Definition: general.h:196
FLANNException(const std::string &message)
Definition: general.h:47
flann_datatype_t
Definition: defines.h:131
FLANNException(const char *message)
Definition: general.h:45


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:41:31