cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
Supporting Inter-Plugin Configuration

The cc_tools_qt allows one plugin to influence the configuration of another. The configuration exchange is done via QVariantMap data type and it's up to the plugins to interpret the values stored in the map.

Receiving Inter-Plugin Configuration Request

The plugin class is expected to extend the cc_tools_qt::Plugin and override the applyInterPluginConfigImpl() member function.

class MyFilterPlugin : public cc_tools_qt::Plugin
{
...
protected:
void applyInterPluginConfigImpl(const QVariantMap& props) override
{
auto somePropVar = props.value("some_prop");
if (somePropVar.isValid()) {
// The inter-plugin configuration contains a value this plugin
// can use:
auto someProp = somePropVar.value<QString>();
... // Do something with the extracted value.
}
}
...
};
Interface class for plugin definition.
Definition Plugin.h:39
virtual void applyInterPluginConfigImpl(const QVariantMap &props)
Polymorphic inter-plugin configuration application.

In case the plugin configuration is handled inside the class extending the socket, filter, or protocol, then such class can override its applyInterPluginConfigImpl() member function while the plugin's applyInterPluginConfigImpl() one can redirect the request.

class MySocket : public cc_tools_qt::Socket
{
...
protected:
void applyInterPluginConfigImpl(const QVariantMap& props) override
{
auto somePropVar = props.value("some_prop");
if (somePropVar.isValid()) {
// The inter-plugin configuration contains a value this plugin
// can use:
auto someProp = somePropVar.value<QString>();
... // Do something with the extracted value.
}
}
...
};
class MyFilterPlugin : public cc_tools_qt::Plugin
{
public:
MyFilterPlugin() : m_socket(new MySocket) {...}
protected:
void applyInterPluginConfigImpl(const QVariantMap& props) override
{
m_socket->applyInterPluginConfig(props);
}
...
};
Main polymorphic interface class for sockets.
Definition Socket.h:39
virtual void applyInterPluginConfigImpl(const QVariantMap &props)
Polymorphic inter-plugin configuration application.

Sending Inter-Plugin Configuration Request

The plugin class can invoke inheirted reportInterPluginConfig() member function to report populated inter-plugin configuration.

class MyFilterPlugin : public cc_tools_qt::Plugin
{
...
private:
void someEvent()
{
QVariantMap props;
prop["some_prop"] = QVariant::fromValue(QString("some_value"));
prop["some_other_prop"] = QVariant::fromValue(123);
}
};
void reportInterPluginConfig(const QVariantMap &props)
Report inter-plugin configuration.

In case the inter-plugin configuration event is initiated inside the class extending the socket, filter, or protocol, then such class can use inherited cc_tools_qt::Socket::reportInterPluginConfig() member function while the plugin class can set appropriate callback and use the inherited reportInterPluginConfig() to propagate the inter-plugin configuration request.

class MySocket : public cc_tools_qt::Socket
{
...
private:
void someEvent()
{
QVariantMap props;
prop["some_prop"] = QVariant::fromValue(QString("some_value"));
prop["some_other_prop"] = QVariant::fromValue(123);
}
};
class MyFilterPlugin : public cc_tools_qt::Plugin
{
public:
MyFilterPlugin() : m_socket(new MySocket)
{
m_socket->setInterPluginConfigReportCallback(
[this](const QVariantMap& props)
{
});
}
};
void reportInterPluginConfig(const QVariantMap &props)
Report inter-plugin configuration.