cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
Plugin.h
1//
2// Copyright 2014 - 2024 (C). Alex Robenko. All rights reserved.
3//
4
5// This file is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19#pragma once
20
21#include <string>
22#include <cassert>
23#include <memory>
24
25#include <QtCore/QObject>
26#include <QtCore/QtPlugin>
27#include <QtCore/QVariantMap>
28#include <QtWidgets/QWidget>
29
30#include "Api.h"
31#include "PluginProperties.h"
32
33namespace cc_tools_qt
34{
35
38class CC_API Plugin : public QObject
39{
40public:
42 using WidgetPtr = std::unique_ptr<QWidget>;
43
46
49
52
54 virtual ~Plugin() noexcept;
55
61 void getCurrentConfig(QVariantMap& config);
62
68 QVariantMap getCurrentConfig();
69
74 void reconfigure(const QVariantMap& config);
75
81 SocketPtr createSocket() const;
82
88 ListOfFilters createFilters() const;
89
95 ProtocolPtr createProtocol() const;
96
106 ListOfGuiActions createGuiActions() const;
107
116 QWidget* createConfiguarionWidget() const;
117
122 QVariant getCustomProperty(const QString& name);
123
129 void applyInterPluginConfig(const QVariantMap& props);
130
132 using InterPluginConfigReportCallback = std::function <void (const QVariantMap&)>;
133
135 void setInterPluginConfigReportCallback(InterPluginConfigReportCallback&& func);
136
139 void setDebugOutputLevel(unsigned level = 0U);
140
141protected:
147 virtual void getCurrentConfigImpl(QVariantMap& config);
148
154 virtual void reconfigureImpl(const QVariantMap& config);
155
159 virtual void applyInterPluginConfigImpl(const QVariantMap& props);
160
166 PluginProperties& pluginProperties();
167
174 void reportInterPluginConfig(const QVariantMap& props);
175
176private:
177 PluginProperties m_props;
178 InterPluginConfigReportCallback m_interPluginConfigReportCallback;
179 unsigned m_debugOutputLevel = 0U;
180};
181
182} // namespace cc_tools_qt
183
184Q_DECLARE_INTERFACE(cc_tools_qt::Plugin, "cc.Plugin")
185
186
Accumulation of various properties of Plugin.
Definition PluginProperties.h:43
QList< QAction * > ListOfGuiActions
List of dynamically allocated QAction objects.
Definition PluginProperties.h:49
QList< FilterPtr > ListOfFilters
List of Filter objects.
Definition PluginProperties.h:46
Interface class for plugin definition.
Definition Plugin.h:39
Plugin()
Constructor.
PluginProperties::ListOfFilters ListOfFilters
List of filter objects.
Definition Plugin.h:45
PluginProperties::ListOfGuiActions ListOfGuiActions
List of GUI action buttons.
Definition Plugin.h:48
std::function< void(const QVariantMap &)> InterPluginConfigReportCallback
Callback to report inter-plugin configuration updates.
Definition Plugin.h:132
virtual ~Plugin() noexcept
Destructor.
std::unique_ptr< QWidget > WidgetPtr
Pointer to widget object.
Definition Plugin.h:42
Main namespace for all classes / functions of the shared library.
std::shared_ptr< Socket > SocketPtr
Pointer to Socket object.
Definition Socket.h:246
std::shared_ptr< Protocol > ProtocolPtr
Pointer to Protocol object.
Definition Protocol.h:293