COMMS
Template library intended to help with implementation of communication protocols.
|
#include "comms/GenericHandler.h"
Generic common message handler.
Will define virtual message handling functions for all the messages bundled in TAll plus one to handle TDefault type of message as default behaviour. The declaration of the handling function is as following:
All the handling functions will upcast the message to TDefault and call the default message handling function with signature:
which does nothing. To override the handling behaviour just inherit your handler from comms::GenericHandler and override the appropriate function.
TDefault | Base class of all custom messages bundled in TAll. |
TAll | All message types bundled in std::tuple that need to be handled. |
TRetType | Return type of the implemented handle() functions. |
Public Types | |
using | RetType = TRetType |
Return type of every handle() member function. | |
Public Member Functions | |
virtual TRetType | handle (TDefault &msg) |
Handle message object. | |
Protected Member Functions | |
~GenericHandler () noexcept=default | |
Destructor. | |
|
protecteddefaultnoexcept |
Destructor.
Although there are virtual functions, the destructor is NOT virtual. The protected destructor prevents typedef of GenericHandler and use it as actual handler class. To allow polymorphic delete (destruction) make sure to declare the inherited destructor as virtual.
|
virtual |
Handle message object.
Does nothing, can be overridden in the derived class.