Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorAnimation::ProfileTree Class Reference

Hierarchical profile storage with walk-up inheritance. More...

#include <phosphor-animation/include/PhosphorAnimation/ProfileTree.h>

Public Member Functions

 ProfileTree ()=default
 
 ProfileTree (const ProfileTree &)=default
 
ProfileTreeoperator= (const ProfileTree &)=default
 
 ProfileTree (ProfileTree &&)=default
 
ProfileTreeoperator= (ProfileTree &&)=default
 
Profile resolve (const QString &path) const
 Resolve effective Profile for path (walks parents, fills defaults).
 
Profile overlayChainOnto (const QString &path, Profile base) const
 Overlay ONLY this tree's override chain for path onto base — the tree's own baseline is ignored and no library defaults are filled.
 
Profile directOverride (const QString &path) const
 Direct override at path without walking parents.
 
bool hasOverride (const QString &path) const
 
QStringList overriddenPaths () const
 Every path with a direct override, in insertion order.
 
bool hasAnyOverride () const
 True when no path in the tree carries an override.
 
void setOverride (const QString &path, const Profile &profile)
 Install an explicit override. Empty path is rejected (no-op).
 
bool clearOverride (const QString &path)
 Remove the override at path. Returns true if one was removed.
 
void clearAllOverrides ()
 
Profile baseline () const
 The baseline "global" profile — always participates in resolution.
 
void setBaseline (const Profile &profile)
 
QJsonObject toJson () const
 Serialize the entire tree.
 
bool operator== (const ProfileTree &other) const
 
bool operator!= (const ProfileTree &other) const
 

Static Public Member Functions

static ProfileTree fromJson (const QJsonObject &obj, const CurveRegistry &registry)
 Parse from JSON.
 

Detailed Description

Hierarchical profile storage with walk-up inheritance.

Sparse map from dot-paths (see ProfilePaths.h) to Profile overrides plus a baseline. resolve() walks the chain and fills library defaults. Schema-less beyond the dot-path convention — plugins add paths freely. Not internally synchronized (value type).

Constructor & Destructor Documentation

◆ ProfileTree() [1/3]

PhosphorAnimation::ProfileTree::ProfileTree ( )
default

◆ ProfileTree() [2/3]

PhosphorAnimation::ProfileTree::ProfileTree ( const ProfileTree )
default

◆ ProfileTree() [3/3]

PhosphorAnimation::ProfileTree::ProfileTree ( ProfileTree &&  )
default

Member Function Documentation

◆ baseline()

Profile PhosphorAnimation::ProfileTree::baseline ( ) const
inline

The baseline "global" profile — always participates in resolution.

◆ clearAllOverrides()

void PhosphorAnimation::ProfileTree::clearAllOverrides ( )

◆ clearOverride()

bool PhosphorAnimation::ProfileTree::clearOverride ( const QString &  path)

Remove the override at path. Returns true if one was removed.

◆ directOverride()

Profile PhosphorAnimation::ProfileTree::directOverride ( const QString &  path) const

Direct override at path without walking parents.

Use hasOverride() to distinguish absent from all-unset.

◆ fromJson()

static ProfileTree PhosphorAnimation::ProfileTree::fromJson ( const QJsonObject &  obj,
const CurveRegistry registry 
)
static

Parse from JSON.

Invalid entries fall back to default Profile; empty paths are dropped. registry forwarded to Profile::fromJson.

◆ hasAnyOverride()

bool PhosphorAnimation::ProfileTree::hasAnyOverride ( ) const

True when no path in the tree carries an override.

Prefer this over overriddenPaths().isEmpty() on a hot path: the latter returns a QStringList BY VALUE, so a mere emptiness test costs a copy-on-write refcount atomic pair. The compositor's default-state fast path runs it per animated snap and per shader install, where the whole point is to be free.

◆ hasOverride()

bool PhosphorAnimation::ProfileTree::hasOverride ( const QString &  path) const

◆ operator!=()

bool PhosphorAnimation::ProfileTree::operator!= ( const ProfileTree other) const
inline

◆ operator=() [1/2]

ProfileTree & PhosphorAnimation::ProfileTree::operator= ( const ProfileTree )
default

◆ operator=() [2/2]

ProfileTree & PhosphorAnimation::ProfileTree::operator= ( ProfileTree &&  )
default

◆ operator==()

bool PhosphorAnimation::ProfileTree::operator== ( const ProfileTree other) const

◆ overlayChainOnto()

Profile PhosphorAnimation::ProfileTree::overlayChainOnto ( const QString &  path,
Profile  base 
) const

Overlay ONLY this tree's override chain for path onto base — the tree's own baseline is ignored and no library defaults are filled.

Each engaged override field (closest-to-root first, leaf wins) replaces the matching field in base; any field that no override in the chain sets keeps its value from base. Returns base unchanged when no node in the chain has an override.

Use this to layer per-event overrides on top of an externally-owned base profile (e.g. a consumer that holds the authoritative "global" elsewhere) without importing this tree's baseline — resolve() would instead start from m_baseline and collapse an empty chain to the library default.

The tree carries TWO representations of the global level, and only one is skipped. The BASELINE is ignored, as above. But an OVERRIDE stored at the literal path "global" is a genuine chain member (ProfilePaths::parentPath routes every category root there), so it overlays on top of base like any other ancestor. The two never collide today because the D-Bus adaptor routes a Global-keyed profile to setBaseline() and every other path to setOverride(); putting a global profile through setOverride() instead would double-apply it over the caller's own base.

◆ overriddenPaths()

QStringList PhosphorAnimation::ProfileTree::overriddenPaths ( ) const

Every path with a direct override, in insertion order.

◆ resolve()

Profile PhosphorAnimation::ProfileTree::resolve ( const QString &  path) const

Resolve effective Profile for path (walks parents, fills defaults).

withDefaults() backfills anything the chain left unset, including curve (a default Easing) — so every field is concrete on return EXCEPT presetName, which has no library default and may still be disengaged.

◆ setBaseline()

void PhosphorAnimation::ProfileTree::setBaseline ( const Profile profile)

◆ setOverride()

void PhosphorAnimation::ProfileTree::setOverride ( const QString &  path,
const Profile profile 
)

Install an explicit override. Empty path is rejected (no-op).

◆ toJson()

QJsonObject PhosphorAnimation::ProfileTree::toJson ( ) const

Serialize the entire tree.

Overrides stored as JSON array (not object) so insertion order round-trips losslessly.


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