Flair
Framework Libre Air
Matrix.h
Go to the documentation of this file.
1 // %flair:license{
2 // This file is part of the Flair framework distributed under the
3 // CECILL-C License, Version 1.0.
4 // %flair:license}
13 #ifndef MATRIX_H
14 #define MATRIX_H
15 
16 #include <io_data.h>
17 #include <IODataElement.h>
18 #include <cvmatrix_descriptor.h>
19 
20 class Matrix_impl;
21 
22 namespace flair {
23 namespace core {
24 
31 class Matrix : public io_data {
32 public:
33  class Type : public DataType {
34  public:
35  Type(size_t _nbRows, size_t _nbCols, ScalarType const &_elementDataType)
36  : nbRows(_nbRows), nbCols(_nbCols), elementDataType(_elementDataType) {}
37  size_t GetSize() const {
38  return nbRows * nbCols * elementDataType.GetSize();
39  }
40  std::string GetDescription() const { return "matrix"; }
41  size_t GetNbRows() const { return nbRows; }
42  size_t GetNbCols() const { return nbCols; }
43  ScalarType const &GetElementDataType() const { return elementDataType; }
44 
45  private:
46  size_t nbRows, nbCols;
47  ScalarType const &elementDataType;
48  };
49 
64  Matrix(const Object *parent, const cvmatrix_descriptor *descriptor,
65  ScalarType const &elementDataType, std::string name = "",
66  uint32_t n = 1);
67 
82  Matrix(const Object *parent, uint32_t rows, uint32_t cols,
83  ScalarType const &elementDataType, std::string name = "",
84  uint32_t n = 1);
85 
90  ~Matrix();
91 
102  float Value(uint32_t row, uint32_t col) const;
103 
117  float ValueNoMutex(uint32_t row, uint32_t col) const;
118 
128  void SetValue(uint32_t row, uint32_t col, float value);
129 
142  void SetValueNoMutex(uint32_t row, uint32_t col, float value);
143 
154  std::string Name(uint32_t row, uint32_t col) const;
155 
166  IODataElement *Element(uint32_t row, uint32_t col) const;
167 
179  IODataElement *Element(uint32_t index) const;
180 
186  uint32_t Rows(void) const;
187 
193  uint32_t Cols(void) const;
194 
195  Type const &GetDataType() const { return dataType; };
196 
205  void RawRead(char *dst) const;
206 
214  void RawWrite(char *src);
215 
216 private:
217  class Matrix_impl *pimpl_;
218  Type dataType;
219 };
220 
221 } // end namespace core
222 } // end namespace flair
223 
224 #endif // MATRIX_H
Abstract class for data types.
Definition: io_data.h:94
Definition: io_data.h:26
Base class for all Framework's classes.
Definition: Object.h:83
namespace of the flair Framework
Definition: Ahrs.h:19
void SetValue(uint32_t row, uint32_t col, float value)
Set element value.
uint32_t Cols(void) const
Number of colomns.
Definition: Matrix.h:33
IODataElement * Element(uint32_t row, uint32_t col) const
Element.
Abstract class for data types.
Class describing cvmatrix elements, for log and graphs purpose.
Definition: cvmatrix_descriptor.h:28
float ValueNoMutex(uint32_t row, uint32_t col) const
Element value.
float Value(uint32_t row, uint32_t col) const
Element value.
std::string Name(uint32_t row, uint32_t col) const
Element name.
Abstract class for accessing an element of an io_data.
Definition: io_data.h:40
Class describing cvmatrix elements, for log and graphs purpose.
void RawWrite(char *src)
Raw write datas.
Abstract class for accessing an element of an io_data.
Definition: IODataElement.h:27
~Matrix()
Destructor.
void SetValueNoMutex(uint32_t row, uint32_t col, float value)
Set element value.
void RawRead(char *dst) const
Raw read datas.
Matrix(const Object *parent, const cvmatrix_descriptor *descriptor, ScalarType const &elementDataType, std::string name="", uint32_t n=1)
Constructor.
Class defining a matrix.
Definition: Matrix.h:31
uint32_t Rows(void) const
Number of rows.