Concrete tiling-algorithm registry. More...
#include <phosphor-tiles/include/PhosphorTiles/AlgorithmRegistry.h>
Public Member Functions | |
| void | cleanup () |
| Early cleanup of all registered algorithms. | |
| void | registerAlgorithm (const QString &id, TilingAlgorithm *algorithm) override |
Register an algorithm under id. | |
| bool | unregisterAlgorithm (const QString &id) override |
Unregister and delete the algorithm with id. | |
| TilingAlgorithm * | algorithm (const QString &id) const override |
| Resolve an algorithm by its stable id. | |
| QStringList | availableAlgorithms () const override |
| All registered algorithm ids, in registration order. | |
| QList< TilingAlgorithm * > | allAlgorithms () const override |
| Every registered algorithm pointer. | |
| bool | hasAlgorithm (const QString &id) const override |
Whether an algorithm is registered under id. | |
| TilingAlgorithm * | defaultAlgorithm () const override |
| Convenience: the registry's recommended default algorithm. | |
| QString | defaultAlgorithmId () const override |
| Get the library's recommended default algorithm ID. | |
| void | setPreviewParams (const AlgorithmPreviewParams ¶ms) override |
| Apply the user-configured tiling parameters. | |
| const AlgorithmPreviewParams & | previewParams () const noexcept override |
| The currently-configured preview parameters. | |
| AlgorithmRegistry (QObject *parent=nullptr) | |
| Composition roots (daemon, editor, settings, tests) construct their own registry instance. | |
| ~AlgorithmRegistry () override | |
Public Member Functions inherited from PhosphorTiles::ITileAlgorithmRegistry | |
| ITileAlgorithmRegistry (QObject *parent=nullptr) | |
| ~ITileAlgorithmRegistry () override | |
Public Member Functions inherited from PhosphorLayout::ILayoutSourceRegistry | |
| ILayoutSourceRegistry (QObject *parent=nullptr) | |
| ~ILayoutSourceRegistry () override | |
Static Public Member Functions | |
| static QString | staticDefaultAlgorithmId () |
Static accessor for the same id defaultAlgorithmId() returns. | |
Static Public Attributes | |
| static constexpr int | PreviewCanvasSize = 1000 |
| Canvas edge length used by every preview path that converts algorithm output into relative (0.0–1.0) geometry. | |
Additional Inherited Members | |
Signals inherited from PhosphorTiles::ITileAlgorithmRegistry | |
| void | algorithmRegistered (const QString &id) |
| An algorithm has been registered. | |
| void | algorithmUnregistered (const QString &id, bool replacing) |
| An algorithm has been unregistered or is being replaced. | |
| void | previewParamsChanged () |
Preview parameters changed via setPreviewParams. | |
Signals inherited from PhosphorLayout::ILayoutSourceRegistry | |
| void | contentsChanged () |
| Emitted when the set of layouts this registry produces changes in any way that invalidates cached previews — entries added, removed, renamed, or re-parameterised. | |
Concrete tiling-algorithm registry.
Implements the ITileAlgorithmRegistry contract. Composition roots (daemon, editor, settings, tests) construct their own instance and inject it into every consumer that needs algorithm enumeration / lookup / preview-param access. There is no process-global singleton — plugin-based compositor/WM/shell deployment requires per-instance ownership so plugins cannot corrupt each other's registry state.
Built-in algorithms (BSP, Master-Stack, Columns) register automatically in the constructor via the static pendingAlgorithmRegistrations list populated by AlgorithmRegistrar. Additional scripted algorithms are loaded by ScriptedAlgorithmLoader against an injected registry.
algorithm, availableAlgorithms, hasAlgorithm) are thread-safe once construction has completed. Registration/unregistration should only occur from the thread that owns the registry (typically the main thread).
|
explicit |
Composition roots (daemon, editor, settings, tests) construct their own registry instance.
Built-in algorithms register automatically in the constructor.
|
override |
|
overridevirtual |
Resolve an algorithm by its stable id.
Returns nullptr when no algorithm with that id is registered.
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
overridevirtual |
Every registered algorithm pointer.
Ownership stays with the registry.
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
overridevirtual |
All registered algorithm ids, in registration order.
Implements PhosphorTiles::ITileAlgorithmRegistry.
| void PhosphorTiles::AlgorithmRegistry::cleanup | ( | ) |
Early cleanup of all registered algorithms.
Wired to QCoreApplication::aboutToQuit so algorithm objects (especially ScriptedAlgorithm instances with QJSEngine internals) are destroyed while Qt is still fully alive, avoiding teardown crashes if an instance outlives QCoreApplication.
Drains exclusively this registry's own pending deleteLater() algorithms (tracked in m_pendingDeletes), never the process- wide DeferredDelete queue. This narrow scoping is load-bearing after the singleton kill in PR #343: multiple registries (daemon, editor, settings) each connect to aboutToQuit, and a process-wide drain from one registry would force-delete pending deleteLater() events for unrelated subsystems whose owners have not yet run their teardown.
Safe to call from the destructor as well — idempotent after the first invocation.
|
overridevirtual |
Convenience: the registry's recommended default algorithm.
Resolves defaultAlgorithmId() via algorithm() and falls back to the first-registered algorithm if the configured default isn't present. Concrete registries override defaultAlgorithmId to publish their policy id; tests can override either to inject a fake.
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
inlineoverridevirtual |
Get the library's recommended default algorithm ID.
Owned by the algorithm layer itself (not the application config layer) so the registry remains self-contained. Application config layers may expose their own user-facing default; that is intentionally independent.
Returns the same id from any instance (type-level policy, not per-instance state) — the static helper defaultAlgorithmId() is still available for callers that don't hold a registry pointer.
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
overridevirtual |
Whether an algorithm is registered under id.
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
overridevirtualnoexcept |
The currently-configured preview parameters.
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
overridevirtual |
Register an algorithm under id.
Ownership transfers to the registry. Re-registering an existing id replaces the old algorithm; algorithmUnregistered(id, replacing=true) fires before algorithmRegistered(id).
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
overridevirtual |
Apply the user-configured tiling parameters.
Emits previewParamsChanged when the stored value differs from the new one; AutotileLayoutSource reacts by invalidating its preview cache.
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
static |
Static accessor for the same id defaultAlgorithmId() returns.
Provided for callers that already had a hard dependency on the concrete AlgorithmRegistry type.
|
overridevirtual |
Unregister and delete the algorithm with id.
Returns true when an algorithm was found and removed.
Implements PhosphorTiles::ITileAlgorithmRegistry.
|
staticconstexpr |
Canvas edge length used by every preview path that converts algorithm output into relative (0.0–1.0) geometry.
Exposed publicly so external callers (e.g. AutotileLayoutSource, SettingsController's live-param preview) scale against the same canvas without drift.