MRPT  2.0.1
CMatrixB.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "math-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/CMatrixB.h>
14 
15 using namespace mrpt;
16 using namespace mrpt::math;
17 
18 // This must be added to any CSerializable class implementation file.
20 
21 uint8_t CMatrixB::serializeGetVersion() const { return 0; }
23 {
24  out.WriteAs<uint32_t>(sizeof(bool));
25 
26  // First, write the number of rows and columns:
27  out.WriteAs<uint32_t>(rows());
28  out.WriteAs<uint32_t>(cols());
29 
30  if (rows() > 0 && cols() > 0)
31  out.WriteBuffer(&(*this)(0, 0), sizeof(bool) * cols() * rows());
32 }
33 
35 {
36  switch (version)
37  {
38  case 0:
39  {
40  uint32_t size_bool;
41  in >> size_bool;
42  if (size_bool != sizeof(bool))
44  "Error: size of 'bool' is different in serialized data!");
45 
46  uint32_t nRows, nCols;
47 
48  // First, write the number of rows and columns:
49  in >> nRows >> nCols;
50 
51  setSize(nRows, nCols);
52 
53  if (nRows > 0 && nCols > 0)
54  in.ReadBuffer(&(*this)(0, 0), sizeof(bool) * cols() * rows());
55  }
56  break;
57  default:
59  };
60 }
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
This base provides a set of functions for maths stuff.
size_type rows() const
Number of rows in the matrix.
size_type cols() const
Number of columns in the matrix.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
mrpt::vision::TStereoCalibResults out
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
Definition: CArchive.cpp:25
This class is a "CSerializable" wrapper for "CMatrixBool".
Definition: CMatrixB.h:21
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CMatrixB.cpp:34
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CMatrixB.cpp:22



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020