COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
comms::GenericHandler< TDefault, TAll, TRetType > Class Template Reference

#include "comms/GenericHandler.h"

Detailed Description

template<typename TDefault, typename TAll, typename TRetType = void>
class comms::GenericHandler< TDefault, TAll, TRetType >

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:

virtual TRetType handle(ActualMessageType& msg);
virtual TRetType handle(TDefault &msg)
Handle message object.

All the handling functions will upcast the message to TDefault and call the default message handling function with signature:

virtual TRetType handle(TDefault& msg);

which does nothing. To override the handling behaviour just inherit your handler from comms::GenericHandler and override the appropriate function.

Template Parameters
TDefaultBase class of all custom messages bundled in TAll.
TAllAll message types bundled in std::tuple that need to be handled.
TRetTypeReturn type of the implemented handle() functions.
Precondition
TAll is any variation of std::tuple
TDefault is a base class for all the custom messages in TAll.
Note
The default destructor is NOT virtual. To allow polymorphic delete make sure to declare the destructor virtual in the inherited class.

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.
 

Constructor & Destructor Documentation

◆ ~GenericHandler()

template<typename TDefault , typename TAll , typename TRetType = void>
comms::GenericHandler< TDefault, TAll, TRetType >::~GenericHandler ( )
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.

Member Function Documentation

◆ handle()

template<typename TDefault , typename TAll , typename TRetType = void>
virtual TRetType comms::GenericHandler< TDefault, TAll, TRetType >::handle ( TDefault &  msg)
virtual

Handle message object.

Does nothing, can be overridden in the derived class.


The documentation for this class was generated from the following file: