1、数据类型定义:
{
enum class ValueType
{
Float,
Integer
};
union Value
{
float fValue;
int32_t iValue;
};
class Item {
public:
Item(int32_t address, ValueType type, Value value, std::time_t ts)
: _address(address), _valueType(type), _value(value), _timestamp(ts)
{}
[[nodiscard]] const int32_t & address() const {
return _address;
}
[[nodiscard]] const ValueType & type() const {
return _valueType;
}
[[nodiscard]] const Value & value() const {
return _value;
}
[[nodiscard]] const std::time_t & timestamp() const {
return _timestamp;
}
private:
int32_t _address;
ValueType _valueType;
Value _value;
std::time_t _timestamp;
};
using ItemList = std::vector<Item>;
}
2、