Working With Fields
In order to automate some basic operations, all the fields had to provide the same basic interface. As the result the actual field values had to be wrapped in a class that defines the required public interface. Such class must also provide means to access/update the wrapped value. For example:
class SomeField
{
public:
// Value storage type definition
using ValueType = ...;
// Provide an access to the stored value
ValueType& value() { return m_value; }
const ValueType& value() const { return m_value; }
...
private:
ValueType m_value;
}Let's assume the ActualMessage1 defines 3 integer value fields with serialisation lengths of 1, 2, and 4 bytes respectively.
using ActualMessage1Fields = std::tuple<
IntValueField<std::int8_t>,
IntValueField<std::int16_t>
IntValueField<std::int32_t>
>;
class ActualMessage1 : public MessageBase<ActualMessage1Fields> {...};The Dispatching and Handling chapter described the efficient way to dispatch message object to its handler. The appropriate handling function may access its field's value using the following code flow:
When preparing message to send, the similar code sequence may be applied to update the values:
Last updated
Was this helpful?