Pluggable configuration backend. More...
#include <phosphor-config/include/PhosphorConfig/IBackend.h>
Public Member Functions | |
| virtual | ~IBackend ()=default |
| virtual std::unique_ptr< IGroup > | group (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< IGroupPathResolver > | pathResolver () 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 | |
| IBackend & | operator= (const IBackend &)=delete |
Protected Member Functions | |
| IBackend ()=default | |
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").
|
virtualdefault |
|
delete |
|
protecteddefault |
|
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.
|
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.
|
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.
|
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.
|
inlinevirtual |
Currently-installed resolver, or nullptr when none is set (also the default for backends that ignore setPathResolver).
Reimplemented in PhosphorConfig::JsonBackend.
|
pure virtual |
Read/write ungrouped (root-level) keys.
Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.
|
pure virtual |
Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.
|
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.
|
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.
|
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.
|
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.
|
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.
|
pure virtual |
Implemented in PhosphorConfig::JsonBackend, and PhosphorConfig::QSettingsBackend.