cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsPluginMgrImpl.h
1//
2// Copyright 2015 - 2025 (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#pragma once
19
20#include <memory>
21#include <list>
22#include <array>
23
24#include <QtCore/QObject>
25#include <QtCore/QString>
26#include <QtCore/QVariantMap>
27#include <QtCore/QPluginLoader>
28
29#include "cc_tools_qt/ToolsPlugin.h"
30#include "cc_tools_qt/ToolsPluginMgr.h"
31#include "cc_tools_qt/ToolsConfigMgr.h"
32
33namespace cc_tools_qt
34{
35
36class ToolsPluginMgrImpl
37{
38public:
39
40 using PluginLoaderPtr = ToolsPluginMgr::PluginLoaderPtr;
41 using PluginInfo = ToolsPluginMgr::PluginInfo;
42 using PluginInfoPtr = ToolsPluginMgr::PluginInfoPtr;
43 using ListOfPluginInfos = ToolsPluginMgr::ListOfPluginInfos;
44
45 ToolsPluginMgrImpl();
46 ~ToolsPluginMgrImpl() noexcept;
47
48 void setPluginsDir(const QString& pluginDir);
49 const ListOfPluginInfos& getAvailablePlugins();
50 const ListOfPluginInfos& getAppliedPlugins() const;
51 void setAppliedPlugins(const ListOfPluginInfos& plugins);
52 ListOfPluginInfos loadPluginsFromConfig(const QVariantMap& config);
53 ListOfPluginInfos loadPluginsFromConfigFile(const QString& filename);
54 bool savePluginsToConfigFile(const ListOfPluginInfos& infos, const QString& filename);
55 ToolsPlugin* loadPlugin(const PluginInfo& info);
56 bool hasAppliedPlugins() const;
57 bool needsReload(const ListOfPluginInfos& infos) const;
58 bool isProtocolChanging(const ListOfPluginInfos& infos) const;
59 void unloadApplied();
60 bool unloadAppliedPlugin(const PluginInfo& info);
61 static QVariantMap getConfigForPlugins(const ListOfPluginInfos& infos);
62 const QString& getLastFile() const;
63 static const QString& getFilesFilter();
64
65private:
66 using PluginLoadersList = std::list<PluginLoaderPtr>;
67
68 PluginInfoPtr readPluginInfo(const QString& filename);
69
70 QString m_pluginDir;
71 ListOfPluginInfos m_plugins;
72 ListOfPluginInfos m_appliedPlugins;
73 ToolsConfigMgr m_configMgr;
74};
75
76} // namespace cc_tools_qt
77
Main namespace for all classes / functions of the shared library.