serialization.h
Go to the documentation of this file.
1 #ifndef RTABMAP_SERIALIZATION_H_
2 #define RTABMAP_SERIALIZATION_H_
3 
4 #include <vector>
5 #include <map>
6 #include <cstdlib>
7 #include <cstring>
8 #include <stdio.h>
9 #include "rtflann/ext/lz4.h"
10 #include "rtflann/ext/lz4hc.h"
11 
12 
13 namespace rtflann
14 {
16  char signature[24];
17  char version[16];
20  size_t rows;
21  size_t cols;
22  size_t compression;
24  };
25 
26 namespace serialization
27 {
28 
29 struct access
30 {
31  template<typename Archive, typename T>
32  static inline void serialize(Archive& ar, T& type)
33  {
34  type.serialize(ar);
35  }
36 };
37 
38 
39 template<typename Archive, typename T>
40 inline void serialize(Archive& ar, T& type)
41 {
43 }
44 
45 template<typename T>
46 struct Serializer
47 {
48  template<typename InputArchive>
49  static inline void load(InputArchive& ar, T& val)
50  {
52  }
53  template<typename OutputArchive>
54  static inline void save(OutputArchive& ar, const T& val)
55  {
56  serialization::serialize(ar,const_cast<T&>(val));
57  }
58 };
59 
60 #define BASIC_TYPE_SERIALIZER(type)\
61 template<> \
62 struct Serializer<type> \
63 {\
64  template<typename InputArchive>\
65  static inline void load(InputArchive& ar, type& val)\
66  {\
67  ar.load(val);\
68  }\
69  template<typename OutputArchive>\
70  static inline void save(OutputArchive& ar, const type& val)\
71  {\
72  ar.save(val);\
73  }\
74 }
75 
76 #define ENUM_SERIALIZER(type)\
77 template<>\
78 struct Serializer<type>\
79 {\
80  template<typename InputArchive>\
81  static inline void load(InputArchive& ar, type& val)\
82  {\
83  int int_val;\
84  ar & int_val;\
85  val = (type) int_val;\
86  }\
87  template<typename OutputArchive>\
88  static inline void save(OutputArchive& ar, const type& val)\
89  {\
90  int int_val = (int)val;\
91  ar & int_val;\
92  }\
93 }
94 
95 
96 // declare serializers for simple types
98 BASIC_TYPE_SERIALIZER(unsigned char);
100 BASIC_TYPE_SERIALIZER(unsigned short);
102 BASIC_TYPE_SERIALIZER(unsigned int);
104 BASIC_TYPE_SERIALIZER(unsigned long);
105 BASIC_TYPE_SERIALIZER(unsigned long long);
106 BASIC_TYPE_SERIALIZER(float);
107 BASIC_TYPE_SERIALIZER(double);
109 #ifdef _MSC_VER
110 // unsigned __int64 ~= unsigned long long
111 // Will throw error on VS2013
112 #if _MSC_VER != 1800
113 //BASIC_TYPE_SERIALIZER(unsigned __int64);
114 #endif
115 #endif
116 
117 
118 // serializer for std::vector
119 template<typename T>
120 struct Serializer<std::vector<T> >
121 {
122  template<typename InputArchive>
123  static inline void load(InputArchive& ar, std::vector<T>& val)
124  {
125  size_t size;
126  ar & size;
127  val.resize(size);
128  for (size_t i=0;i<size;++i) {
129  ar & val[i];
130  }
131  }
132 
133  template<typename OutputArchive>
134  static inline void save(OutputArchive& ar, const std::vector<T>& val)
135  {
136  ar & val.size();
137  for (size_t i=0;i<val.size();++i) {
138  ar & val[i];
139  }
140  }
141 };
142 
143 // serializer for std::vector
144 template<typename K, typename V>
145 struct Serializer<std::map<K,V> >
146 {
147  template<typename InputArchive>
148  static inline void load(InputArchive& ar, std::map<K,V>& map_val)
149  {
150  size_t size;
151  ar & size;
152  for (size_t i = 0; i < size; ++i)
153  {
154  K key;
155  ar & key;
156  V value;
157  ar & value;
158  map_val[key] = value;
159  }
160  }
161 
162  template<typename OutputArchive>
163  static inline void save(OutputArchive& ar, const std::map<K,V>& map_val)
164  {
165  ar & map_val.size();
166  for (typename std::map<K,V>::const_iterator i=map_val.begin(); i!=map_val.end(); ++i) {
167  ar & i->first;
168  ar & i->second;
169  }
170  }
171 };
172 
173 template<typename T>
174 struct Serializer<T*>
175 {
176  template<typename InputArchive>
177  static inline void load(InputArchive& ar, T*& val)
178  {
179  ar.load(val);
180  }
181 
182  template<typename OutputArchive>
183  static inline void save(OutputArchive& ar, T* const& val)
184  {
185  ar.save(val);
186  }
187 };
188 
189 template<typename T, int N>
190 struct Serializer<T[N]>
191 {
192  template<typename InputArchive>
193  static inline void load(InputArchive& ar, T (&val)[N])
194  {
195  ar.load(val);
196  }
197 
198  template<typename OutputArchive>
199  static inline void save(OutputArchive& ar, T const (&val)[N])
200  {
201  ar.save(val);
202  }
203 };
204 
205 
206 
207 
209 {
210  void const * ptr_;
211  size_t size_;
212 
213  binary_object( void * const ptr, size_t size) :
214  ptr_(ptr),
215  size_(size)
216  {}
218  ptr_(rhs.ptr_),
219  size_(rhs.size_)
220  {}
221 
223  ptr_ = rhs.ptr_;
224  size_ = rhs.size_;
225  return *this;
226  }
227 };
228 
229 inline const binary_object make_binary_object(/* const */ void * t, size_t size){
230  return binary_object(t, size);
231 }
232 
233 template<>
235 {
236  template<typename InputArchive>
237  static inline void load(InputArchive& ar, const binary_object& b)
238  {
239  ar.load_binary(const_cast<void *>(b.ptr_), b.size_);
240  }
241 
242  template<typename OutputArchive>
243  static inline void save(OutputArchive& ar, const binary_object& b)
244  {
245  ar.save_binary(b.ptr_, b.size_);
246  }
247 };
248 
249 template<>
251 {
252  template<typename InputArchive>
253  static inline void load(InputArchive& ar, binary_object& b)
254  {
255  ar.load_binary(const_cast<void *>(b.ptr_), b.size_);
256  }
257 
258  template<typename OutputArchive>
259  static inline void save(OutputArchive& ar, const binary_object& b)
260  {
261  ar.save_binary(b.ptr_, b.size_);
262  }
263 };
264 
265 
266 
267 template <bool C_>
268 struct bool_ {
269  static const bool value = C_;
270  typedef bool value_type;
271 };
272 
273 
275 {
276 public:
277  void* getObject() { return object_; }
278 
279  void setObject(void* object) { object_ = object; }
280 
281 private:
282  void* object_;
283 };
284 
285 
286 template<typename Archive>
287 class InputArchive : public ArchiveBase
288 {
289 protected:
291 public:
292  typedef bool_<true> is_loading;
294 
295  template<typename T>
296  Archive& operator& (T& val)
297  {
298  Serializer<T>::load(*static_cast<Archive*>(this),val);
299  return *static_cast<Archive*>(this);
300  }
301 };
302 
303 
304 template<typename Archive>
306 {
307 protected:
309 public:
310  typedef bool_<false> is_loading;
312 
313  template<typename T>
314  Archive& operator& (const T& val)
315  {
316  Serializer<T>::save(*static_cast<Archive*>(this),val);
317  return *static_cast<Archive*>(this);
318  }
319 };
320 
321 
322 
323 class SizeArchive : public OutputArchive<SizeArchive>
324 {
325  size_t size_;
326 public:
327 
329  {
330  }
331 
332  template<typename T>
333  void save(const T& val)
334  {
335  size_ += sizeof(val);
336  }
337 
338  template<typename T>
339  void save_binary(T* ptr, size_t size)
340  {
341  size_ += size;
342  }
343 
344 
345  void reset()
346  {
347  size_ = 0;
348  }
349 
350  size_t size()
351  {
352  return size_;
353  }
354 };
355 
356 
357 //
358 //class PrintArchive : public OutputArchive<PrintArchive>
359 //{
360 //public:
361 // template<typename T>
362 // void save(const T& val)
363 // {
364 // std::cout << val << std::endl;
365 // }
366 //
367 // template<typename T>
368 // void save_binary(T* ptr, size_t size)
369 // {
370 // std::cout << "<binary object>" << std::endl;
371 // }
372 //};
373 
374 #define BLOCK_BYTES (1024 * 64)
375 
376 class SaveArchive : public OutputArchive<SaveArchive>
377 {
383  FILE* stream_;
385  char *buffer_;
386  size_t offset_;
387 
393 
394  void initBlock()
395  {
396  // Alloc the space for both buffer blocks (each compressed block
397  // references the previous)
398  buffer_ = buffer_blocks_ = (char *)malloc(BLOCK_BYTES*2);
399  compressed_buffer_ = (char *)malloc(LZ4_COMPRESSBOUND(BLOCK_BYTES) + sizeof(size_t));
400  if (buffer_ == NULL || compressed_buffer_ == NULL) {
401  throw FLANNException("Error allocating compression buffer");
402  }
403 
404  // Init the LZ4 stream
407  first_block_ = true;
408 
409  offset_ = 0;
410  }
411 
412  void flushBlock()
413  {
414  size_t compSz = 0;
415  // Handle header
416  if (first_block_) {
417  // Copy & set the header
419  size_t headSz = sizeof(IndexHeaderStruct);
420 
421  assert(head->compression == 0);
422  head->compression = 1; // Bool now, enum later
423 
424  // Do the compression for the block
425  compSz = LZ4_compress_HC_continue(
426  lz4Stream, buffer_+headSz, compressed_buffer_+headSz, offset_-headSz,
428 
429  if(compSz <= 0) {
430  throw FLANNException("Error compressing (first block)");
431  }
432 
433  // Handle header
434  head->first_block_size = compSz;
435  memcpy(compressed_buffer_, buffer_, headSz);
436 
437  compSz += headSz;
438  first_block_ = false;
439  } else {
440  size_t headSz = sizeof(compSz);
441 
442  // Do the compression for the block
443  compSz = LZ4_compress_HC_continue(
446 
447  if(compSz <= 0) {
448  throw FLANNException("Error compressing");
449  }
450 
451  // Save the size of the compressed block as the header
452  memcpy(compressed_buffer_, &compSz, headSz);
453  compSz += headSz;
454  }
455 
456  // Write the compressed buffer
457  fwrite(compressed_buffer_, compSz, 1, stream_);
458 
459  // Switch the buffer to the *other* block
460  if (buffer_ == buffer_blocks_)
462  else
464  offset_ = 0;
465  }
466 
467  void endBlock()
468  {
469  // Cleanup memory
470  free(buffer_blocks_);
472  buffer_ = NULL;
473  free(compressed_buffer_);
475 
476  // Write a '0' size for next block
477  size_t z = 0;
478  fwrite(&z, sizeof(z), 1, stream_);
479  }
480 
481 public:
482  SaveArchive(const char* filename)
483  {
484  stream_ = fopen(filename, "wb");
485  own_stream_ = true;
486  initBlock();
487  }
488 
490  {
491  initBlock();
492  }
493 
495  {
496  flushBlock();
497  endBlock();
498  if (buffer_) {
499  free(buffer_);
500  buffer_ = NULL;
501  }
502  if (own_stream_) {
503  fclose(stream_);
504  }
505  }
506 
507  template<typename T>
508  void save(const T& val)
509  {
510  assert(sizeof(val) < BLOCK_BYTES);
511  if (offset_+sizeof(val) > BLOCK_BYTES)
512  flushBlock();
513  memcpy(buffer_+offset_, &val, sizeof(val));
514  offset_ += sizeof(val);
515  }
516 
517  template<typename T>
518  void save(T* const& val)
519  {
520  // don't save pointers
521  //fwrite(&val, sizeof(val), 1, handle_);
522  }
523 
524  template<typename T>
525  void save_binary(T* ptr, size_t size)
526  {
527  while (size > BLOCK_BYTES) {
528  // Flush existing block
529  flushBlock();
530 
531  // Save large chunk
532  memcpy(buffer_, ptr, BLOCK_BYTES);
533  offset_ += BLOCK_BYTES;
534  ptr = ((char *)ptr) + BLOCK_BYTES;
535  size -= BLOCK_BYTES;
536  }
537 
538  // Save existing block if new data will make it too big
539  if (offset_+size > BLOCK_BYTES)
540  flushBlock();
541 
542  // Copy out requested data
543  memcpy(buffer_+offset_, ptr, size);
544  offset_ += size;
545  }
546 
547 };
548 
549 
550 class LoadArchive : public InputArchive<LoadArchive>
551 {
557  FILE* stream_;
559  char *buffer_;
560  char *ptr_;
561 
566  size_t block_sz_;
567 
568  void decompressAndLoadV10(FILE* stream)
569  {
570  buffer_ = NULL;
571 
572  // Find file size
573  size_t pos = ftell(stream);
574  fseek(stream, 0, SEEK_END);
575  size_t fileSize = ftell(stream)-pos;
576  fseek(stream, pos, SEEK_SET);
577  size_t headSz = sizeof(IndexHeaderStruct);
578 
579  // Read the (compressed) file to a buffer
580  char *compBuffer = (char *)malloc(fileSize);
581  if (compBuffer == NULL) {
582  throw FLANNException("Error allocating file buffer space");
583  }
584  if (fread(compBuffer, fileSize, 1, stream) != 1) {
585  free(compBuffer);
586  throw FLANNException("Invalid index file, cannot read from disk (compressed)");
587  }
588 
589  // Extract header
590  IndexHeaderStruct *head = (IndexHeaderStruct *)(compBuffer);
591 
592  // Backward compatability
593  size_t compressedSz = fileSize-headSz;
594  size_t uncompressedSz = head->first_block_size-headSz;
595 
596  // Check for compression type
597  if (head->compression != 1) {
598  free(compBuffer);
599  throw FLANNException("Compression type not supported");
600  }
601 
602  // Allocate a decompressed buffer
603  ptr_ = buffer_ = (char *)malloc(uncompressedSz+headSz);
604  if (buffer_ == NULL) {
605  free(compBuffer);
606  throw FLANNException("Error (re)allocating decompression buffer");
607  }
608 
609  // Extract body
610  size_t usedSz = LZ4_decompress_safe(compBuffer+headSz,
611  buffer_+headSz,
612  compressedSz,
613  uncompressedSz);
614 
615  // Check if the decompression was the expected size.
616  if (usedSz != uncompressedSz) {
617  free(compBuffer);
618  throw FLANNException("Unexpected decompression size");
619  }
620 
621  // Copy header data
622  memcpy(buffer_, compBuffer, headSz);
623  free(compBuffer);
624 
625  // Put the file pointer at the end of the data we've read
626  if (compressedSz+headSz+pos != fileSize)
627  fseek(stream, compressedSz+headSz+pos, SEEK_SET);
628  block_sz_ = uncompressedSz+headSz;
629  }
630 
631  void initBlock(FILE *stream)
632  {
633  size_t pos = ftell(stream);
634  buffer_ = NULL;
637  size_t headSz = sizeof(IndexHeaderStruct);
638 
639  // Read the file header to a buffer
640  IndexHeaderStruct *head = (IndexHeaderStruct *)malloc(headSz);
641  if (head == NULL) {
642  throw FLANNException("Error allocating header buffer space");
643  }
644  if (fread(head, headSz, 1, stream) != 1) {
645  free(head);
646  throw FLANNException("Invalid index file, cannot read from disk (header)");
647  }
648 
649  // Backward compatability
650  if (head->signature[13] == '1' && head->signature[15] == '0') {
651  free(head);
652  fseek(stream, pos, SEEK_SET);
654  }
655 
656  // Alloc the space for both buffer blocks (each block
657  // references the previous)
658  buffer_ = buffer_blocks_ = (char *)malloc(BLOCK_BYTES*2);
660  if (buffer_ == NULL || compressed_buffer_ == NULL) {
661  free(head);
662  throw FLANNException("Error allocating compression buffer");
663  }
664 
665  // Init the LZ4 stream
668 
669  // Read first block
670  memcpy(buffer_, head, headSz);
671  loadBlock(buffer_+headSz, head->first_block_size, stream);
672  block_sz_ += headSz;
673  ptr_ = buffer_;
674  free(head);
675  }
676 
677  void loadBlock(char* buffer_, size_t compSz, FILE* stream)
678  {
679  if(compSz >= LZ4_COMPRESSBOUND(BLOCK_BYTES)) {
680  throw FLANNException("Requested block size too large");
681  }
682 
683  // Read the block into the compressed buffer
684  if (fread(compressed_buffer_, compSz, 1, stream) != 1) {
685  throw FLANNException("Invalid index file, cannot read from disk (block)");
686  }
687 
688  // Decompress into the regular buffer
689  const int decBytes = LZ4_decompress_safe_continue(
691  if(decBytes <= 0) {
692  throw FLANNException("Invalid index file, cannot decompress block");
693  }
694  block_sz_ = decBytes;
695  }
696 
697  void preparePtr(size_t size)
698  {
699  // Return if the new size is less than (or eq) the size of a block
700  if (ptr_+size <= buffer_+block_sz_)
701  return;
702 
703  // Switch the buffer to the *other* block
704  if (buffer_ == buffer_blocks_)
706  else
708 
709  // Find the size of the next block
710  size_t cmpSz = 0;
711  size_t readCnt = fread(&cmpSz, sizeof(cmpSz), 1, stream_);
712  if(cmpSz <= 0 || readCnt != 1) {
713  throw FLANNException("Requested to read next block past end of file");
714  }
715 
716  // Load block & init ptr
717  loadBlock(buffer_, cmpSz, stream_);
718  ptr_ = buffer_;
719  }
720 
721  void endBlock()
722  {
723  // If not v1.0 format hack...
724  if (buffer_blocks_ != NULL) {
725  // Read the last '0' in the file
726  size_t zero = -1;
727  if (fread(&zero, sizeof(zero), 1, stream_) != 1) {
728  throw FLANNException("Invalid index file, cannot read from disk (end)");
729  }
730  if (zero != 0) {
731  throw FLANNException("Invalid index file, last block not zero length");
732  }
733  }
734 
735  // Free resources
736  if (buffer_blocks_ != NULL) {
737  free(buffer_blocks_);
739  }
740  if (compressed_buffer_ != NULL) {
741  free(compressed_buffer_);
743  }
744  ptr_ = NULL;
745  }
746 
747 public:
748  LoadArchive(const char* filename)
749  {
750  // Open the file
751  stream_ = fopen(filename, "rb");
752  own_stream_ = true;
753 
755  }
756 
757  LoadArchive(FILE* stream)
758  {
759  stream_ = stream;
760  own_stream_ = false;
761 
762  initBlock(stream);
763  }
764 
766  {
767  endBlock();
768  if (own_stream_) {
769  fclose(stream_);
770  }
771  }
772 
773  template<typename T>
774  void load(T& val)
775  {
776  preparePtr(sizeof(val));
777  memcpy(&val, ptr_, sizeof(val));
778  ptr_ += sizeof(val);
779  }
780 
781  template<typename T>
782  void load(T*& val)
783  {
784  // don't load pointers
785  //fread(&val, sizeof(val), 1, handle_);
786  }
787 
788  template<typename T>
789  void load_binary(T* ptr, size_t size)
790  {
791  while (size > BLOCK_BYTES) {
792  // Load next block
794 
795  // Load large chunk
796  memcpy(ptr, ptr_, BLOCK_BYTES);
797  ptr_ += BLOCK_BYTES;
798  ptr = ((char *)ptr) + BLOCK_BYTES;
799  size -= BLOCK_BYTES;
800  }
801 
802  // Load next block if needed
803  preparePtr(size);
804 
805  // Load the data
806  memcpy(ptr, ptr_, size);
807  ptr_ += size;
808  }
809 };
810 
811 } // namespace serialization
812 } // namespace flann
813 #endif // SERIALIZATION_H_
rtflann::serialization::binary_object::binary_object
binary_object(void *const ptr, size_t size)
Definition: serialization.h:213
rtflann::IndexHeaderStruct::signature
char signature[24]
Definition: serialization.h:16
rtflann::serialization::SaveArchive::offset_
size_t offset_
Definition: serialization.h:386
rtflann::IndexHeaderStruct::data_type
flann_datatype_t data_type
Definition: serialization.h:18
head
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE FixedSegmentReturnType< N >::Type head(Index n=N)
rtflann::serialization::LoadArchive::endBlock
void endBlock()
Definition: serialization.h:721
rtflann::serialization::BASIC_TYPE_SERIALIZER
BASIC_TYPE_SERIALIZER(char)
rtflann::serialization::LoadArchive::lz4StreamDecode
LZ4_streamDecode_t * lz4StreamDecode
Definition: serialization.h:565
rtflann::serialization::LoadArchive::load_binary
void load_binary(T *ptr, size_t size)
Definition: serialization.h:789
rtflann::serialization::Serializer< T[N]>::load
static void load(InputArchive &ar, T(&val)[N])
Definition: serialization.h:193
rtflann::serialization::SaveArchive::SaveArchive
SaveArchive(const char *filename)
Definition: serialization.h:482
rtflann::serialization::SaveArchive
Definition: serialization.h:376
b
Array< int, 3, 1 > b
rtflann::serialization::LoadArchive::compressed_buffer_
char * compressed_buffer_
Definition: serialization.h:563
stream
stream
rtflann::serialization::ArchiveBase::object_
void * object_
Definition: serialization.h:282
rtflann::serialization::SaveArchive::first_block_
int first_block_
Definition: serialization.h:388
LZ4_setStreamDecode
int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize)
Definition: lz4.c:1338
rtflann::serialization::LoadArchive::LoadArchive
LoadArchive(const char *filename)
Definition: serialization.h:748
rtflann::serialization::Serializer< std::map< K, V > >::load
static void load(InputArchive &ar, std::map< K, V > &map_val)
Definition: serialization.h:148
rtflann::serialization::SaveArchive::lz4Stream
LZ4_streamHC_t * lz4Stream
Definition: serialization.h:392
size
Index size
LZ4_decompress_safe_continue
int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *source, char *dest, int compressedSize, int maxOutputSize)
Definition: lz4.c:1355
rtflann::FLANNException
Definition: general.h:70
LZ4_COMPRESSBOUND
#define LZ4_COMPRESSBOUND(isize)
Definition: lz4.h:106
rtflann::serialization::LoadArchive::buffer_blocks_
char * buffer_blocks_
Definition: serialization.h:562
rtflann::serialization::OutputArchive::is_saving
bool_< true > is_saving
Definition: serialization.h:311
rtflann::serialization::LoadArchive::load
void load(T *&val)
Definition: serialization.h:782
LZ4_streamDecode_t
Definition: lz4.h:249
rtflann::serialization::SizeArchive::save_binary
void save_binary(T *ptr, size_t size)
Definition: serialization.h:339
rtflann::IndexHeaderStruct
Definition: serialization.h:15
rtflann::serialization::LoadArchive::buffer_
char * buffer_
Definition: serialization.h:559
rtflann::serialization::LoadArchive::LoadArchive
LoadArchive(FILE *stream)
Definition: serialization.h:757
rtflann::serialization::SizeArchive::reset
void reset()
Definition: serialization.h:345
rtflann::serialization::LoadArchive::own_stream_
bool own_stream_
Definition: serialization.h:558
rtflann::serialization::SizeArchive
Definition: serialization.h:323
rtflann::serialization::ArchiveBase::setObject
void setObject(void *object)
Definition: serialization.h:279
rtflann::serialization::LoadArchive::initBlock
void initBlock(FILE *stream)
Definition: serialization.h:631
type
lz4.h
rtflann::serialization::LoadArchive::ptr_
char * ptr_
Definition: serialization.h:560
rtflann::serialization::OutputArchive::OutputArchive
OutputArchive()
Definition: serialization.h:308
rtflann::serialization::SaveArchive::~SaveArchive
~SaveArchive()
Definition: serialization.h:494
rtflann::serialization::InputArchive::InputArchive
InputArchive()
Definition: serialization.h:290
rtflann::serialization::InputArchive::is_saving
bool_< false > is_saving
Definition: serialization.h:293
rtflann::serialization::bool_
Definition: serialization.h:268
rtflann::serialization::access
Definition: serialization.h:29
rtflann::serialization::LoadArchive::preparePtr
void preparePtr(size_t size)
Definition: serialization.h:697
rtflann::serialization::binary_object::binary_object
binary_object(const binary_object &rhs)
Definition: serialization.h:217
rtflann::serialization::access::serialize
static void serialize(Archive &ar, T &type)
Definition: serialization.h:32
rtflann::serialization::Serializer< T * >::load
static void load(InputArchive &ar, T *&val)
Definition: serialization.h:177
rtflann::serialization::Serializer< T * >::save
static void save(OutputArchive &ar, T *const &val)
Definition: serialization.h:183
rtflann::serialization::LoadArchive::block_sz_
size_t block_sz_
Definition: serialization.h:566
rtflann::serialization::bool_::value_type
bool value_type
Definition: serialization.h:270
LZ4_decompress_safe
int LZ4_decompress_safe(const char *source, char *dest, int compressedSize, int maxDecompressedSize)
Definition: lz4.c:1288
rtflann::serialization::InputArchive::is_loading
bool_< true > is_loading
Definition: serialization.h:290
rtflann::serialization::OutputArchive
Definition: serialization.h:305
rtflann::serialization::ArchiveBase
Definition: serialization.h:274
rtflann::serialization::binary_object::size_
size_t size_
Definition: serialization.h:211
rtflann::serialization::InputArchive
Definition: serialization.h:287
rtflann::serialization::LoadArchive::loadBlock
void loadBlock(char *buffer_, size_t compSz, FILE *stream)
Definition: serialization.h:677
filename
filename
rtflann::serialization::binary_object::ptr_
const void * ptr_
Definition: serialization.h:210
rtflann::serialization::SaveArchive::save
void save(T *const &val)
Definition: serialization.h:518
rtflann::serialization::LoadArchive
Definition: serialization.h:550
rtflann::serialization::SaveArchive::SaveArchive
SaveArchive(FILE *stream)
Definition: serialization.h:489
rtflann::serialization::SaveArchive::lz4Stream_body
LZ4_streamHC_t lz4Stream_body
Definition: serialization.h:391
rtflann::serialization::SizeArchive::size_
size_t size_
Definition: serialization.h:325
rtflann::serialization::Serializer< binary_object >::load
static void load(InputArchive &ar, binary_object &b)
Definition: serialization.h:253
rtflann::serialization::OutputArchive::is_loading
bool_< false > is_loading
Definition: serialization.h:308
LZ4_compress_HC_continue
int LZ4_compress_HC_continue(LZ4_streamHC_t *LZ4_streamHCPtr, const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4hc.c:641
object
rtflann::IndexHeaderStruct::index_type
flann_algorithm_t index_type
Definition: serialization.h:19
rtflann::serialization::Serializer< binary_object >::save
static void save(OutputArchive &ar, const binary_object &b)
Definition: serialization.h:259
rtflann::serialization::Serializer< const binary_object >::load
static void load(InputArchive &ar, const binary_object &b)
Definition: serialization.h:237
z
z
rtflann::serialization::Serializer
Definition: serialization.h:46
Eigen::Triplet< double >
rtflann::serialization::SaveArchive::endBlock
void endBlock()
Definition: serialization.h:467
rtflann::serialization::SaveArchive::initBlock
void initBlock()
Definition: serialization.h:394
rtflann::serialization::LoadArchive::lz4StreamDecode_body
LZ4_streamDecode_t lz4StreamDecode_body
Definition: serialization.h:564
rtflann::serialization::Serializer::load
static void load(InputArchive &ar, T &val)
Definition: serialization.h:49
size_t
std::size_t size_t
rtflann::IndexHeaderStruct::cols
size_t cols
Definition: serialization.h:21
rtflann::serialization::Serializer< std::map< K, V > >::save
static void save(OutputArchive &ar, const std::map< K, V > &map_val)
Definition: serialization.h:163
rtflann::serialization::SizeArchive::size
size_t size()
Definition: serialization.h:350
key
const gtsam::Symbol key( 'X', 0)
K
K
rtflann::serialization::OutputArchive::operator&
Archive & operator&(const T &val)
Definition: serialization.h:314
rtflann::serialization::binary_object
Definition: serialization.h:208
LZ4_resetStreamHC
void LZ4_resetStreamHC(LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel)
Definition: lz4hc.c:567
rtflann::flann_algorithm_t
flann_algorithm_t
Definition: defines.h:79
zero
EIGEN_DONT_INLINE Scalar zero()
rtflann::serialization::make_binary_object
const binary_object make_binary_object(void *t, size_t size)
Definition: serialization.h:229
lz4hc.h
rtflann::IndexHeaderStruct::compression
size_t compression
Definition: serialization.h:22
rtflann::serialization::InputArchive::operator&
Archive & operator&(T &val)
Definition: serialization.h:296
rtflann::serialization::SaveArchive::save
void save(const T &val)
Definition: serialization.h:508
N
N
rtflann::serialization::SaveArchive::stream_
FILE * stream_
Definition: serialization.h:383
std
rtflann::serialization::LoadArchive::stream_
FILE * stream_
Definition: serialization.h:557
rtflann::serialization::Serializer< std::vector< T > >::load
static void load(InputArchive &ar, std::vector< T > &val)
Definition: serialization.h:123
rtflann::serialization::LoadArchive::decompressAndLoadV10
void decompressAndLoadV10(FILE *stream)
Definition: serialization.h:568
rtflann::serialization::SizeArchive::save
void save(const T &val)
Definition: serialization.h:333
rtflann::serialization::Serializer< std::vector< T > >::save
static void save(OutputArchive &ar, const std::vector< T > &val)
Definition: serialization.h:134
rtflann::serialization::LoadArchive::~LoadArchive
~LoadArchive()
Definition: serialization.h:765
rtflann::IndexHeaderStruct::rows
size_t rows
Definition: serialization.h:20
rtflann::IndexHeaderStruct::first_block_size
size_t first_block_size
Definition: serialization.h:23
V
MatrixXcd V
rtflann::serialization::SizeArchive::SizeArchive
SizeArchive()
Definition: serialization.h:328
rtflann::serialization::serialize
void serialize(Archive &ar, T &type)
Definition: serialization.h:40
rtflann::serialization::SaveArchive::own_stream_
bool own_stream_
Definition: serialization.h:384
rtflann::serialization::Serializer< T[N]>::save
static void save(OutputArchive &ar, T const (&val)[N])
Definition: serialization.h:199
rtflann::serialization::SaveArchive::buffer_blocks_
char * buffer_blocks_
Definition: serialization.h:389
NULL
#define NULL
rtflann::serialization::ArchiveBase::getObject
void * getObject()
Definition: serialization.h:277
false
#define false
Definition: ConvertUTF.c:56
rtflann::serialization::binary_object::operator=
binary_object & operator=(const binary_object &rhs)
Definition: serialization.h:222
LZ4_streamHC_t
Definition: lz4hc.h:91
rtflann::serialization::Serializer< const binary_object >::save
static void save(OutputArchive &ar, const binary_object &b)
Definition: serialization.h:243
rtflann::serialization::SaveArchive::compressed_buffer_
char * compressed_buffer_
Definition: serialization.h:390
pos
t
Point2 t(10, 10)
rtflann::serialization::bool_::value
static const bool value
Definition: serialization.h:269
BLOCK_BYTES
#define BLOCK_BYTES
Definition: serialization.h:374
rtflann::serialization::Serializer::save
static void save(OutputArchive &ar, const T &val)
Definition: serialization.h:54
rtflann
Definition: all_indices.h:49
value
value
i
int i
rtflann::IndexHeaderStruct::version
char version[16]
Definition: serialization.h:17
rtflann::flann_datatype_t
flann_datatype_t
Definition: defines.h:131
rtflann::serialization::LoadArchive::load
void load(T &val)
Definition: serialization.h:774
rtflann::serialization::SaveArchive::save_binary
void save_binary(T *ptr, size_t size)
Definition: serialization.h:525
rtflann::serialization::SaveArchive::buffer_
char * buffer_
Definition: serialization.h:385
rtflann::serialization::SaveArchive::flushBlock
void flushBlock()
Definition: serialization.h:412


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:16