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

Trivial IConfigStore that holds its state in process memory. More...

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

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

Public Member Functions

 InMemoryConfigStore (QObject *parent=nullptr)
 
 InMemoryConfigStore (int maxScreensPerPhysical, QObject *parent=nullptr)
 Construct with an explicit maximum-virtual-screens-per-physical cap.
 
QHash< QString, VirtualScreenConfigloadAll () const override
 Snapshot every persisted virtual-screen config, keyed by physical screen ID.
 
VirtualScreenConfig get (const QString &physicalScreenId) const override
 Single-key read for callers that only need one entry (e.g.
 
bool save (const QString &physicalScreenId, const VirtualScreenConfig &config) override
 Persist config for physicalScreenId.
 
bool remove (const QString &physicalScreenId) override
 Drop the entry for physicalScreenId.
 
- Public Member Functions inherited from Phosphor::Screens::IConfigStore
 IConfigStore (QObject *parent=nullptr)
 
 ~IConfigStore () override=default
 

Static Public Attributes

static constexpr int DefaultMaxScreensPerPhysical = 8
 Production-matching default cap.
 

Additional Inherited Members

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

Detailed Description

Trivial IConfigStore that holds its state in process memory.

Use in unit tests, in hosts that synthesise topology programmatically, and as a placeholder during ScreenManager bring-up before the host's persistent store is wired. No serialisation, no schema migration — configs disappear with the process.

Header-only and inline.

Constructor & Destructor Documentation

◆ InMemoryConfigStore() [1/2]

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

◆ InMemoryConfigStore() [2/2]

Phosphor::Screens::InMemoryConfigStore::InMemoryConfigStore ( int  maxScreensPerPhysical,
QObject *  parent = nullptr 
)
inlineexplicit

Construct with an explicit maximum-virtual-screens-per-physical cap.

Pass 0 for "no cap" (test-only; production parity requires matching the daemon's cap).

Member Function Documentation

◆ get()

VirtualScreenConfig Phosphor::Screens::InMemoryConfigStore::get ( const QString &  physicalScreenId) const
inlineoverridevirtual

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().

Implements Phosphor::Screens::IConfigStore.

◆ loadAll()

QHash< QString, VirtualScreenConfig > Phosphor::Screens::InMemoryConfigStore::loadAll ( ) const
inlineoverridevirtual

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.

Implements Phosphor::Screens::IConfigStore.

◆ remove()

bool Phosphor::Screens::InMemoryConfigStore::remove ( const QString &  physicalScreenId)
inlineoverridevirtual

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.

Implements Phosphor::Screens::IConfigStore.

◆ save()

bool Phosphor::Screens::InMemoryConfigStore::save ( const QString &  physicalScreenId,
const VirtualScreenConfig config 
)
inlineoverridevirtual

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.

Implements Phosphor::Screens::IConfigStore.

Member Data Documentation

◆ DefaultMaxScreensPerPhysical

constexpr int Phosphor::Screens::InMemoryConfigStore::DefaultMaxScreensPerPhysical = 8
staticconstexpr

Production-matching default cap.

Mirrors ScreenManagerConfig::maxVirtualScreensPerPhysical so tests that spin up a store without specifying a cap still exercise the same admission ceiling the daemon enforces. A lower default (or 0 = "no cap") silently accepted over-limit configs the real consumer would have rejected, which masked regressions at the layer boundary. Tests that deliberately want no cap pass 0 explicitly.


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