cc_tools_qt
Common Environment for Protocol Analysis.
|
#include "cc_tools_qt/ProtocolBase.h"
Helper class to define custom Protocol.
Provides the default implementation to most of the virtual functions defined by Protocol class.
TProtStack | Definition of the protocol stack. |
TTransportMsg | Definition of the "Transport Message". |
TRawDataMsg | Definition of the "Raw Data Message", defaults to RawDataMessage |
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. | |
ProtocolStack & | protocolStack () |
Get access to embedded "protocol stack" object. | |
const ProtocolStack & | protocolStack () 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. | |
|
protected |
All messages bundle (std::tuple)
Taken from "protocol stack" definition.
|
stronginherited |
|
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().
[in] | props | Properties map. |
|
protectedvirtualinherited |
Polymorphic inter-plugin configuration application.
Invoked by the applyInterPluginConfig().
[in] | props | Properties map. |
|
inherited |
Clone the message object.
Invokes cloneMessageImpl().
|
inherited |
Create all messages supported by the protocol.
Invokes createAllMessagesImpl().
|
inherited |
Create dummy message containing invalid input.
Invokes createInvalidMessageImpl().
|
inherited |
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. |
|
inherited |
Make the protocol aware that the message has been received from remote end.
Invokes messageReceivedReportImpl().
[in] | msg | Pointer to the message object |
|
protectedvirtualinherited |
Polymorphic processing of the message reception report.
Empty function, does nothing.
[in] | msg | Pointer to the message object |
|
inherited |
Make the protocol aware that the message has been sent out to the remote end.
Invokes messageSentReportImpl().
[in] | msg | Pointer to the message object |
|
protectedvirtualinherited |
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 |
|
inherited |
Retrieve name of the protocol.
Invokes nameImpl().
|
protectedpure virtualinherited |
Polymorphic protocol name retrieval.
Invoked by name().
|
inherited |
Read the received data input.
Invokes readImpl().
[in] | dataInfo | Received data information |
[in] | final | Final input indication, if true no more data is expected |
|
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().
[in] | str | Error string. |
|
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.
[in] | props | Reported properties. |
|
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().
[in] | msg | Pointer to the message object. |
|
inherited |
Set debug output level.
[in] | level | Debug level. If 0, debug output is disabled |
|
inherited |
Set callback to report errors.
The callback must have the same signature as ErrorReportCallback
|
inherited |
Set callback to report inter-plugin configuration.
The callback must have the same signature as InterPluginConfigReportCallback.
|
protectedinherited |
Helper function to assign protocol name to message properties.
Expected to be used by the derived class.
|
inherited |
Set the callback to allow request of extra messages to be sent out.
The callback must have the same signature as SendMessageRequestCallback
|
inherited |
Make the protocol aware about socket connection status.
Invokes socketConnectionReportImpl().
[in] | connected | Socket connection status. |
|
protectedvirtualinherited |
Polymorphic processing of the socket connection report.
Empty function, does nothing
[in] | connected | Socket connection status |
|
inherited |
|
inherited |
Serialse message.
Invokes writeImpl().
[in] | msg | Reference to message object, passed by non-const reference to allow update of the message properties. |