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
19#pragma once
20
21#include <memory>
22#include <list>
23#include <array>
24
25#include <QtCore/QObject>
26#include <QtCore/QString>
27#include <QtCore/QVariantMap>
28#include <QtCore/QPluginLoader>
29
30#include "cc_tools_qt/ToolsPlugin.h"
31#include "cc_tools_qt/ToolsPluginMgr.h"
32#include "cc_tools_qt/ToolsConfigMgr.h"
33
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
80
Main namespace for all classes / functions of the shared library.