OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
GenericDataStructMatrix.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <vector>
5#include <functional>
6
7#include "OTCore/Variable.h"
8#include "GenericDataStruct.h"
9
10namespace ot
11{
12 struct __declspec(dllexport) MatrixEntryPointer
13 {
14 uint32_t m_column = 0;
15 uint32_t m_row = 0;
16 };
17
18 class __declspec(dllexport) GenericDataStructMatrix : public GenericDataStruct
19 {
20 public:
22 GenericDataStructMatrix();
23 ~GenericDataStructMatrix();
24 GenericDataStructMatrix(const GenericDataStructMatrix& _other);
25 GenericDataStructMatrix(GenericDataStructMatrix&& _other)noexcept;
26 GenericDataStructMatrix& operator=(const GenericDataStructMatrix& _other) = default;
27 GenericDataStructMatrix& operator=(GenericDataStructMatrix&& _other) noexcept = default;
28
29
30 GenericDataStructMatrix(uint32_t _rows, uint32_t _columns);
31 GenericDataStructMatrix(const MatrixEntryPointer& _matrixEntryPointer);
32 GenericDataStructMatrix(uint32_t _rows, uint32_t _columns, ot::Variable _defaultValue);
33 GenericDataStructMatrix(const MatrixEntryPointer& _matrixEntryPointer, ot::Variable _defaultValue);
34
35 void setValue(const MatrixEntryPointer& _matrixEntryPointer, ot::Variable&& _value);
36 void setValue(const MatrixEntryPointer& _matrixEntryPointer, const ot::Variable& _value);
37 void setValues(const ot::Variable* _values, uint32_t _size);
38
40 void setValues(std::list<ot::Variable> _values);
44 const ot::Variable& getValue(const MatrixEntryPointer& _matrixEntryPointer)const;
45 const ot::Variable* getValues()const;
46 const uint32_t getNumberOfColumns() const { return m_numberOfColumns; }
47 const uint32_t getNumberOfRows() const { return m_numberOfRows; }
48
49 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
50 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
51
52 static std::string getClassName() { return "GenericDataStructMatrix"; }
53
54 private:
55 uint32_t m_numberOfColumns = 0;
56 uint32_t m_numberOfRows = 0;
57
58 std::vector<ot::Variable> m_values;
59 void allocateValueMemory();
60 void allocateValueMemory( const ot::Variable& _defaultValue);
61 void allocateValueMemory( ot::Variable&& _defaultValue);
62
63 inline uint32_t getIndex(const uint32_t& _columnIndex, const uint32_t& _rowIndex) const { return m_numberOfColumns * _rowIndex + _columnIndex; }
64 };
65
66
67}
Definition Variable.h:107
Definition Connector.h:8
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30