Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorConfig::Schema Struct Reference

Declarative description of a configuration store. More...

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

Public Member Functions

const KeyDeffindKey (const QString &group, const QString &key) const
 Look up a KeyDef by (group, key).
 
QVariant defaultFor (const QString &group, const QString &key) const
 Convenience: default value for a declared key, or QVariant() if the key is undeclared.
 

Public Attributes

int version = 1
 Current schema revision.
 
QString versionKey = QStringLiteral("_version")
 JSON key used to persist the schema version.
 
QMap< QString, QVector< KeyDef > > groups
 Keys grouped by their group name.
 
QVector< MigrationStepmigrations
 Ordered migration chain.
 
std::shared_ptr< IGroupPathResolverpathResolver
 Optional per-screen / custom name resolver.
 

Detailed Description

Declarative description of a configuration store.

Aggregates the current schema version, the JSON key that holds it, the set of groups and their keys (with defaults), any registered migrations, and an optional path resolver for custom group-name semantics.

The struct is plain data; construct it once at startup and hand it to Store (and/or MigrationRunner).

Member Function Documentation

◆ defaultFor()

QVariant PhosphorConfig::Schema::defaultFor ( const QString &  group,
const QString &  key 
) const

Convenience: default value for a declared key, or QVariant() if the key is undeclared.

◆ findKey()

const KeyDef * PhosphorConfig::Schema::findKey ( const QString &  group,
const QString &  key 
) const

Look up a KeyDef by (group, key).

Returns nullptr if the key is not declared in the schema.

Member Data Documentation

◆ groups

QMap<QString, QVector<KeyDef> > PhosphorConfig::Schema::groups

Keys grouped by their group name.

The group name format depends on the attached resolver + backend combination — the schema itself is agnostic to whether it's flat ("General"), dot-path ("Snapping.Behavior"), or resolver-translated ("Prefix:ScreenId").

QMap (sorted) rather than QHash so exportToJson and the on-disk flush loop emit groups in deterministic order — important for version-controlling exported configs and for diff-based debugging.

◆ migrations

QVector<MigrationStep> PhosphorConfig::Schema::migrations

Ordered migration chain.

MigrationRunner applies every step whose fromVersion matches the current persisted version, advancing one version at a time until it reaches Schema::version.

◆ pathResolver

std::shared_ptr<IGroupPathResolver> PhosphorConfig::Schema::pathResolver

Optional per-screen / custom name resolver.

Ownership is shared so a single resolver instance can be attached to multiple backends/stores.

◆ version

int PhosphorConfig::Schema::version = 1

Current schema revision.

Fresh stores are stamped with this value on their first successful sync. Increment in lockstep with a new MigrationStep whenever you change the on-disk shape.

◆ versionKey

QString PhosphorConfig::Schema::versionKey = QStringLiteral("_version")

JSON key used to persist the schema version.

Defaults to "_version" so it sorts to the top of most JSON libraries and won't collide with a user key. Change only if you have a legacy store with a different convention.


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