cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | List of all members
cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg > Class Template Referenceabstract

#include "cc_tools_qt/ProtocolBase.h"

Detailed Description

template<typename TProtStack, typename TTransportMsg, typename TRawDataMsg = RawDataMessage<TProtStack>>
class cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >

Helper class to define custom Protocol.

Provides the default implementation to most of the virtual functions defined by Protocol class.

Template Parameters
TProtStackDefinition of the protocol stack.
TTransportMsgDefinition of the "Transport Message".
TRawDataMsgDefinition of the "Raw Data Message", defaults to RawDataMessage
Inheritance diagram for cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >:
cc_tools_qt::Protocol

Public Types

using DataInfosList = std::list< DataInfoPtr >
 List of raw data buffers.
 
using ErrorReportCallback = std::function< void(const QString &msg)>
 Type of callback to report errors.
 
using InterPluginConfigReportCallback = std::function< void(const QVariantMap &)>
 Callback to report inter-plugin configuration updates.
 
using MessagesList = std::list< MessagePtr >
 List of messages.
 
using MsgDataSeq = Message::DataSeq
 Type used to contain raw bytes seqence.
 
using SendMessageRequestCallback = std::function< void(MessagePtr)>
 Type of callback to request message being sent initiated by the plugin itself.
 
enum class  UpdateStatus { NoChange , Changed }
 Status of message "update" operation. More...
 

Public Member Functions

void applyInterPluginConfig (const QVariantMap &props)
 Apply inter-plugin configuration.
 
MessagePtr cloneMessage (const Message &msg)
 Clone the message object.
 
MessagesList createAllMessages ()
 Create all messages supported by the protocol.
 
MessagePtr createInvalidMessage (const MsgDataSeq &data)
 Create dummy message containing invalid input.
 
MessagePtr createMessage (const QString &idAsString, unsigned idx=0)
 Create message object given string representation of the message ID.
 
void messageReceivedReport (MessagePtr msg)
 Make the protocol aware that the message has been received from remote end.
 
void messageSentReport (MessagePtr msg)
 Make the protocol aware that the message has been sent out to the remote end.
 
const QString & name () const
 Retrieve name of the protocol.
 
MessagesList read (const DataInfo &dataInfo, bool final=false)
 Read the received data input.
 
void setDebugOutputLevel (unsigned level=0U)
 Set debug output level.
 
template<typename TFunc >
void setErrorReportCallback (TFunc &&func)
 Set callback to report errors.
 
template<typename TFunc >
void setInterPluginConfigReportCallback (TFunc &&func)
 Set callback to report inter-plugin configuration.
 
template<typename TFunc >
void setSendMessageRequestCallback (TFunc &&func)
 Set the callback to allow request of extra messages to be sent out.
 
void socketConnectionReport (bool connected)
 Make the protocol aware about socket connection status.
 
UpdateStatus updateMessage (Message &msg)
 Update (or refresh) message contents.
 
DataInfoPtr write (Message &msg)
 Serialse message.
 

Protected Types

using AllMessages = typename ProtocolStack::AllMessages
 All messages bundle (std::tuple)
 
using ExtraInfoMsg = ExtraInfoMessage< ProtocolMessage >
 Type of "Extra Info Message".
 
using InvalidMsg = InvalidMessage< ProtocolMessage >
 Type of "Invalid Message".
 
using MsgFactory = typename TProtStack::MsgFactory
 Type of message factory.
 
using MsgIdParamType = typename ProtocolMessage::MsgIdParamType
 Type of message ID when passed as a parameter.
 
using MsgIdType = typename ProtocolMessage::MsgIdType
 Type used to represent message ID.
 
using ProtocolMessage = typename ProtocolMsgPtr::element_type
 Type of the common interface class.
 
using ProtocolMsgPtr = typename ProtocolStack::MsgPtr
 Definition of the pointer to message object.
 
using ProtocolStack = TProtStack
 Definition of "protocol stack" type.
 
using RawDataMsg = TRawDataMsg
 Definition of "Raw Data Message" type.
 
using TransportMsg = TTransportMsg
 Definition of "Transport Message" type.
 

Protected Member Functions

 ProtocolBase ()=default
 Default constructor.
 
virtual void applyInterPluginConfigImpl (const QVariantMap &props)
 Polymorphic inter-plugin configuration application.
 
virtual MessagePtr cloneMessageImpl (const Message &msg) override
 Overriding implementation to Protocol::cloneMessageImpl().
 
virtual MessagesList createAllMessagesImpl () override
 Overriding implementation to Protocol::createAllMessagesImpl().
 
template<typename TMsgsTuple >
MessagesList createAllMessagesInTuple ()
 Helper function allowing creation of all messages, types of which provided in the template parameter.
 
virtual MessagePtr createExtraInfoMessageImpl () override
 Overriding implementation to Protocol::createExtraInfoMessageImpl().
 
virtual MessagePtr createInvalidMessageImpl () override
 Overriding implementation to Protocol::createInvalidMessageImpl().
 
MessagePtr createMessage (MsgIdParamType id, unsigned idx=0)
 Helper function to create message.
 
virtual MessagePtr createMessageImpl (const QString &idAsString, unsigned idx) override
 Overriding implementation to Protocol::createMessageImpl().
 
virtual MessagePtr createRawDataMessageImpl () override
 Overriding implementation to Protocol::createRawDataMessageImpl().
 
unsigned getDebugOutputLevel () const
 Get current debug output level.
 
virtual void messageReceivedReportImpl (MessagePtr msg)
 Polymorphic processing of the message reception report.
 
virtual void messageSentReportImpl (MessagePtr msg)
 Make the protocol aware that the message has been sent out to the remote end.
 
virtual const QString & nameImpl () const =0
 Polymorphic protocol name retrieval.
 
ProtocolStackprotocolStack ()
 Get access to embedded "protocol stack" object.
 
const ProtocolStackprotocolStack () const
 Get access to embedded "protocol stack" object.
 
virtual MessagesList readImpl (const DataInfo &dataInfo, bool final) override
 Overriding implementation to Protocol::readImpl().
 
void reportError (const QString &str)
 Report operation error.
 
void reportInterPluginConfig (const QVariantMap &props)
 Report inter-plugin configuration.
 
void sendMessageRequest (MessagePtr msg)
 Request a protocol message to be sent out.
 
void setNameToMessageProperties (Message &msg)
 Helper function to assign protocol name to message properties.
 
virtual void socketConnectionReportImpl (bool connected)
 Polymorphic processing of the socket connection report.
 
virtual UpdateStatus updateMessageImpl (Message &msg) override
 Overriding implementation to Protocol::updateMessageImpl().
 
virtual DataInfoPtr writeImpl (Message &msg) override
 Overriding implementation to Protocol::writeImpl().
 

Static Protected Member Functions

static QVariantMap getExtraInfoFromMessageProperties (const Message &msg)
 Helper function to retrieve "extra info" from message properties.
 
static MessagePtr getExtraInfoMsgToMessageProperties (const Message &msg)
 Helper function to retrieve "extra info message" object from properties of the application message object.
 
static bool getForceExtraInfoExistenceFromMessageProperties (const Message &msg)
 Helper function to check whether "extra info" existence is force.
 
static void mergeExtraInfoToMessageProperties (const QVariantMap &extraInfo, Message &msg)
 Helper function to merge existing "extra info" and provided one.
 
static void setExtraInfoMsgToMessageProperties (MessagePtr extraInfoMsg, Message &msg)
 Helper function to assign "extra info message" object as a property of application message object.
 
static void setExtraInfoToMessageProperties (const QVariantMap &extraInfo, Message &msg)
 Helper function to set "extra info" to message properties.
 
static void setForceExtraInfoExistenceToMessageProperties (Message &msg)
 Helper function to force "extra info" existence.
 
static void setRawDataToMessageProperties (MessagePtr rawDataMsg, Message &msg)
 Helper function to assign "raw data message" object as a property of application message object.
 
static void setTransportToMessageProperties (MessagePtr transportMsg, Message &msg)
 Helper function to assign "tranport message" object as a property of application message object.
 

Member Typedef Documentation

◆ AllMessages

template<typename TProtStack , typename TTransportMsg , typename TRawDataMsg = RawDataMessage<TProtStack>>
using cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >::AllMessages = typename ProtocolStack::AllMessages
protected

All messages bundle (std::tuple)

Taken from "protocol stack" definition.

Member Enumeration Documentation

◆ UpdateStatus

enum class cc_tools_qt::Protocol::UpdateStatus
stronginherited

Status of message "update" operation.

Enumerator
NoChange 

The message contents haven't been changed.

Changed 

The message contents have been changed.

Member Function Documentation

◆ applyInterPluginConfig()

void cc_tools_qt::Protocol::applyInterPluginConfig ( const QVariantMap &  props)
inherited

Apply inter-plugin configuration.

Allows one plugin to influence the configuration of another. This function will be called for all currently chosen plugins to override current configuration. Invokes polymorphic applyInterPluginConfigImpl().

Parameters
[in]propsProperties map.

◆ applyInterPluginConfigImpl()

virtual void cc_tools_qt::Protocol::applyInterPluginConfigImpl ( const QVariantMap &  props)
protectedvirtualinherited

Polymorphic inter-plugin configuration application.

Invoked by the applyInterPluginConfig().

Parameters
[in]propsProperties map.

◆ cloneMessage()

MessagePtr cc_tools_qt::Protocol::cloneMessage ( const Message msg)
inherited

Clone the message object.

Invokes cloneMessageImpl().

Returns
Pointer to newly created message with the same contents

◆ createAllMessages()

MessagesList cc_tools_qt::Protocol::createAllMessages ( )
inherited

Create all messages supported by the protocol.

Invokes createAllMessagesImpl().

◆ createInvalidMessage()

MessagePtr cc_tools_qt::Protocol::createInvalidMessage ( const MsgDataSeq data)
inherited

Create dummy message containing invalid input.

Invokes createInvalidMessageImpl().

◆ createMessage()

MessagePtr cc_tools_qt::Protocol::createMessage ( const QString &  idAsString,
unsigned  idx = 0 
)
inherited

Create message object given string representation of the message ID.

Invokes createMessageImpl().

Parameters
[in]idAsStringString representation of the message ID.
[in]idxIndex of the message type within the range of message types with the same ID.

◆ messageReceivedReport()

void cc_tools_qt::Protocol::messageReceivedReport ( MessagePtr  msg)
inherited

Make the protocol aware that the message has been received from remote end.

Invokes messageReceivedReportImpl().

Parameters
[in]msgPointer to the message object

◆ messageReceivedReportImpl()

virtual void cc_tools_qt::Protocol::messageReceivedReportImpl ( MessagePtr  msg)
protectedvirtualinherited

Polymorphic processing of the message reception report.

Empty function, does nothing.

Parameters
[in]msgPointer to the message object

◆ messageSentReport()

void cc_tools_qt::Protocol::messageSentReport ( MessagePtr  msg)
inherited

Make the protocol aware that the message has been sent out to the remote end.

Invokes messageSentReportImpl().

Parameters
[in]msgPointer to the message object

◆ messageSentReportImpl()

virtual void cc_tools_qt::Protocol::messageSentReportImpl ( MessagePtr  msg)
protectedvirtualinherited

Make the protocol aware that the message has been sent out to the remote end.

Empty function, does nothing

Parameters
[in]msgPointer to the message object

◆ name()

const QString & cc_tools_qt::Protocol::name ( ) const
inherited

Retrieve name of the protocol.

Invokes nameImpl().

◆ nameImpl()

virtual const QString & cc_tools_qt::Protocol::nameImpl ( ) const
protectedpure virtualinherited

Polymorphic protocol name retrieval.

Invoked by name().

◆ read()

MessagesList cc_tools_qt::Protocol::read ( const DataInfo dataInfo,
bool  final = false 
)
inherited

Read the received data input.

Invokes readImpl().

Parameters
[in]dataInfoReceived data information
[in]finalFinal input indication, if true no more data is expected
Returns
List of created messages

◆ reportError()

void cc_tools_qt::Protocol::reportError ( const QString &  str)
protectedinherited

Report operation error.

This function is expected to be invoked by the derived class, when some error is detected. This function will invoke callback set by setErrorReportCallback().

Parameters
[in]strError string.

◆ reportInterPluginConfig()

void cc_tools_qt::Protocol::reportInterPluginConfig ( const QVariantMap &  props)
protectedinherited

Report inter-plugin configuration.

Sometimes configuration of one plugin may influence configuration of another. Use this function to report inter-plugin configuration properties. When invoked all other plugins are expected to get their respecitve applyInterPluginConfig() functions invoked.

Parameters
[in]propsReported properties.

◆ sendMessageRequest()

void cc_tools_qt::Protocol::sendMessageRequest ( MessagePtr  msg)
protectedinherited

Request a protocol message to be sent out.

This function is expected to be invoked by the derived class, when an extra message needs to be sent out. This function will invoke callback set by setSendMessageRequestCallback().

Parameters
[in]msgPointer to the message object.

◆ setDebugOutputLevel()

void cc_tools_qt::Protocol::setDebugOutputLevel ( unsigned  level = 0U)
inherited

Set debug output level.

Parameters
[in]levelDebug level. If 0, debug output is disabled

◆ setErrorReportCallback()

template<typename TFunc >
void cc_tools_qt::Protocol::setErrorReportCallback ( TFunc &&  func)
inherited

Set callback to report errors.

The callback must have the same signature as ErrorReportCallback

◆ setInterPluginConfigReportCallback()

template<typename TFunc >
void cc_tools_qt::Protocol::setInterPluginConfigReportCallback ( TFunc &&  func)
inherited

Set callback to report inter-plugin configuration.

The callback must have the same signature as InterPluginConfigReportCallback.

◆ setNameToMessageProperties()

void cc_tools_qt::Protocol::setNameToMessageProperties ( Message msg)
protectedinherited

Helper function to assign protocol name to message properties.

Expected to be used by the derived class.

◆ setSendMessageRequestCallback()

template<typename TFunc >
void cc_tools_qt::Protocol::setSendMessageRequestCallback ( TFunc &&  func)
inherited

Set the callback to allow request of extra messages to be sent out.

The callback must have the same signature as SendMessageRequestCallback

◆ socketConnectionReport()

void cc_tools_qt::Protocol::socketConnectionReport ( bool  connected)
inherited

Make the protocol aware about socket connection status.

Invokes socketConnectionReportImpl().

Parameters
[in]connectedSocket connection status.

◆ socketConnectionReportImpl()

virtual void cc_tools_qt::Protocol::socketConnectionReportImpl ( bool  connected)
protectedvirtualinherited

Polymorphic processing of the socket connection report.

Empty function, does nothing

Parameters
[in]connectedSocket connection status

◆ updateMessage()

UpdateStatus cc_tools_qt::Protocol::updateMessage ( Message msg)
inherited

Update (or refresh) message contents.

Invokes updateMessageImpl().

Returns
Status of the update.

◆ write()

DataInfoPtr cc_tools_qt::Protocol::write ( Message msg)
inherited

Serialse message.

Invokes writeImpl().

Parameters
[in]msgReference to message object, passed by non-const reference to allow update of the message properties.
Returns
Serialised data.

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