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

#include "cc_tools_qt/Plugin.h"

Detailed Description

Interface class for plugin definition.

Inherits QObject.

Public Types

using InterPluginConfigReportCallback = std::function< void(const QVariantMap &)>
 Callback to report inter-plugin configuration updates.
 
using ListOfFilters = PluginProperties::ListOfFilters
 List of filter objects.
 
using ListOfGuiActions = PluginProperties::ListOfGuiActions
 List of GUI action buttons.
 
using WidgetPtr = std::unique_ptr< QWidget >
 Pointer to widget object.
 

Public Member Functions

 Plugin ()
 Constructor.
 
virtual ~Plugin () noexcept
 Destructor.
 
void applyInterPluginConfig (const QVariantMap &props)
 Apply inter-plugin configuration.
 
QWidget * createConfiguarionWidget () const
 Create a widget to perform plugin configuration in GUI application.
 
ListOfFilters createFilters () const
 Create filters.
 
ListOfGuiActions createGuiActions () const
 Create GUI actions relevant to the plugin.
 
ProtocolPtr createProtocol () const
 Create protocol.
 
SocketPtr createSocket () const
 Create socket.
 
QVariantMap getCurrentConfig ()
 Get currentConfiguration.
 
void getCurrentConfig (QVariantMap &config)
 Get current configuration.
 
QVariant getCustomProperty (const QString &name)
 Retrieve custom property assigned by the derived class.
 
void reconfigure (const QVariantMap &config)
 Request to perform reconfigure.
 
void setDebugOutputLevel (unsigned level=0U)
 Set debug output level.
 
void setInterPluginConfigReportCallback (InterPluginConfigReportCallback &&func)
 Set callback to report inter-plugin configuration.
 

Protected Member Functions

virtual void applyInterPluginConfigImpl (const QVariantMap &props)
 Polymorphic inter-plugin configuration application.
 
virtual void getCurrentConfigImpl (QVariantMap &config)
 Polymorphic call to retrieve current configuration.
 
PluginPropertiespluginProperties ()
 Get access to plugin properties.
 
virtual void reconfigureImpl (const QVariantMap &config)
 Polymorphic call to perform plugin (re)configuration.
 
void reportInterPluginConfig (const QVariantMap &props)
 Report inter-plugin configuration.
 

Member Function Documentation

◆ applyInterPluginConfig()

void cc_tools_qt::Plugin::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::Plugin::applyInterPluginConfigImpl ( const QVariantMap &  props)
protectedvirtual

Polymorphic inter-plugin configuration application.

Invoked by the applyInterPluginConfig().

Parameters
[in]propsProperties map.

◆ createConfiguarionWidget()

QWidget * cc_tools_qt::Plugin::createConfiguarionWidget ( ) const

Create a widget to perform plugin configuration in GUI application.

Sometimes there is a need to provide a way to configure the plugin. A GUI application will call this function to retrieve a widget which will control the configuration. The returned widged is expected to be dynamically allocated and will be owned by the GUI application, i.e. the plugin doesn't need to perform any delete operation on it.

Returns
Dynamically allocated widget object

◆ createFilters()

ListOfFilters cc_tools_qt::Plugin::createFilters ( ) const

Create filters.

This function will be called if it is filter plugin. It will invoke filters creation callback function assigned by the derived class to pluginProperties().

Returns
List of allocated plugin objects

◆ createGuiActions()

ListOfGuiActions cc_tools_qt::Plugin::createGuiActions ( ) const

Create GUI actions relevant to the plugin.

This function will invoke the relevant callback function assigned by the derived class to pluginProperties(). The callback function is responsible to allocate and return a list of QAction objects, which will appear to the main toolbar of the GUI application. Note, that the main application will own the allocated QAction objects and will delete them later. The plugin doesn't need to do it explicityly.

Returns
List of GUI QAction objects.

◆ createProtocol()

ProtocolPtr cc_tools_qt::Plugin::createProtocol ( ) const

Create protocol.

This function will be called if it is protocol plugin. It will invoke protocol creation callback function assigned by the derived class to pluginProperties().

Returns
Allocated protocol object

◆ createSocket()

SocketPtr cc_tools_qt::Plugin::createSocket ( ) const

Create socket.

This function will be called if it is socket plugin. It will invoke socket creation callback function assigned by the derived class to pluginProperties().

Returns
Allocated socket object

◆ getCurrentConfig() [1/2]

QVariantMap cc_tools_qt::Plugin::getCurrentConfig ( )

Get currentConfiguration.

Invokes getCurrentConfigImpl(), which can be overridden by the derived class. It is responsible to update the provided configuration with new entries relevant to the plugin.

Returns
Configuration map.

◆ getCurrentConfig() [2/2]

void cc_tools_qt::Plugin::getCurrentConfig ( QVariantMap &  config)

Get current configuration.

Invokes getCurrentConfigImpl(), which can be overridden by the derived class. It is responsible to update the provided configuration with new entries relevant to the plugin.

Parameters
[in,out]configConfiguration map

◆ getCurrentConfigImpl()

virtual void cc_tools_qt::Plugin::getCurrentConfigImpl ( QVariantMap &  config)
protectedvirtual

Polymorphic call to retrieve current configuration.

Default implementation does nothing. The derived class needs to override this function if the plugin requires or supports configuration and update the provided map with relevant values.

Parameters
[in,out]configConfiguration map

◆ getCustomProperty()

QVariant cc_tools_qt::Plugin::getCustomProperty ( const QString &  name)

Retrieve custom property assigned by the derived class.

Parameters
[in]nameName of the property
Returns
Property value. The value needs to be converted to proper type by the caller.

◆ pluginProperties()

PluginProperties & cc_tools_qt::Plugin::pluginProperties ( )
protected

Get access to plugin properties.

Expected to be called by the derived class to get an access to the properties accumulation objects and provide appropriate callbacks and/or other custom properties.

Returns
Reference to plugin properties object

◆ reconfigure()

void cc_tools_qt::Plugin::reconfigure ( const QVariantMap &  config)

Request to perform reconfigure.

Invokes reconfigureImpl(), which can be overridden by the derived class. The latter must retrieve appropriate values from the configuration map and apply requested updates.

◆ reconfigureImpl()

virtual void cc_tools_qt::Plugin::reconfigureImpl ( const QVariantMap &  config)
protectedvirtual

Polymorphic call to perform plugin (re)configuration.

Default implementation does nothing. The derived class needs to override byt function if the plugin requires or supports (re)configuration.

Parameters
[in]configConfiguration map

◆ reportInterPluginConfig()

void cc_tools_qt::Plugin::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.

◆ setDebugOutputLevel()

void cc_tools_qt::Plugin::setDebugOutputLevel ( unsigned  level = 0U)

Set debug output level.

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

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