Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
structs.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_UNITS_MODEL_STRUCTS_HPP_
2#define IV_SRC_UNITS_MODEL_STRUCTS_HPP_
3
4#include "core/defines.hpp"
6
7#include <cstring>
8#include <string_view>
9
10namespace iv::units
11{
12
14{
16 {
17 }
18
19 UnitLogicInfo(std::string_view _name, std::string_view _version, std::string_view _author,
20 std::string_view _description, iv::types::timestamp _date)
21 : name(_name), version(_version), author(_author), description(_description), date(_date)
22 {
23 }
24
26 {
27 name = data.name;
28 version = data.version;
29 author = data.author;
31 date = data.date;
32 }
33
34 UnitLogicInfo &operator=(const UnitLogicInfo &data) = default;
35
46
47 bool save(iv::file::xml::node &node) const
48 {
54
55 return true;
56 }
57
58 std::string name;
59 std::string version;
60 std::string author;
61 std::string description;
63
64private:
65 struct Keys
66 {
67 static constexpr std::string_view name {"Name"};
68 static constexpr std::string_view version {"Version"};
69 static constexpr std::string_view author {"Author"};
70 static constexpr std::string_view description {"Description"};
71 static constexpr std::string_view date {"Date"};
72 };
73
75 {
76 static constexpr std::string name {};
77 static constexpr std::string version {};
78 static constexpr std::string author {};
79 static constexpr std::string description {};
80 static constexpr iv::types::timestamp date {};
81 };
82};
83
85{
86 UnitData() = default;
87
88 UnitData(std::string_view product_, std::string_view firmware_, const char serialNumber_[4],
89 std::string_view pcbVersion_, iv::units::UnitLogicInfo &logic)
90 : product(product_), firmware(firmware_), pcbVersion(pcbVersion_), unitLogicInfo(logic)
91 {
92 ::strncpy(serialNumber, serialNumber_, sizeof(serialNumber));
93 }
94
95 UnitData(const UnitData &data)
96 {
97 product = data.product;
98 firmware = data.firmware;
99 ::strncpy(serialNumber, data.serialNumber, sizeof(serialNumber));
100 pcbVersion = data.pcbVersion;
102 }
103
105 {
106 if (this != &data)
107 {
108 product = data.product;
109 firmware = data.firmware;
110 std::memcpy(serialNumber, data.serialNumber, sizeof(serialNumber));
111 pcbVersion = data.pcbVersion;
113 }
114
115 return *this;
116 }
117
118 std::string product;
119 std::string firmware;
120 char serialNumber[4] {0};
121 std::string pcbVersion;
124
125private:
126 struct Sections
127 {
128 static constexpr std::string_view unitLogicInfo {"UnitLogicInfo"};
129 };
130 struct Keys
131 {
132 static constexpr std::string_view product {"Product"};
133 static constexpr std::string_view firmware {"Firmware"};
134 static constexpr std::string_view serialNumber {"SerialNumber"};
135 static constexpr std::string_view pcbVersion {"PcbVersion"};
136 };
138 {
139 static constexpr std::string product {};
140 static constexpr std::string firmware {};
141 static constexpr std::string serialNumber {};
142 static constexpr std::string pcbVersion {};
143 };
144};
145
147{
148 UnitIdAndName() : enabled(false), id(0), name()
149 {
150 }
151
154 std::string name;
155 std::string description;
156};
157
158}// namespace iv::units
159
160#endif//IV_SRC_UNITS_MODEL_STRUCTS_HPP_
Definition xmlFile.hpp:15
T getAttribute(const std::string_view key, T defaultValue) const
Definition xmlFile.hpp:33
bool addAttribute(const std::string_view key, T value)
Definition xmlFile.hpp:77
uint64_t timestamp
Definition types.hpp:21
uint16_t unitId
Definition types.hpp:77
Definition AbstractChannel.hpp:16
Definition structs.hpp:138
static constexpr std::string firmware
Definition structs.hpp:140
static constexpr std::string product
Definition structs.hpp:139
static constexpr std::string serialNumber
Definition structs.hpp:141
static constexpr std::string pcbVersion
Definition structs.hpp:142
Definition structs.hpp:131
static constexpr std::string_view serialNumber
Definition structs.hpp:134
static constexpr std::string_view product
Definition structs.hpp:132
static constexpr std::string_view firmware
Definition structs.hpp:133
static constexpr std::string_view pcbVersion
Definition structs.hpp:135
Definition structs.hpp:127
static constexpr std::string_view unitLogicInfo
Definition structs.hpp:128
Definition structs.hpp:85
char serialNumber[4]
Definition structs.hpp:120
UnitData(const UnitData &data)
Definition structs.hpp:95
UnitData(std::string_view product_, std::string_view firmware_, const char serialNumber_[4], std::string_view pcbVersion_, iv::units::UnitLogicInfo &logic)
Definition structs.hpp:88
std::string pcbVersion
Definition structs.hpp:121
iv::types::timestamp lastProjectUpdate
Definition structs.hpp:122
UnitData & operator=(const UnitData &data)
Definition structs.hpp:104
std::string firmware
Definition structs.hpp:119
std::string product
Definition structs.hpp:118
iv::units::UnitLogicInfo unitLogicInfo
Definition structs.hpp:123
Definition structs.hpp:147
iv::types::unitId id
Definition structs.hpp:153
bool enabled
Definition structs.hpp:152
std::string name
Definition structs.hpp:154
UnitIdAndName()
Definition structs.hpp:148
std::string description
Definition structs.hpp:155
static constexpr std::string name
Definition structs.hpp:76
static constexpr std::string description
Definition structs.hpp:79
static constexpr std::string version
Definition structs.hpp:77
static constexpr iv::types::timestamp date
Definition structs.hpp:80
static constexpr std::string author
Definition structs.hpp:78
Definition structs.hpp:66
static constexpr std::string_view description
Definition structs.hpp:70
static constexpr std::string_view name
Definition structs.hpp:67
static constexpr std::string_view date
Definition structs.hpp:71
static constexpr std::string_view version
Definition structs.hpp:68
static constexpr std::string_view author
Definition structs.hpp:69
Definition structs.hpp:14
UnitLogicInfo(const UnitLogicInfo &data)
Definition structs.hpp:25
bool load(const iv::file::xml::node &node)
Definition structs.hpp:36
UnitLogicInfo(std::string_view _name, std::string_view _version, std::string_view _author, std::string_view _description, iv::types::timestamp _date)
Definition structs.hpp:19
UnitLogicInfo & operator=(const UnitLogicInfo &data)=default
iv::types::timestamp date
Definition structs.hpp:62
std::string description
Definition structs.hpp:61
std::string name
Definition structs.hpp:58
std::string author
Definition structs.hpp:60
bool save(iv::file::xml::node &node) const
Definition structs.hpp:47
std::string version
Definition structs.hpp:59
UnitLogicInfo()
Definition structs.hpp:15