Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PluginLoader.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3#pragma once
4
8#include <PhosphorRegistry/phosphorregistry_export.h>
9
10#include <QHash>
11#include <QObject>
12#include <QString>
13#include <QStringList>
14#include <QtCore/qtclasshelpermacros.h>
15
16#include <memory>
17
18namespace PhosphorRegistry {
19
37class PHOSPHORREGISTRY_EXPORT PluginLoader : public QObject
38{
39 Q_OBJECT
40public:
43 [[nodiscard]] static PluginSeam barWidgetSeam();
44
48 const QList<PluginSearchPath>& searchPaths = QList<PluginSearchPath>(),
49 QObject* parent = nullptr);
50 ~PluginLoader() override;
51 Q_DISABLE_COPY_MOVE(PluginLoader)
52
53
59 void rescanNow();
60
62 [[nodiscard]] QStringList loadedPluginIds() const;
63
64 [[nodiscard]] PluginCatalog& catalog();
65 [[nodiscard]] const PluginCatalog& catalog() const;
66
67Q_SIGNALS:
71 void pluginLoaded(const QString& id);
74 void pluginUnloaded(const QString& id);
75
76private:
77 void loadPlugin(const QString& id);
78 void unloadPlugin(const QString& id);
79 void unregisterIfOurs(const QString& id, const std::shared_ptr<IBarWidgetFactory>& ours);
80
82 Registry<IBarWidgetFactory>* m_registry = nullptr;
83 PluginCatalog m_catalog;
85 QHash<QString, std::shared_ptr<IBarWidgetFactory>> m_factories;
86};
87
88} // namespace PhosphorRegistry
Definition IBarWidgetFactory.h:28
Finds the plugins of one seam, reads their metadata without loading them, and loads one only when ask...
Definition PluginCatalog.h:140
void rescanCompleted()
After every scan, whether or not anything changed.
void rescanNow()
Rescan now instead of waiting for the watch.
void pluginUnloaded(const QString &id)
The catalog withdrew a plugin this loader had registered.
void scanAndLoad()
The first scan: find, load and register every plugin, and arm the watch.
PluginLoader(Registry< IBarWidgetFactory > *registry, const QList< PluginSearchPath > &searchPaths=QList< PluginSearchPath >(), QObject *parent=nullptr)
searchPaths highest priority first.
void pluginLoaded(const QString &id)
A plugin's factory was registered.
static PluginSeam barWidgetSeam()
The bar-widget seam: plugins in <root>/bar-widget/, IID PhosphorRegistryBarWidgetPlugin_iid,...
QStringList loadedPluginIds() const
The ids of the plugins currently registered, sorted.
Definition Registry.h:88
Definition IBarWidgetFactory.h:16
One kind of plugin the suite loads, such as bar widgets.
Definition PluginCatalog.h:37