Fw::Buffer::getSerializeRepr currently returns a reference into a serialize buffer stored as a member of Fw::Buffer. There are some issues with this:
When you call getSerializeRepr, you're not sure what state the serialize buffer is in. It depends on what has previously been done with the buffer.
The serialize representation state is reset when the buffer object is serialized and deserialized but otherwise persists. This could be an unexpected behavior.
Performing deserialize operations on the buffer updates the serialize buffer and therefore updates the Fw::Buffer. It would be better for theFw::Buffer to be read-only in this case.
Instead we could have getSerializeRepr return an object, say Fw::ExternalSerializeBufferWithMemberCopy. That way the user would own the serialize representation, and it could be freshly initialized each time it is requested. An argument to getSerializeRepr could specify whether the representation is for serialization (in which case the internal serial pointer should be set to zero) or deserialization (in which case the internal serial pointer should be set to the end of the data). Access to the buffer for deserialization would be read-only.
Fw::Buffer::getSerializeRepr
currently returns a reference into a serialize buffer stored as a member ofFw::Buffer
. There are some issues with this:getSerializeRepr
, you're not sure what state the serialize buffer is in. It depends on what has previously been done with the buffer.Fw::Buffer
. It would be better for theFw::Buffer
to be read-only in this case.Instead we could have
getSerializeRepr
return an object, sayFw::ExternalSerializeBufferWithMemberCopy
. That way the user would own the serialize representation, and it could be freshly initialized each time it is requested. An argument togetSerializeRepr
could specify whether the representation is for serialization (in which case the internal serial pointer should be set to zero) or deserialization (in which case the internal serial pointer should be set to the end of the data). Access to the buffer for deserialization would be read-only.