Flair
Framework Libre Air
io_data.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 IO_DATA_H
14 #define IO_DATA_H
15 
16 #include <Mutex.h>
17 
18 class IODevice_impl;
19 class io_data_impl;
20 
21 namespace flair {
22 namespace core {
23 
24 class Object;
25 
26 class DataType {
27 public:
28  virtual std::string GetDescription() const = 0;
29  // size in bytes
30  virtual size_t GetSize() const = 0;
31 };
32 
33 class DummyType : public DataType {
34 public:
35  size_t GetSize() const { return 0; }
36  std::string GetDescription() const { return "dummy"; };
37 };
38 extern DummyType dummyType;
39 
40 class ScalarType : public DataType {
41 public:
42  ScalarType(size_t _size) : size(_size) {}
43  size_t GetSize() const { return size; }
44  virtual std::string GetDescription() const { return "scalar"; };
45 
46 private:
47  size_t size;
48 };
49 
50 class SignedIntegerType : public ScalarType {
51 public:
52  SignedIntegerType(size_t sizeInBits) : ScalarType(sizeInBits / 8) {}
53  std::string GetDescription() const {
54  return "int" + std::to_string(GetSize() * 8) + "_t";
55  };
56 };
57 extern SignedIntegerType Int8Type;
58 extern SignedIntegerType Int16Type;
59 
61 public:
62  UnsignedIntegerType(size_t sizeInBits) : ScalarType(sizeInBits / 8) {}
63  std::string GetDescription() const {
64  return "uint" + std::to_string(GetSize() * 8) + "_t";
65  };
66 };
67 extern UnsignedIntegerType UInt8Type;
68 extern UnsignedIntegerType UInt16Type;
69 
70 class FloatType : public ScalarType {
71 public:
72  FloatType() : ScalarType(4) {}
73  std::string GetDescription() const { return "float"; };
74 };
75 extern FloatType floatType;
76 
77 class DoubleType : public ScalarType {
78 public:
79  DoubleType() : ScalarType(8) {}
80  std::string GetDescription() const { return "double"; };
81 };
82 extern DoubleType doubleType;
83 
94 class io_data : public Mutex {
95  friend class IODevice;
96  friend class ::IODevice_impl;
97  friend class ::io_data_impl;
98 
99 public:
109  io_data(const Object *parent, std::string name, int n);
110 
115  virtual ~io_data();
116 
122  void SetDataTime(Time time);
123 
129  Time DataTime(void) const;
130 
142  const io_data *Prev(int n) const;
143 
144  virtual DataType const &GetDataType() const = 0;
145 
146 protected:
159  void AppendLogDescription(std::string description, DataType const &datatype);
160 
166  void SetPtrToCircle(void **ptr);
167 
175 
176 private:
187  virtual void CopyDatas(char *dst) const = 0;
188 
189  io_data_impl *pimpl_;
190 };
191 
192 } // end namespace core
193 } // end namespace flair
194 
195 #endif // IO_DATA_H
Abstract class for data types.
Definition: io_data.h:94
const io_data * Prev(int n) const
Previous data.
Definition: io_data.h:26
Base class for all Framework's classes.
Definition: Object.h:77
Abstract class for input/ouput system.
Definition: IODevice.h:45
namespace of the flair Framework
Definition: Ahrs.h:19
Time DataTime(void) const
Data time.
Class defining a mutex.
Definition: Mutex.h:29
unsigned long long Time
Time definition, in ns.
Definition: Object.h:49
void SetPtrToCircle(void **ptr)
Set the datas to circle.
io_data * prev
Pointer to previous data.
Definition: io_data.h:174
Definition: io_data.h:40
Definition: io_data.h:77
Definition: io_data.h:33
void SetDataTime(Time time)
Set data time.
Definition: io_data.h:60
Class defining a mutex.
io_data(const Object *parent, std::string name, int n)
Constructor.
Definition: io_data.h:50
void AppendLogDescription(std::string description, DataType const &datatype)
Specify the description of the reimplemented class data's.
Definition: io_data.h:70
virtual ~io_data()
Destructor.