cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsPluginMgrImpl.h
1//
2// Copyright 2015 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7// This file is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20#pragma once
21
22#include <memory>
23#include <list>
24#include <array>
25
26#include <QtCore/QObject>
27#include <QtCore/QString>
28#include <QtCore/QVariantMap>
29#include <QtCore/QPluginLoader>
30
31#include "cc_tools_qt/ToolsPlugin.h"
32#include "cc_tools_qt/ToolsPluginMgr.h"
33#include "cc_tools_qt/ToolsConfigMgr.h"
34
35namespace cc_tools_qt
36{
37
38class ToolsPluginMgrImpl
39{
40public:
41
42 using PluginLoaderPtr = ToolsPluginMgr::PluginLoaderPtr;
43 using PluginInfo = ToolsPluginMgr::PluginInfo;
44 using PluginInfoPtr = ToolsPluginMgr::PluginInfoPtr;
45 using ListOfPluginInfos = ToolsPluginMgr::ListOfPluginInfos;
46
47 ToolsPluginMgrImpl();
48 ~ToolsPluginMgrImpl() noexcept;
49
50 void setPluginsDir(const QString& pluginDir);
51 const ListOfPluginInfos& getAvailablePlugins();
52 const ListOfPluginInfos& getAppliedPlugins() const;
53 void setAppliedPlugins(const ListOfPluginInfos& plugins);
54 ListOfPluginInfos loadPluginsFromConfig(const QVariantMap& config);
55 ListOfPluginInfos loadPluginsFromConfigFile(const QString& filename);
56 bool savePluginsToConfigFile(const ListOfPluginInfos& infos, const QString& filename);
57 ToolsPlugin* loadPlugin(const PluginInfo& info);
58 bool hasAppliedPlugins() const;
59 bool needsReload(const ListOfPluginInfos& infos) const;
60 bool isProtocolChanging(const ListOfPluginInfos& infos) const;
61 void unloadApplied();
62 bool unloadAppliedPlugin(const PluginInfo& info);
63 static QVariantMap getConfigForPlugins(const ListOfPluginInfos& infos);
64 const QString& getLastFile() const;
65 static const QString& getFilesFilter();
66
67private:
68 using PluginLoadersList = std::list<PluginLoaderPtr>;
69
70 PluginInfoPtr readPluginInfo(const QString& filename);
71
72 QString m_pluginDir;
73 ListOfPluginInfos m_plugins;
74 ListOfPluginInfos m_appliedPlugins;
75 ToolsConfigMgr m_configMgr;
76};
77
78} // namespace cc_tools_qt
79
Main namespace for all classes / functions of the shared library.