cc_tools_qt
Common Environment for Protocol Analysis.
|
#include "cc_tools_qt/Protocol.h"
Main polymorphic interface class for protocols.
It is used by CommsChampion Tools to create and manipulate protocol messages.
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. | |
|
strong |
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().
[in] | props | Properties map. |
|
protectedvirtual |
Polymorphic inter-plugin configuration application.
Invoked by the applyInterPluginConfig().
[in] | props | Properties map. |
MessagePtr cc_tools_qt::Protocol::cloneMessage | ( | const Message & | msg | ) |
Clone the message object.
Invokes cloneMessageImpl().
|
protectedpure virtual |
Polymorphic message cloning functionality.
Invoked by cloneMessage().
Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.
MessagesList cc_tools_qt::Protocol::createAllMessages | ( | ) |
Create all messages supported by the protocol.
Invokes createAllMessagesImpl().
|
protectedpure virtual |
Polymorphic creation of all messages protocol supports.
Invoked by createAllMessages().
Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.
MessagePtr cc_tools_qt::Protocol::createInvalidMessage | ( | const MsgDataSeq & | data | ) |
Create dummy message containing invalid input.
Invokes createInvalidMessageImpl().
|
protectedpure virtual |
Polymorphic creation of invalid message representation.
Invoked by createInvalidMessage().
Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.
MessagePtr cc_tools_qt::Protocol::createMessage | ( | const QString & | idAsString, |
unsigned | idx = 0 |
||
) |
Create message object given string representation of the message ID.
Invokes createMessageImpl().
[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. |
|
protectedpure virtual |
Polymorphic message creation functionality.
Invoked by createMessage().
Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.
void cc_tools_qt::Protocol::messageReceivedReport | ( | MessagePtr | 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::Protocol::messageSentReport | ( | MessagePtr | 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::Protocol::name | ( | ) | const |
Retrieve name of the protocol.
Invokes nameImpl().
|
protectedpure virtual |
Polymorphic protocol name retrieval.
Invoked by name().
MessagesList cc_tools_qt::Protocol::read | ( | const DataInfo & | dataInfo, |
bool | final = false |
||
) |
Read the received data input.
Invokes readImpl().
[in] | dataInfo | Received data information |
[in] | final | Final input indication, if true no more data is expected |
|
protectedpure virtual |
Polymorphic read functionality.
Invoked by read().
Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.
|
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().
[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.
[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 callback set by setSendMessageRequestCallback().
[in] | msg | Pointer to the message object. |
void cc_tools_qt::Protocol::setDebugOutputLevel | ( | unsigned | level = 0U | ) |
Set debug output level.
[in] | level | Debug level. If 0, debug output is disabled |
void cc_tools_qt::Protocol::setErrorReportCallback | ( | TFunc && | func | ) |
Set callback to report errors.
The callback must have the same signature as ErrorReportCallback
void cc_tools_qt::Protocol::setInterPluginConfigReportCallback | ( | TFunc && | func | ) |
Set callback to report inter-plugin configuration.
The callback must have the same signature as InterPluginConfigReportCallback.
|
protected |
Helper function to assign protocol name to message properties.
Expected to be used by the derived class.
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
void cc_tools_qt::Protocol::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 |
UpdateStatus cc_tools_qt::Protocol::updateMessage | ( | Message & | msg | ) |
|
protectedpure virtual |
Polymorphic message update (refresh) functionality.
Invoked by updateMessage().
Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.
DataInfoPtr cc_tools_qt::Protocol::write | ( | Message & | msg | ) |
Serialse message.
Invokes writeImpl().
[in] | msg | Reference to message object, passed by non-const reference to allow update of the message properties. |
|
protectedpure virtual |
Polymorphic write functionality.
invoked by write().
Implemented in cc_tools_qt::ProtocolBase< TProtStack, TTransportMsg, TRawDataMsg >.