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

Pluggable configuration backend. More...

#include <phosphor-config/include/PhosphorConfig/IBackend.h>

Inheritance diagram for PhosphorConfig::IBackend:
[legend]

Public Member Functions

virtual ~IBackend ()=default
 
virtual std::unique_ptr< IGroupgroup (const QString &name)=0
 Return a scoped view into the named group.
 
virtual void reparseConfiguration ()=0
 Re-read configuration from disk, discarding any pending in-memory changes.
 
virtual bool sync ()=0
 Flush pending writes to disk.
 
virtual void deleteGroup (const QString &name)=0
 Delete an entire group and everything inside it.
 
virtual QString readRootString (const QString &key, const QString &defaultValue={}) const =0
 Read/write ungrouped (root-level) keys.
 
virtual void writeRootString (const QString &key, const QString &value)=0
 
virtual void removeRootKey (const QString &key)=0
 
virtual QStringList groupList () const =0
 Enumerate every top-level group name.
 
virtual void setPathResolver (std::shared_ptr< IGroupPathResolver >)
 Install a group-path resolver.
 
virtual std::shared_ptr< IGroupPathResolverpathResolver () const
 Currently-installed resolver, or nullptr when none is set (also the default for backends that ignore setPathResolver).
 
virtual void setVersionStamp (const QString &, int)
 Install a "stamp on first sync" version annotation: if key is absent from the backend's root on the next flush, write key = version.
 
virtual std::pair< QString, int > versionStamp () const
 Currently-installed version stamp as {key, version}.
 
virtual bool applyMigration (const Schema &)
 Apply schema's migration chain against the backend's in-memory state and commit any resulting version bump.
 
 IBackend (const IBackend &)=delete
 
IBackendoperator= (const IBackend &)=delete
 

Protected Member Functions

 IBackend ()=default
 

Detailed Description

Pluggable configuration backend.

Provides group-based access, persistence, and group enumeration. Concrete implementations: JsonBackend (atomic-write JSON file), QSettingsBackend (INI files, for legacy compatibility and migration).

Root-level ("ungrouped") access is provided via readRootString / writeRootString. How a backend stores root keys is implementation-defined: QSettings routes them to a [General] section, and JsonBackend mirrors that by keeping them under a configurable root-group name (defaults to "General").

Constructor & Destructor Documentation

◆ ~IBackend()

virtual PhosphorConfig::IBackend::~IBackend ( )
virtualdefault

◆ IBackend() [1/2]

PhosphorConfig::IBackend::IBackend ( const IBackend )
delete

◆ IBackend() [2/2]

PhosphorConfig::IBackend::IBackend ( )
protecteddefault

Member Function Documentation

◆ applyMigration()

virtual bool PhosphorConfig::IBackend::applyMigration ( const Schema )
inlinevirtual

Apply schema's migration chain against the backend's in-memory state and commit any resulting version bump.

Returns true when the backend supports schema migrations (even if no step applied — e.g. the on-disk version already matches). Returns false when the backend has no concept of a JSON-root snapshot; callers should log that declared migrations will not run. Default: no-op returning false.

Reimplemented in PhosphorConfig::JsonBackend.

◆ deleteGroup()

virtual void PhosphorConfig::IBackend::deleteGroup ( const QString &  name)
pure virtual

Delete an entire group and everything inside it.

Intermediate parents are pruned if they become empty (dot-path groups only).

Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.

◆ group()

virtual std::unique_ptr< IGroup > PhosphorConfig::IBackend::group ( const QString &  name)
pure virtual

Return a scoped view into the named group.

Caller owns the pointer; destroy it before asking for another group on this backend.

Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.

◆ groupList()

virtual QStringList PhosphorConfig::IBackend::groupList ( ) const
pure virtual

Enumerate every top-level group name.

Dot-path groups are returned with their full path ("Snapping", "Snapping.Behavior", ...). Groups produced by a plugged-in IGroupPathResolver appear in the resolver's preferred external form.

Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.

◆ operator=()

IBackend & PhosphorConfig::IBackend::operator= ( const IBackend )
delete

◆ pathResolver()

virtual std::shared_ptr< IGroupPathResolver > PhosphorConfig::IBackend::pathResolver ( ) const
inlinevirtual

Currently-installed resolver, or nullptr when none is set (also the default for backends that ignore setPathResolver).

Reimplemented in PhosphorConfig::JsonBackend.

◆ readRootString()

virtual QString PhosphorConfig::IBackend::readRootString ( const QString &  key,
const QString &  defaultValue = {} 
) const
pure virtual

Read/write ungrouped (root-level) keys.

Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.

◆ removeRootKey()

virtual void PhosphorConfig::IBackend::removeRootKey ( const QString &  key)
pure virtual

◆ reparseConfiguration()

virtual void PhosphorConfig::IBackend::reparseConfiguration ( )
pure virtual

Re-read configuration from disk, discarding any pending in-memory changes.

Must not be called while a group view is live.

Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.

◆ setPathResolver()

virtual void PhosphorConfig::IBackend::setPathResolver ( std::shared_ptr< IGroupPathResolver )
inlinevirtual

Install a group-path resolver.

The caller shares ownership via shared_ptr so multiple Stores/backends can reference the same instance. Backends that have no resolver concept return without storing the pointer.

Reimplemented in PhosphorConfig::JsonBackend.

◆ setVersionStamp()

virtual void PhosphorConfig::IBackend::setVersionStamp ( const QString &  ,
int   
)
inlinevirtual

Install a "stamp on first sync" version annotation: if key is absent from the backend's root on the next flush, write key = version.

Backends without a stamp concept ignore the call. Passing an empty key disables the stamp.

Reimplemented in PhosphorConfig::JsonBackend.

◆ sync()

virtual bool PhosphorConfig::IBackend::sync ( )
pure virtual

Flush pending writes to disk.

No-op when nothing is dirty. Returns true on success (or when there was nothing to flush), false on an I/O error — backends log the reason before returning.

Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.

◆ versionStamp()

virtual std::pair< QString, int > PhosphorConfig::IBackend::versionStamp ( ) const
inlinevirtual

Currently-installed version stamp as {key, version}.

Empty key means "no stamp installed" (also the default for backends that ignore setVersionStamp).

Reimplemented in PhosphorConfig::JsonBackend.

◆ writeRootString()

virtual void PhosphorConfig::IBackend::writeRootString ( const QString &  key,
const QString &  value 
)
pure virtual

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