Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
Phosphor::Screens::IConfigStore Class Referenceabstract

Pluggable persistence for virtual-screen configurations. More...

#include <phosphor-screens/include/PhosphorScreens/IConfigStore.h>

Inheritance diagram for Phosphor::Screens::IConfigStore:
[legend]

Signals

void changed ()
 Some entry in the store has changed (via this interface or by an external writer — KCM, settings UI, hand-edited file).
 

Public Member Functions

 IConfigStore (QObject *parent=nullptr)
 
 ~IConfigStore () override=default
 
virtual QHash< QString, VirtualScreenConfigloadAll () const =0
 Snapshot every persisted virtual-screen config, keyed by physical screen ID.
 
virtual VirtualScreenConfig get (const QString &physicalScreenId) const =0
 Single-key read for callers that only need one entry (e.g.
 
virtual bool save (const QString &physicalScreenId, const VirtualScreenConfig &config)=0
 Persist config for physicalScreenId.
 
virtual bool remove (const QString &physicalScreenId)=0
 Drop the entry for physicalScreenId.
 

Detailed Description

Pluggable persistence for virtual-screen configurations.

The library never reads JSON, never touches ~/.config, and never knows the schema-version migration rules. The host (daemon, KCM, test harness) implements this interface and ScreenManager treats it as the single source of truth: writes go through save / remove, the changed signal triggers a refreshVirtualConfigs cycle, reads come back via loadAll.

Implementations are owned by the consumer; lifetime must outlive the ScreenManager that holds the pointer.

Threading: ScreenManager calls every method on the GUI thread; the changed signal must be emitted on the GUI thread.

Validation: implementations should accept whatever VirtualScreenConfig::isValid accepts and reject the rest. Returning false from save is an explicit "rejected"; ScreenManager logs and leaves its cache untouched.

Constructor & Destructor Documentation

◆ IConfigStore()

Phosphor::Screens::IConfigStore::IConfigStore ( QObject *  parent = nullptr)
inlineexplicit

◆ ~IConfigStore()

Phosphor::Screens::IConfigStore::~IConfigStore ( )
overridedefault

Member Function Documentation

◆ changed

void Phosphor::Screens::IConfigStore::changed ( )
signal

Some entry in the store has changed (via this interface or by an external writer — KCM, settings UI, hand-edited file).

Listeners should re-read via loadAll and apply the delta. The signal is deliberately coarse-grained: it does not say which entry changed because external writers can't always pinpoint that.

◆ get()

virtual VirtualScreenConfig Phosphor::Screens::IConfigStore::get ( const QString &  physicalScreenId) const
pure virtual

Single-key read for callers that only need one entry (e.g.

the VirtualScreenSwapper, which mutates one physical screen at a time). Returns an empty config if no entry exists for physicalScreenId — callers can distinguish via isEmpty().

Implemented in Phosphor::Screens::InMemoryConfigStore.

◆ loadAll()

virtual QHash< QString, VirtualScreenConfig > Phosphor::Screens::IConfigStore::loadAll ( ) const
pure virtual

Snapshot every persisted virtual-screen config, keyed by physical screen ID.

Empty configs are NOT included — absence means "no subdivision". Callers should treat the returned map as authoritative and fully replace any prior cache.

Implemented in Phosphor::Screens::InMemoryConfigStore.

◆ remove()

virtual bool Phosphor::Screens::IConfigStore::remove ( const QString &  physicalScreenId)
pure virtual

Drop the entry for physicalScreenId.

No-op + true if no entry exists; a removal of a missing entry is not an error.

Contract: remove(id) MUST be functionally equivalent to save(id, VirtualScreenConfig{}) — i.e. both forms drop the entry and emit changed(). The empty-config-as-removal sentinel exists because some hosts (Settings-backed adapters) have a single unified setter on their underlying store; exposing both forms lets callers use whichever reads more cleanly at the call site without forcing implementers to duplicate the mutation path.

Returns
true if the entry was dropped OR did not exist. false is reserved for backing-store write failure.

Implemented in Phosphor::Screens::InMemoryConfigStore.

◆ save()

virtual bool Phosphor::Screens::IConfigStore::save ( const QString &  physicalScreenId,
const VirtualScreenConfig config 
)
pure virtual

Persist config for physicalScreenId.

An empty config is a removal request; implementations should drop the entry rather than store an empty marker.

Returns
true if accepted (and persisted, if applicable). false if the config failed validation or could not be written.

Implemented in Phosphor::Screens::InMemoryConfigStore.


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