cc_tools_qt
Common Environment for Protocol Analysis.
|
#include "cc_tools_qt/ToolsProtocol.h"
Main polymorphic interface class for protocols.
It is used by CommsChampion Tools to create and manipulate protocol messages.
Inherits QObject.
Public Types | |
using | DataInfosList = std::list< ToolsDataInfoPtr > |
List of raw data buffers. | |
using | MsgDataSeq = ToolsMessage::DataSeq |
Type used to contain raw bytes seqence. | |
enum class | UpdateStatus { NoChange , Changed } |
Status of message "update" operation. More... | |
Signals | |
void | sigErrorReport (const QString &str) |
Signal used to report error. | |
void | sigInterPluginConfigReport (const QVariantMap &props) |
Signal to report inter-plugin configuration. | |
void | sigSendMessageReport (ToolsMessagePtr msg) |
Signal used to report new protocol message to be sent out. | |
Public Member Functions | |
virtual | ~ToolsProtocol () noexcept |
Destructor. | |
void | applyInterPluginConfig (const QVariantMap &props) |
Apply inter-plugin configuration. | |
ToolsMessagePtr | cloneMessage (const ToolsMessage &msg) |
Clone the message object. | |
ToolsMessagesList | createAllMessages () |
Create all messages supported by the protocol. | |
ToolsMessagePtr | createInvalidMessage (const MsgDataSeq &data) |
Create dummy message containing invalid input. | |
ToolsMessagePtr | createMessage (const QString &idAsString, unsigned idx=0) |
Create message object given string representation of the message ID. | |
void | messageReceivedReport (ToolsMessagePtr msg) |
Make the protocol aware that the message has been received from remote end. | |
void | messageSentReport (ToolsMessagePtr 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. | |
ToolsMessagesList | read (const ToolsDataInfo &dataInfo, bool final=false) |
Read the received data input. | |
void | setDebugOutputLevel (unsigned level=0U) |
Set debug output level. | |
void | socketConnectionReport (bool connected) |
Make the protocol aware about socket connection status. | |
UpdateStatus | updateMessage (ToolsMessage &msg) |
Update (or refresh) message contents. | |
ToolsDataInfoPtr | write (ToolsMessage &msg) |
Serialise message. | |
Protected Member Functions | |
virtual void | applyInterPluginConfigImpl (const QVariantMap &props) |
Polymorphic inter-plugin configuration application. | |
unsigned | getDebugOutputLevel () const |
Get current debug output level. | |
virtual void | messageReceivedReportImpl (ToolsMessagePtr msg) |
Polymorphic processing of the message reception report. | |
virtual void | messageSentReportImpl (ToolsMessagePtr 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. | |
void | reportError (const QString &str) |
Report operation error. | |
void | reportInterPluginConfig (const QVariantMap &props) |
Report inter-plugin configuration. | |
void | sendMessageRequest (ToolsMessagePtr msg) |
Request a protocol message to be sent out. | |
void | setNameToMessageProperties (ToolsMessage &msg) |
Helper function to assign protocol name to message properties. | |
virtual void | socketConnectionReportImpl (bool connected) |
Polymorphic processing of the socket connection report. | |
Static Protected Member Functions | |
static QVariantMap | getExtraInfoFromMessageProperties (const ToolsMessage &msg) |
Helper function to retrieve "extra info" from message properties. | |
static ToolsMessagePtr | getExtraInfoMsgToMessageProperties (const ToolsMessage &msg) |
Helper function to retrieve "extra info message" object from properties of the application message object. | |
static bool | getForceExtraInfoExistenceFromMessageProperties (const ToolsMessage &msg) |
Helper function to check whether "extra info" existence is force. | |
static void | mergeExtraInfoToMessageProperties (const QVariantMap &extraInfo, ToolsMessage &msg) |
Helper function to merge existing "extra info" and provided one. | |
static void | setExtraInfoMsgToMessageProperties (ToolsMessagePtr extraInfoMsg, ToolsMessage &msg) |
Helper function to assign "extra info message" object as a property of application message object. | |
static void | setExtraInfoToMessageProperties (const QVariantMap &extraInfo, ToolsMessage &msg) |
Helper function to set "extra info" to message properties. | |
static void | setForceExtraInfoExistenceToMessageProperties (ToolsMessage &msg) |
Helper function to force "extra info" existence. | |
static void | setRawDataToMessageProperties (ToolsMessagePtr rawDataMsg, ToolsMessage &msg) |
Helper function to assign "raw data message" object as a property of application message object. | |
static void | setTransportToMessageProperties (ToolsMessagePtr transportMsg, ToolsMessage &msg) |
Helper function to assign "tranport message" object as a property of application message object. | |
|
strong |
void cc_tools_qt::ToolsProtocol::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().
[in] | props | Properties map. |
|
protectedvirtual |
Polymorphic inter-plugin configuration application.
Invoked by the applyInterPluginConfig().
[in] | props | Properties map. |
ToolsMessagePtr cc_tools_qt::ToolsProtocol::cloneMessage | ( | const ToolsMessage & | msg | ) |
Clone the message object.
ToolsMessagePtr cc_tools_qt::ToolsProtocol::createMessage | ( | const QString & | idAsString, |
unsigned | idx = 0 |
||
) |
Create message object given string representation of the message ID.
[in] | idAsString | String representation of the message ID. |
[in] | idx | Index of the message type within the range of message types with the same ID. |
void cc_tools_qt::ToolsProtocol::messageReceivedReport | ( | ToolsMessagePtr | msg | ) |
Make the protocol aware that the message has been received from remote end.
Invokes messageReceivedReportImpl().
[in] | msg | Pointer to the message object |
|
protectedvirtual |
Polymorphic processing of the message reception report.
Empty function, does nothing.
[in] | msg | Pointer to the message object |
void cc_tools_qt::ToolsProtocol::messageSentReport | ( | ToolsMessagePtr | msg | ) |
Make the protocol aware that the message has been sent out to the remote end.
Invokes messageSentReportImpl().
[in] | msg | Pointer to the message object |
|
protectedvirtual |
Make the protocol aware that the message has been sent out to the remote end.
Empty function, does nothing
[in] | msg | Pointer to the message object |
const QString & cc_tools_qt::ToolsProtocol::name | ( | ) | const |
Retrieve name of the protocol.
Invokes nameImpl().
|
protectedpure virtual |
Polymorphic protocol name retrieval.
Invoked by name().
ToolsMessagesList cc_tools_qt::ToolsProtocol::read | ( | const ToolsDataInfo & | dataInfo, |
bool | final = false |
||
) |
Read the received data input.
[in] | dataInfo | Received data information |
[in] | final | Final input indication, if true no more data is expected |
|
protected |
Report operation error.
This function is expected to be invoked by the derived class, when some error is detected. This function will emit sigErrorReport() signal.
[in] | str | Error string. |
|
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.
Emits sigInterPluginConfigReport() signal.
[in] | props | Reported properties. |
|
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 emit sigSendMessageReport() signal.
[in] | msg | Pointer to the message object. |
void cc_tools_qt::ToolsProtocol::setDebugOutputLevel | ( | unsigned | level = 0U | ) |
Set debug output level.
[in] | level | Debug level. If 0, debug output is disabled |
|
protected |
Helper function to assign protocol name to message properties.
Expected to be used by the derived class.
|
signal |
Signal used to report error.
[in] | str | Error message. |
|
signal |
Signal to report inter-plugin configuration.
[in] | props | Configuration properties. |
|
signal |
Signal used to report new protocol message to be sent out.
[in] | msg | Pointer to message object |
void cc_tools_qt::ToolsProtocol::socketConnectionReport | ( | bool | connected | ) |
Make the protocol aware about socket connection status.
Invokes socketConnectionReportImpl().
[in] | connected | Socket connection status. |
|
protectedvirtual |
Polymorphic processing of the socket connection report.
Empty function, does nothing
[in] | connected | Socket connection status |
ToolsProtocol::UpdateStatus cc_tools_qt::ToolsProtocol::updateMessage | ( | ToolsMessage & | msg | ) |
Update (or refresh) message contents.
ToolsDataInfoPtr cc_tools_qt::ToolsProtocol::write | ( | ToolsMessage & | msg | ) |
Serialise message.
[in] | msg | Reference to message object, passed by non-const reference to allow update of the message properties. |