Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorRegistry::PluginLoader Class Reference

Loads every bar-widget plugin into a Registry<IBarWidgetFactory> and keeps it in step with the plugins on disk. More...

#include <PhosphorRegistry/PluginLoader.h>

Inheritance diagram for PhosphorRegistry::PluginLoader:
[legend]

Signals

void rescanCompleted ()
 After every scan, whether or not anything changed.
void pluginLoaded (const QString &id)
 A plugin's factory was registered.
void pluginUnloaded (const QString &id)
 The catalog withdrew a plugin this loader had registered.

Public Member Functions

 PluginLoader (Registry< IBarWidgetFactory > *registry, const QList< PluginSearchPath > &searchPaths=QList< PluginSearchPath >(), QObject *parent=nullptr)
 searchPaths highest priority first.
 ~PluginLoader () override
void scanAndLoad ()
 The first scan: find, load and register every plugin, and arm the watch.
void rescanNow ()
 Rescan now instead of waiting for the watch.
QStringList loadedPluginIds () const
 The ids of the plugins currently registered, sorted.
PluginCatalog & catalog ()
const PluginCatalog & catalog () const

Static Public Member Functions

static PluginSeam barWidgetSeam ()
 The bar-widget seam: plugins in <root>/bar-widget/, IID PhosphorRegistryBarWidgetPlugin_iid, ApiVersion 1.

Detailed Description

Loads every bar-widget plugin into a Registry<IBarWidgetFactory> and keeps it in step with the plugins on disk.

Discovery, vetting, overrides and live reload come from a PluginCatalog over the bar-widget seam (see barWidgetSeam). A plugin's root object implements IBarWidgetPlugin. Every bar-widget plugin is loaded as soon as it comes on offer, because the bar needs every factory to lay itself out. A plugin whose id the registry already holds is not loaded at all.

A plugin the catalog withdraws (its file is gone or now refused) is unregistered and pluginUnloaded is emitted. Its library stays mapped (PluginCatalog never unloads), so widgets it already created keep working until their parents delete them. A plugin whose library failed to load is tried again once its file changes. One that loaded but handed out no usable factory keeps its loaded code until the next start.

The Registry must outlive the loader. GUI thread only.

Constructor & Destructor Documentation

◆ PluginLoader()

PhosphorRegistry::PluginLoader::PluginLoader ( Registry< IBarWidgetFactory > * registry,
const QList< PluginSearchPath > & searchPaths = QList< PluginSearchPath >(),
QObject * parent = nullptr )
explicit

searchPaths highest priority first.

Empty means PluginCatalog::defaultSearchPaths for the bar-widget seam.

◆ ~PluginLoader()

PhosphorRegistry::PluginLoader::~PluginLoader ( )
override

Member Function Documentation

◆ barWidgetSeam()

PluginSeam PhosphorRegistry::PluginLoader::barWidgetSeam ( )
staticnodiscard

The bar-widget seam: plugins in <root>/bar-widget/, IID PhosphorRegistryBarWidgetPlugin_iid, ApiVersion 1.

◆ catalog() [1/2]

PluginCatalog & PhosphorRegistry::PluginLoader::catalog ( )
nodiscard

◆ catalog() [2/2]

const PluginCatalog & PhosphorRegistry::PluginLoader::catalog ( ) const
nodiscard

◆ loadedPluginIds()

QStringList PhosphorRegistry::PluginLoader::loadedPluginIds ( ) const
nodiscard

The ids of the plugins currently registered, sorted.

◆ pluginLoaded

void PhosphorRegistry::PluginLoader::pluginLoaded ( const QString & id)
signal

A plugin's factory was registered.

◆ pluginUnloaded

void PhosphorRegistry::PluginLoader::pluginUnloaded ( const QString & id)
signal

The catalog withdrew a plugin this loader had registered.

Its factory is unregistered, unless another owner has since replaced it.

◆ rescanCompleted

void PhosphorRegistry::PluginLoader::rescanCompleted ( )
signal

After every scan, whether or not anything changed.

◆ rescanNow()

void PhosphorRegistry::PluginLoader::rescanNow ( )

Rescan now instead of waiting for the watch.

Called from a slot that a running scan reached, the rescan runs once that scan has finished.

◆ scanAndLoad()

void PhosphorRegistry::PluginLoader::scanAndLoad ( )

The first scan: find, load and register every plugin, and arm the watch.

It runs synchronously, so connect to the registry first to see these registrations. A second call rescans, like rescanNow.


The documentation for this class was generated from the following file: