cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
cc_tools_qt::Protocol Class Referenceabstract

#include "cc_tools_qt/Protocol.h"

Detailed Description

Main polymorphic interface class for protocols.

It is used by CommsChampion Tools to create and manipulate protocol messages.

Inheritance diagram for cc_tools_qt::Protocol:
cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >

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

virtual ~Protocol () noexcept
 Destructor.
 
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 Member Functions

virtual void applyInterPluginConfigImpl (const QVariantMap &props)
 Polymorphic inter-plugin configuration application.
 
virtual MessagePtr cloneMessageImpl (const Message &msg)=0
 Polymorphic message cloning functionality.
 
virtual MessagesList createAllMessagesImpl ()=0
 Polymorphic creation of all messages protocol supports.
 
virtual MessagePtr createExtraInfoMessageImpl ()=0
 Polymorphic creation of message object representing extra info.
 
virtual MessagePtr createInvalidMessageImpl ()=0
 Polymorphic creation of invalid message representation.
 
virtual MessagePtr createMessageImpl (const QString &idAsString, unsigned idx)=0
 Polymorphic message creation functionality.
 
virtual MessagePtr createRawDataMessageImpl ()=0
 Polymorphic creation of message object representing raw data.
 
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.
 
virtual MessagesList readImpl (const DataInfo &dataInfo, bool final)=0
 Polymorphic read functionality.
 
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)=0
 Polymorphic message update (refresh) functionality.
 
virtual DataInfoPtr writeImpl (Message &msg)=0
 Polymorphic write functionality.
 

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 Enumeration Documentation

◆ UpdateStatus

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)

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)
protectedvirtual

Polymorphic inter-plugin configuration application.

Invoked by the applyInterPluginConfig().

Parameters
[in]propsProperties map.

◆ cloneMessage()

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

Clone the message object.

Invokes cloneMessageImpl().

Returns
Pointer to newly created message with the same contents

◆ cloneMessageImpl()

virtual MessagePtr cc_tools_qt::Protocol::cloneMessageImpl ( const Message msg)
protectedpure virtual

Polymorphic message cloning functionality.

Invoked by cloneMessage().

Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.

◆ createAllMessages()

MessagesList cc_tools_qt::Protocol::createAllMessages ( )

Create all messages supported by the protocol.

Invokes createAllMessagesImpl().

◆ createAllMessagesImpl()

virtual MessagesList cc_tools_qt::Protocol::createAllMessagesImpl ( )
protectedpure virtual

Polymorphic creation of all messages protocol supports.

Invoked by createAllMessages().

Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.

◆ createInvalidMessage()

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

Create dummy message containing invalid input.

Invokes createInvalidMessageImpl().

◆ createInvalidMessageImpl()

virtual MessagePtr cc_tools_qt::Protocol::createInvalidMessageImpl ( )
protectedpure virtual

Polymorphic creation of invalid message representation.

Invoked by createInvalidMessage().

Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.

◆ createMessage()

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

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.

◆ createMessageImpl()

virtual MessagePtr cc_tools_qt::Protocol::createMessageImpl ( const QString &  idAsString,
unsigned  idx 
)
protectedpure virtual

Polymorphic message creation functionality.

Invoked by createMessage().

Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.

◆ messageReceivedReport()

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

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)
protectedvirtual

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)

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)
protectedvirtual

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

Retrieve name of the protocol.

Invokes nameImpl().

◆ nameImpl()

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

Polymorphic protocol name retrieval.

Invoked by name().

◆ read()

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

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

◆ readImpl()

virtual MessagesList cc_tools_qt::Protocol::readImpl ( const DataInfo dataInfo,
bool  final 
)
protectedpure virtual

Polymorphic read functionality.

Invoked by read().

Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.

◆ reportError()

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

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)
protected

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)
protected

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)

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)

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)

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)
protected

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)

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)

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)
protectedvirtual

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)

Update (or refresh) message contents.

Invokes updateMessageImpl().

Returns
Status of the update.

◆ updateMessageImpl()

virtual UpdateStatus cc_tools_qt::Protocol::updateMessageImpl ( Message msg)
protectedpure virtual

Polymorphic message update (refresh) functionality.

Invoked by updateMessage().

Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.

◆ write()

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

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.

◆ writeImpl()

virtual DataInfoPtr cc_tools_qt::Protocol::writeImpl ( Message msg)
protectedpure virtual

Polymorphic write functionality.

invoked by write().

Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.


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