14 if (count == 0 || _currentElements == 0 || start > _currentElements || count > _currentElements - start + 1)
34 if (count == 1 &&
data[0] == 0 &&
data[1] == 0)
54 if (start + count > _currentElements)
57 uint8_t* oldData = _data;
58 size_t oldDataSize = _currentElements *
ElementSize();
60 size_t newDataSize = (start + count) *
ElementSize();
61 _data =
new uint8_t[newDataSize];
62 memset(_data, 0, newDataSize);
64 if (oldData !=
nullptr)
66 memcpy(_data, oldData, oldDataSize);
70 _currentElements = start + count;
79 uint16_t maxElements, uint8_t access)
80 :
Property(id, writeEnable, type, maxElements, access)
90 uint16_t maxElements, uint8_t access, uint16_t value)
91 :
Property(id, writeEnable, type, maxElements, access)
97 uint16_t maxElements, uint8_t access, uint32_t value)
98 :
Property(id, writeEnable, type, maxElements, access)
104 uint16_t maxElements, uint8_t access, uint8_t value)
105 :
Property(id, writeEnable, type, maxElements, access)
111 uint16_t maxElements, uint8_t access,
const uint8_t* value)
112 :
Property(id, writeEnable, type, maxElements, access)
125 uint16_t elements = 0;
126 buffer =
popWord(elements, buffer);
128 if (elements != _currentElements)
130 if (_data !=
nullptr)
134 _currentElements = elements;
146 buffer =
pushWord(_currentElements, buffer);
148 if (_currentElements > 0)
162 if ((elementIndex == 0) || (elementIndex > _currentElements))
167 return _data + offset;
uint8_t * pushByteArray(const uint8_t *src, uint32_t size, uint8_t *data)
const uint8_t * popByteArray(uint8_t *dst, uint32_t size, const uint8_t *data)
uint8_t * pushWord(uint16_t w, uint8_t *data)
const uint8_t * popWord(uint16_t &w, const uint8_t *data)
uint16_t saveSize() override
uint8_t * save(uint8_t *buffer) override
This method is called when the object should save its state to the buffer.
uint8_t write(uint16_t start, uint8_t count, const uint8_t *data) override
DataProperty(PropertyID id, bool writeEnable, PropertyDataType type, uint16_t maxElements, uint8_t access)
const uint8_t * restore(const uint8_t *buffer) override
This method is called when the object should restore its state from the buffer.
uint8_t read(uint16_t start, uint8_t count, uint8_t *data) const override
uint8_t ElementSize() const
virtual uint8_t write(uint16_t start, uint8_t count, const uint8_t *data)=0
PropertyDataType
The data type of a property.