COMMS
Template library intended to help with implementation of communication protocols.
|
#include "comms/protocol/MsgSizeLayer.h"
Protocol layer that uses size field as a prefix to all the subsequent data written by other (next) layers.
The main purpose of this layer is to provide information about the remaining size of the serialised message. This layer is a mid level layer, expects other mid level layer or MsgDataLayer to be its next one.
TField | Type of the field that describes the "size" field. |
TNextLayer | Next transport layer in protocol stack. |
TOptions | Default functionality extension options. Supported options are:
|
Public Types | |
using | AllFields = typename std::decay< decltype(std::tuple_cat(std::declval< std::tuple< Field > >(), std::declval< typename TNextLayer::AllFields >())) >::type |
Type of all the fields of all the transport layers wrapped in std::tuple. | |
using | AllMessages = typename NextLayer::AllMessages |
All supported messages. | |
using | ExtendingClass = typename ParsedOptionsInternal::ExtendingClass |
Type of real extending class. | |
using | Field = typename BaseImpl::Field |
Type of the field object used to read/write remaining size value. | |
using | MsgFactory = typename NextLayer::MsgFactory |
Type of message factory. | |
using | MsgPtr = typename details::ProtocolLayerMsgPtr< NextLayer >::Type |
Type of pointer to the message. | |
using | NextLayer = TNextLayer |
Type of the next transport layer. | |
using | ParsedOptions = details::ProtocolLayerBaseOptionsParser< TOptions... > |
Parsed options structure. | |
using | ThisLayer = TDerived |
Actual derived class. | |
Public Member Functions | |
MsgSizeLayer ()=default | |
Default constructor. | |
MsgSizeLayer (const MsgSizeLayer &)=default | |
Copy constructor. | |
MsgSizeLayer (MsgSizeLayer &&)=default | |
Move constructor. | |
~MsgSizeLayer () noexcept=default | |
Destructor. | |
template<typename TId > | |
MsgPtr | createMsg (TId &&id, unsigned idx=0) |
Create message object given the ID. | |
template<typename TMsg , typename TIter , typename TNextLayerReader , typename... TExtraValues> | |
comms::ErrorStatus | doRead (Field &field, TMsg &msg, TIter &iter, std::size_t size, TNextLayerReader &&nextLayerReader, TExtraValues... extraValues) |
Customized read functionality, invoked by read(). | |
template<typename TMsg , typename TIter , typename TNextLayerUpdater > | |
comms::ErrorStatus | doUpdate (const TMsg &msg, Field &field, TIter &iter, std::size_t size, TNextLayerUpdater &&nextLayerUpdater) const |
Customized update functionality, invoked by update(). | |
template<typename TIter , typename TNextLayerUpdater > | |
comms::ErrorStatus | doUpdate (Field &field, TIter &iter, std::size_t size, TNextLayerUpdater &&nextLayerUpdater) const |
Customized update functionality, invoked by update(). | |
template<typename TMsg , typename TIter , typename TNextLayerWriter > | |
ErrorStatus | doWrite (Field &field, const TMsg &msg, TIter &iter, std::size_t size, TNextLayerWriter &&nextLayerWriter) const |
Customized write functionality, invoked by write(). | |
constexpr std::size_t | length () const |
Get remaining length of wrapping transport information. | |
template<typename TMsg > | |
constexpr std::size_t | length (const TMsg &msg) const |
Get remaining length of wrapping transport information + length of the provided message. | |
NextLayer & | nextLayer () |
Get access to the next layer object. | |
const NextLayer & | nextLayer () const |
Get "const" access to the next layer object. | |
MsgSizeLayer & | operator= (const MsgSizeLayer &)=default |
Copy assignment. | |
MsgSizeLayer & | operator= (MsgSizeLayer &&)=default |
Move assignment. | |
template<typename TMsg , typename TIter , typename... TExtraValues> | |
comms::ErrorStatus | read (TMsg &msg, TIter &iter, std::size_t size, TExtraValues... extraValues) |
Deserialise message from the input data sequence. | |
template<typename TAllFields , typename TMsg , typename TIter , typename... TExtraValues> | |
comms::ErrorStatus | readFieldsCached (TAllFields &allFields, TMsg &msg, TIter &iter, std::size_t size, TExtraValues... extraValues) |
Deserialise message from the input data sequence while caching the read transport information fields. | |
template<typename TMsg , typename TIter , typename... TExtraValues> | |
comms::ErrorStatus | readFromData (TMsg &msg, TIter &iter, std::size_t size, TExtraValues... extraValues) |
Finalise the read operation by reading the message payload. | |
template<typename TAllFields , typename TMsg , typename TIter , typename... TExtraValues> | |
comms::ErrorStatus | readFromDataFieldsCached (TAllFields &allFields, TMsg &msg, TIter &iter, std::size_t size, TExtraValues... extraValues) |
Finalise the read operation by reading the message payload while caching the read transport information fields. | |
template<typename TMsg , typename TIter , typename... TExtraValues> | |
comms::ErrorStatus | readUntilData (TMsg &msg, TIter &iter, std::size_t size, TExtraValues... extraValues) |
Perform read of data fields until data layer (message payload). | |
template<typename TAllFields , typename TMsg , typename TIter , typename... TExtraValues> | |
comms::ErrorStatus | readUntilDataFieldsCached (TAllFields &allFields, TMsg &msg, TIter &iter, std::size_t size, TExtraValues... extraValues) |
Perform read of data fields until data layer (message payload) while caching the read transport information fields. | |
ThisLayer & | thisLayer () |
Get access to this layer object. | |
const ThisLayer & | thisLayer () const |
Get "const" access to this layer object. | |
template<typename TMsg , typename TIter > | |
comms::ErrorStatus | update (const TMsg &msg, TIter &iter, std::size_t size) const |
Update recently written (using write()) message contents data. | |
template<typename TIter > | |
comms::ErrorStatus | update (TIter &iter, std::size_t size) const |
Update recently written (using write()) message contents data. | |
template<typename TAllFields , typename TMsg , typename TIter > | |
ErrorStatus | updateFieldsCached (TAllFields &allFields, const TMsg &msg, TIter &iter, std::size_t size) const |
Update recently written (using writeFieldsCached()) message data as well as cached transport information fields. | |
template<typename TAllFields , typename TIter > | |
ErrorStatus | updateFieldsCached (TAllFields &allFields, TIter &iter, std::size_t size) const |
Update recently written (using writeFieldsCached()) message data as well as cached transport information fields. | |
template<typename TMsg , typename TIter > | |
comms::ErrorStatus | write (const TMsg &msg, TIter &iter, std::size_t size) const |
Serialise message into output data sequence. | |
template<typename TAllFields , typename TMsg , typename TIter > | |
comms::ErrorStatus | writeFieldsCached (TAllFields &allFields, const TMsg &msg, TIter &iter, std::size_t size) const |
Serialise message into output data sequence while caching the written transport information fields. | |
Static Public Member Functions | |
template<typename TAllFields > | |
static auto | accessCachedField (TAllFields &allFields) -> decltype(std::get< std::tuple_size< typename std::decay< TAllFields >::type >::value - std::tuple_size< AllFields >::value >(allFields)) |
Access appropriate field from "cached" bundle of all the protocol stack fields. | |
static constexpr bool | canSplitRead () |
Compile time check whether split read "until" and "from" data layer is allowed. | |
static constexpr std::size_t | doFieldLength () |
Default implementation of field length retrieval. | |
template<typename TMsg > | |
static constexpr std::size_t | doFieldLength (const TMsg &) |
Default implementation of field length retrieval when message is known. | |
static constexpr bool | hasExtendingClass () |
Compile time inquiry of whether this class was extended via comms::option::ExtendingClass option. | |
Static Public Attributes | |
static const std::size_t | NumOfLayers = 1 + NextLayer::NumOfLayers |
Static constant indicating amount of transport layers used. | |
Protected Member Functions | |
template<typename... TExtraValues> | |
void | setMissingSize (std::size_t val, TExtraValues... extraValues) const |
Set the missing size information if such is requested. | |
template<typename TId , typename... TExtraValues> | |
void | setMsgId (TId val, TExtraValues... extraValues) const |
Set the message ID information if such is requested. | |
template<typename... TExtraValues> | |
void | setMsgIndex (std::size_t val, TExtraValues... extraValues) const |
Set the message index information if such is requested. | |
template<typename... TExtraValues> | |
void | updateMissingSize (const Field &field, std::size_t size, TExtraValues... extraValues) const |
Update the missing size information if such is requested. | |
template<typename... TExtraValues> | |
void | updateMissingSize (std::size_t size, TExtraValues... extraValues) const |
Update the missing size information if such is requested. | |
Static Protected Member Functions | |
template<typename TMsg > | |
static void | beforeRead (const Field &field, TMsg *msg) |
Extra operation before read is forwarded to the next layer. | |
template<typename TMsg , typename TIter > | |
static comms::ErrorStatus | doReadField (const TMsg *msgPtr, Field &field, TIter &iter, std::size_t len) |
Read the layer field. | |
template<typename TMsg , typename TIter > | |
static comms::ErrorStatus | doWriteField (const TMsg *msgPtr, const Field &field, TIter &iter, std::size_t len) |
Write the layer field. | |
template<std::size_t TIdx, typename TAllFields > | |
static Field & | getField (TAllFields &allFields) |
Retrieve reference to a layer specific field out of all fields. | |
static std::size_t | getRemainingSizeFromField (const Field &field) |
Retrieve remaining size (length) from the field. | |
template<typename T > | |
static constexpr bool | isMessageObjRef () |
Detect whether type is actual message object. | |
template<typename TMsg > | |
static void | prepareFieldForWrite (std::size_t size, const TMsg *msg, Field &field) |
Prepare field for writing. | |
template<typename TMsg > | |
static void | resetMsg (TMsg &msg) |
Reset msg in case it is a smart pointer (MsgPtr). | |
template<typename TMsg > | |
static auto | toMsgPtr (TMsg &msg) -> decltype(toMsgPtrInternal(msg, MsgTypeTag< typename std::decay< decltype(msg)>::type >())) |
Get a pointer to the message object. | |
Related Symbols | |
(Note that these are not member symbols.) | |
#define | COMMS_PROTOCOL_LAYERS_ACCESS(...) COMMS_DO_ACCESS_LAYER_ACC_FUNC(__VA_ARGS__) |
Provide convenience access functions to protocol layers. | |
#define | COMMS_PROTOCOL_LAYERS_ACCESS_INNER(...) COMMS_PROTOCOL_LAYERS_ACCESS(__VA_ARGS__) |
Same as COMMS_PROTOCOL_LAYERS_ACCESS() | |
#define | COMMS_PROTOCOL_LAYERS_ACCESS_OUTER(...) COMMS_PROTOCOL_LAYERS_ACCESS(COMMS_EXPAND(COMMS_REVERSE_MACRO_ARGS(__VA_ARGS__))) |
Provide convenience access functions to protocol layers. | |
#define | COMMS_PROTOCOL_LAYERS_NAMES(...) |
Provide names and convenience access functions to protocol layers. | |
#define | COMMS_PROTOCOL_LAYERS_NAMES_INNER(...) COMMS_PROTOCOL_LAYERS_NAMES(__VA_ARGS__) |
Same as COMMS_PROTOCOL_LAYERS_NAMES() | |
#define | COMMS_PROTOCOL_LAYERS_NAMES_OUTER(...) COMMS_PROTOCOL_LAYERS_NAMES(COMMS_EXPAND(COMMS_REVERSE_MACRO_ARGS(__VA_ARGS__))) |
Provide names and convenience access functions to protocol layers. | |
template<typename T > | |
constexpr bool | isMsgSizeLayer () |
Compile time check of whether the provided type is a variant of MsgSizeLayer. | |
|
inherited |
|
inherited |
All supported messages.
Same as NextLayer::AllMessages or void if such doesn't exist. Expected to be overrided by comms::protocol::MsgIdLayer
using comms::protocol::MsgSizeLayer< TField, TNextLayer, TOptions >::ExtendingClass = typename ParsedOptionsInternal::ExtendingClass |
Type of real extending class.
Updated when comms::option::ExtendingClass extension option us used, aliasing void if the options is not used.
|
inherited |
Type of message factory.
Same as NextLayer::AllMessages or void if such doesn't exist. Expected to be overrided by comms::protocol::MsgIdLayer
|
inherited |
Type of pointer to the message.
Same as NextLayer::MsgPtr or void if such doesn't exist.
|
staticinherited |
Access appropriate field from "cached" bundle of all the protocol stack fields.
allFields | All fields of the protocol stack |
|
staticprotected |
Extra operation before read is forwarded to the next layer.
Default implementation does nothing, may be overriden in the derived class.
[in] | field | Field of the layer that was successfully read. |
[in,out] | msg | Pointer to message object, either interface class or message object itself (depending on how doRead() was invoked). Can be nullptr in case message object hasn't been created yet |
|
inherited |
Create message object given the ID.
The default implementation is to forwards this call to the next layer. One of the layers (usually comms::protocol::MsgIdLayer) hides and overrides this implementation.
TMsg | Type of message ID. |
id | ID of the message. |
idx | Relative index of the message with the same ID. |
|
staticconstexprinherited |
Default implementation of field length retrieval.
Default implementation returns
|
staticconstexprinherited |
Default implementation of field length retrieval when message is known.
Default implementation returns
comms::ErrorStatus comms::protocol::MsgSizeLayer< TField, TNextLayer, TOptions >::doRead | ( | Field & | field, |
TMsg & | msg, | ||
TIter & | iter, | ||
std::size_t | size, | ||
TNextLayerReader && | nextLayerReader, | ||
TExtraValues... | extraValues | ||
) |
Customized read functionality, invoked by read().
Reads size of the subsequent data from the input data sequence and calls read() member function of the next layer with the size specified in the size field. The function will also compare the provided size of the data with value read from the buffer. If the latter is greater than former, comms::ErrorStatus::NotEnoughData will be returned. However, if buffer contains enough data, but the next layer reports it's not enough (returns comms::ErrorStatus::NotEnoughData), comms::ErrorStatus::ProtocolError will be returned.
TMsg | Type of msg parameter. |
TIter | Type of iterator used for reading. |
TNextLayerReader | next layer reader object type. |
[out] | field | Field object to read. |
[in,out] | msg | Reference to smart pointer, that already holds or will hold allocated message object, or reference to actual message object (which extends comms::MessageBase). |
[in,out] | iter | Input iterator used for reading. |
[in] | size | Size of the data in the sequence |
[in] | nextLayerReader | Reader object, needs to be invoked to forward read operation to the next layer. |
[out] | extraValues | Variadic extra output parameters passed to the "read" operatation of the protocol stack (see read() and readFieldsCached()). Need to passed on as variadic arguments to the nextLayerReader. |
|
staticprotectedinherited |
Read the layer field.
The default implementation invokes read() operation of the passed field object. The function can be overriden by the extending class.
[in] | msgPtr | Pointer to message object (if available), can be nullptr. |
[out] | field | Field object value of which needs to be populated |
[in,out] | iter | Iterator used for reading, expected to be advanced |
[in] | len | Length of the input buffer |
comms::ErrorStatus comms::protocol::MsgSizeLayer< TField, TNextLayer, TOptions >::doUpdate | ( | const TMsg & | msg, |
Field & | field, | ||
TIter & | iter, | ||
std::size_t | size, | ||
TNextLayerUpdater && | nextLayerUpdater | ||
) | const |
Customized update functionality, invoked by update().
Similar to other doUpdate(), but receiving reference to valid message object.
[in] | msg | Reference to valid message object. |
[out] | field | Field object to update. |
[in,out] | iter | Any random access iterator. |
[in] | size | Number of bytes that have been written using write(). |
[in] | nextLayerUpdater | Next layer updater object. |
comms::ErrorStatus comms::protocol::MsgSizeLayer< TField, TNextLayer, TOptions >::doUpdate | ( | Field & | field, |
TIter & | iter, | ||
std::size_t | size, | ||
TNextLayerUpdater && | nextLayerUpdater | ||
) | const |
Customized update functionality, invoked by update().
Should be called when doWrite() returns comms::ErrorStatus::UpdateRequired.
TIter | Type of iterator used for updating. |
TNextLayerWriter | next layer updater object type. |
[out] | field | Field object to update. |
[in,out] | iter | Any random access iterator. |
[in] | size | Number of bytes that have been written using write(). |
[in] | nextLayerUpdater | Next layer updater object. |
ErrorStatus comms::protocol::MsgSizeLayer< TField, TNextLayer, TOptions >::doWrite | ( | Field & | field, |
const TMsg & | msg, | ||
TIter & | iter, | ||
std::size_t | size, | ||
TNextLayerWriter && | nextLayerWriter | ||
) | const |
Customized write functionality, invoked by write().
The function will write number of bytes required to serialise the message, then invoke the write() member function of the next layer. The calculation of the required length is performed by invoking "length(msg)".
TMsg | Type of message object. |
TIter | Type of iterator used for writing. |
TNextLayerWriter | next layer writer object type. |
[out] | field | Field object to update and write. |
[in] | msg | Reference to message object |
[in,out] | iter | Output iterator. |
[in] | size | Max number of bytes that can be written. |
[in] | nextLayerWriter | Next layer writer object. |
|
staticprotectedinherited |
Write the layer field.
The default implementation invokes write() operation of the passed field object. The function can be overriden by the extending class.
[in] | msgPtr | Pointer to message object (if available), can be nullptr. |
[out] | field | Field object value of which needs to be written |
[in,out] | iter | Iterator used for writing, expected to be advanced |
[in] | len | Length of the output buffer |
|
staticprotectedinherited |
Retrieve reference to a layer specific field out of all fields.
TIdx | Index of the field in tuple |
|
staticprotected |
Retrieve remaining size (length) from the field.
May be overridden by the extending class
[in] | field | Field for this layer. |
|
staticconstexpr |
Compile time inquiry of whether this class was extended via comms::option::ExtendingClass option.
If true is returned, the ExtendingClass type aliasing the real layer type.
|
staticconstexprprotectedinherited |
Detect whether type is actual message object.
T | Type of the object |
|
constexprinherited |
Get remaining length of wrapping transport information.
The message data always get wrapped with transport information to be successfully delivered to and unpacked on the other side. This function return remaining length of the transport information. It performs a call to doFieldLength() member function to get info about current field length. To update the default behaviour just override the function in the derived class.
|
constexprinherited |
Get remaining length of wrapping transport information + length of the provided message.
This function usually gets called when there is a need to identify the size of the buffer required to write provided message wrapped in the transport information. This function is very similar to length(), but adds also length of the message. It performs a call to doFieldLength() member function with message parameter to get info about current field length. To update the default behaviour just override the function in the derived class.
TMsg | Type of message object. |
[in] | msg | Message object |
|
staticprotected |
Prepare field for writing.
Must assign provided size (length) value. May be overridden by the extending class if some complex functionality is required.
[in] | size | Size value to assign |
[in] | msg | Pointer to message object being written, may be nullptr (in case invoked from doUpdate()) |
[out] | field | Field, value of which needs to be populated |
|
inherited |
Deserialise message from the input data sequence.
The function will invoke doRead() member function provided by the derived class, which must have the following signature and logic:
The signature of the nextLayerReader.read() function is the same as the signature of this read() member function. The implemented doRead() member function also may use the following inherited protected member to set values of variadic parameters in case they are provided.
TMsg | Type of msg parameter |
TIter | Type of iterator used for reading. |
[in,out] | msg | Reference to smart pointer, that already holds or will hold allocated message object, or reference to actual message object (which extends comms::MessageBase). |
[in,out] | iter | Input iterator used for reading. |
[in] | size | Size of the data in the sequence |
[out] | extraValues | Extra output parameters provided using one of the following functions: comms::protocol::missingSize(), comms::protocol::msgId(), comms::protocol::msgIndex(), comms::protocol::msgPayload(). |
|
inherited |
Deserialise message from the input data sequence while caching the read transport information fields.
Very similar to read() member function, but adds "allFields" parameter to store read transport information fields. The function will also invoke the same doRead() member function provided by the derived class, as described with read().
TAllFields | std::tuple of all the transport fields, must be AllFields type defined in the last layer class that defines protocol stack. |
TMsg | Type of msg parameter. |
TIter | Type of iterator used for reading. |
[out] | allFields | Reference to the std::tuple object that wraps all transport fields (AllFields type of the last protocol layer class). |
[in,out] | msg | Reference to smart pointer, that already holds or will hold allocated message object, or reference to actual message object (which extends comms::MessageBase). |
[in,out] | iter | Iterator used for reading. |
[in] | size | Number of bytes available for reading. |
[out] | extraValues | Extra output parameters provided using one of the following functions |
|
inherited |
Finalise the read operation by reading the message payload.
Should be called to finalise the read operation started by readUntilData().
TMsg | Type of msg parameter |
TIter | Type of iterator used for reading. |
[in,out] | msg | Reference to smart pointer, that already holds or will hold allocated message object, or reference to actual message object (which extends comms::MessageBase). |
[in,out] | iter | Input iterator used for reading. |
[in] | size | Size of the data in the sequence |
[out] | extraValues | Extra output parameters provided using one of the following functions |
|
inherited |
Finalise the read operation by reading the message payload while caching the read transport information fields.
Should be called to finalise the read operation started by readUntilDataFieldsCached().
TAllFields | std::tuple of all the transport fields, must be AllFields type defined in the last layer class that defines protocol stack. |
TMsg | Type of msg parameter |
TIter | Type of iterator used for reading. |
[out] | allFields | Reference to the std::tuple object that wraps all transport fields (AllFields type of the last protocol layer class). |
[in,out] | msg | Reference to smart pointer, that already holds or will hold allocated message object, or reference to actual message object (which extends comms::MessageBase). |
[in,out] | iter | Iterator used for reading. |
[in] | size | Number of bytes available for reading. |
[out] | extraValues | Extra output parameters provided using one of the following functions |
|
inherited |
Perform read of data fields until data layer (message payload).
Same as read by stops read operation when data layer is reached. Expected to be followed by a call to readFromData().
TMsg | Type of msg parameter. |
TIter | Type of iterator used for reading. |
[in,out] | msg | Reference to smart pointer, that already holds or will hold allocated message object, or reference to actual message object (which extends comms::MessageBase). |
[in,out] | iter | Input iterator used for reading. |
[in] | size | Size of the data in the sequence |
[out] | extraValues | Extra output parameters provided using one of the following functions |
|
inherited |
Perform read of data fields until data layer (message payload) while caching the read transport information fields.
Very similar to readUntilData() member function, but adds "allFields" parameter to store read transport information fields. The function will also invoke the same doRead() member function provided by the derived class, as described with read().
TAllFields | std::tuple of all the transport fields, must be AllFields type defined in the last layer class that defines protocol stack. |
TMsg | Type of msg parameter |
TIter | Type of iterator used for reading. |
[out] | allFields | Reference to the std::tuple object that wraps all transport fields (AllFields type of the last protocol layer class). |
[in,out] | msg | Reference to smart pointer, that already holds or will hold allocated message object, or reference to actual message object (which extends comms::MessageBase). |
[in,out] | iter | Iterator used for reading. |
[in] | size | Number of bytes available for reading. |
[out] | extraValues | Extra output parameters provided using one of the following functions |
|
staticprotectedinherited |
Reset msg in case it is a smart pointer (MsgPtr).
Does nothing if passed parameter is actual message object.
|
protectedinherited |
Set the missing size information if such is requested.
Updates the value reference to which was passed to the "read" operation using comms::protocol::missingSize().
[in] | val | Value to assign. |
[out] | extraValues | Variadic parameters passed to the "read" function such as read() or readFieldsCached() |
|
protectedinherited |
Set the message ID information if such is requested.
Updates the value reference to which was passed to the "read" operation using comms::protocol::msgId().
[in] | val | Value to assign. |
[out] | extraValues | Variadic parameters passed to the "read" function such as read() or readFieldsCached() |
|
protectedinherited |
Set the message index information if such is requested.
Updates the value reference to which was passed to the "read" operation using comms::protocol::msgIndex().
[in] | val | Value to assign. |
[out] | extraValues | Variadic parameters passed to the "read" function such as read() or readFieldsCached() |
|
staticprotectedinherited |
Get a pointer to the message object.
The function works seamlessly for both smart pointer and reference to the real object
|
inherited |
Update recently written (using write()) message contents data.
Similar to other update() but also receiving recently written message object.
[in] | msg | Reference to message object. |
[in,out] | iter | Any random access iterator. |
[in] | size | Number of bytes that have been written using write(). |
|
inherited |
Update recently written (using write()) message contents data.
Sometimes, when NON random access iterator is used for writing (for example std::back_insert_iterator), some transport data cannot be properly written. In this case, write() function will return comms::ErrorStatus::UpdateRequired. When such status is returned it is necessary to call update() with random access iterator on the written buffer to update written dummy information with proper values.
The function will invoke doUpdate() member function provided (or inherited) by the derived class, which must have the following signature and logic:
The signature of the nextLayerUpdater.update() function is the same as the signature of this update() member function.
[in,out] | iter | Any random access iterator. |
[in] | size | Number of bytes that have been written using write(). |
|
inherited |
Update recently written (using writeFieldsCached()) message data as well as cached transport information fields.
Very similar to other updateFieldsCached() member function, but adds "msg" parameter to access message object if needed.
The function will also invoke the same doUpdate() member function provided by the derived class, as described with write().
TAllFields | std::tuple of all the transport fields, must be AllFields type defined in the last layer class that defines protocol stack. |
TMsg | Type of msg parameter. |
TIter | Type of the random access iterator. |
[out] | allFields | Reference to the std::tuple object that wraps all transport fields (AllFields type of the last protocol layer class). |
[in] | msg | Reference to recently written message object. |
[in,out] | iter | Random access iterator to the written data. |
[in] | size | Number of bytes that have been written using writeFieldsCached(). |
|
inherited |
Update recently written (using writeFieldsCached()) message data as well as cached transport information fields.
Very similar to update() member function, but adds "allFields" parameter to store raw data of the message.
The function will also invoke the same doUpdate() member function provided by the derived class, as described with write().
TAllFields | std::tuple of all the transport fields, must be AllFields type defined in the last layer class that defines protocol stack. |
TIter | Type of the random access iterator. |
[out] | allFields | Reference to the std::tuple object that wraps all transport fields (AllFields type of the last protocol layer class). |
[in,out] | iter | Random access iterator to the written data. |
[in] | size | Number of bytes that have been written using writeFieldsCached(). |
|
protectedinherited |
Update the missing size information if such is requested.
Calculates the minimal required length to be yet read. Updates the value reference to which was passed to the "read" operation using comms::protocol::missingSize().
[in] | field | Field read operation of which has failed. |
[in] | size | Remaining number of bytes in the input buffer. |
[out] | extraValues | Variadic parameters passed to the "read" function such as read() or readFieldsCached() |
|
protectedinherited |
Update the missing size information if such is requested.
Calculates the minimal required length to be yet read. Updates the value reference to which was passed to the "read" operation using comms::protocol::missingSize().
[in] | size | Remaining number of bytes in the input buffer. |
[out] | extraValues | Variadic parameters passed to the "read" function such as read() or readFieldsCached() |
|
inherited |
Serialise message into output data sequence.
The function will invoke doWrite() member function provided by the derived class, which must have the following signature and logic:
The signature of the nextLayerWriter.write() function is the same as the signature of this write() member function.
TMsg | Type of the message being written. |
TIter | Type of iterator used for writing. |
[in] | msg | Reference to message object |
[in,out] | iter | Output iterator used for writing. |
[in] | size | Max number of bytes that can be written. |
|
inherited |
Serialise message into output data sequence while caching the written transport information fields.
Very similar to write() member function, but adds "allFields" parameter to store raw data of the message. The function will also invoke the same doWrite() member function provided by the derived class, as described with write().
TAllFields | std::tuple of all the transport fields, must be AllFields type defined in the last layer class that defines protocol stack. |
TMsg | Type of the message being written. |
TIter | Type of iterator used for writing. |
[out] | allFields | Reference to the std::tuple object that wraps all transport fields (AllFields type of the last protocol layer class). |
[in] | msg | Reference to the message object that is being written, |
[in,out] | iter | Iterator used for writing. |
[in] | size | Max number of bytes that can be written. |
|
related |
Provide convenience access functions to protocol layers.
The first argument is a name for innermost layer (comms::protocol::MsgDataLayer), while the last one is the name for the outermost one.
|
related |
Provide convenience access functions to protocol layers.
Similar to COMMS_PROTOCOL_LAYERS_ACCESS(), but the arguments are expected to be in reverse order, i.e. the first argument is the name of the outermost layer, while the last one is the name for the innermost one (comms::protocol::MsgDataLayer)
|
related |
Provide names and convenience access functions to protocol layers.
Similar to COMMS_PROTOCOL_LAYERS_ACCESS() but defines "Layer_<name>" type names.
|
related |
Provide names and convenience access functions to protocol layers.
Similar to COMMS_PROTOCOL_LAYERS_ACCESS_OUTER() but defines "Layer_<name>" type names.