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

Static-init self-registration helper for provider libraries. More...

#include <phosphor-layout-api/include/PhosphorLayoutApi/LayoutSourceProviderRegistry.h>

Public Member Functions

 LayoutSourceProviderRegistrar (QString name, int priority, std::function< std::unique_ptr< ILayoutSourceFactory >(const FactoryContext &)> builder)
 

Detailed Description

Static-init self-registration helper for provider libraries.

Each provider library declares an instance in an anonymous namespace inside its factory .cpp file. The constructor appends to pendingLayoutSourceProviders() at process startup, before any composition root constructs its LayoutSourceBundle.

Usage (in e.g. zoneslayoutsourcefactory.cpp):

namespace {
QStringLiteral("zones"), /*priority=*/0,
[](const PhosphorLayout::FactoryContext& ctx) -> std::unique_ptr<PhosphorLayout::ILayoutSourceFactory> {
auto* registry = ctx.get<PhosphorZones::IZoneLayoutRegistry>();
if (!registry) {
return nullptr; // composition root didn't surface this engine
}
return std::make_unique<PhosphorZones::ZonesLayoutSourceFactory>(registry);
});
}
Service registry passed to a layout-source-provider builder so it can pull whatever registries / depe...
Definition LayoutSourceProviderRegistry.h:66
T * get() const
Look up a previously-registered service.
Definition LayoutSourceProviderRegistry.h:131
Static-init self-registration helper for provider libraries.
Definition LayoutSourceProviderRegistry.h:230
Enumeration + mutation surface for the in-memory zone-layout catalog.
Definition IZoneLayoutRegistry.h:43

Adding a new layout-source family (the planned scrolling engine) is one new library + one of these registrars inside it. No edits to phosphor-layout-api, no edits to other provider libraries, and — as long as the engine pulls only services the composition root already surfaces — no edits to daemon / editor / settings either.

Constructor & Destructor Documentation

◆ LayoutSourceProviderRegistrar()

PhosphorLayout::LayoutSourceProviderRegistrar::LayoutSourceProviderRegistrar ( QString  name,
int  priority,
std::function< std::unique_ptr< ILayoutSourceFactory >(const FactoryContext &)>  builder 
)

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