Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorProfileRegistry.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7#include <PhosphorAnimation/phosphoranimation_export.h>
8
9#include <QtCore/QHash>
10#include <QtCore/QObject>
11#include <QtCore/QString>
12
13#include <atomic>
14#include <mutex>
15#include <optional>
16
17namespace PhosphorAnimation {
18
22class PHOSPHORANIMATION_EXPORT PhosphorProfileRegistry : public QObject
23{
24 Q_OBJECT
25
26public:
27 explicit PhosphorProfileRegistry(QObject* parent = nullptr);
29
32
35
38
46 std::optional<Profile> resolve(const QString& path) const;
47
72 Profile resolveWithInheritance(const QString& path) const;
73 Profile resolveWithInheritance(const QString& path, const QString& lowPrecedenceOwnerTag) const;
74
81 void setLowPrecedenceOwnerTag(const QString& tag);
82
84 void registerProfile(const QString& path, const Profile& profile);
85
87 void registerProfile(const QString& path, const Profile& profile, const QString& ownerTag);
88
90 void unregisterProfile(const QString& path);
91
94 void reloadFromOwner(const QString& ownerTag, const QHash<QString, Profile>& profiles);
95
97 void clearOwner(const QString& ownerTag);
98
100 void reloadAll(const QHash<QString, Profile>& profiles);
101
103 void clear();
104
106 QString ownerOf(const QString& path) const;
107
115 QHash<QString, Profile> snapshot() const;
116
118 int profileCount() const;
119
121 bool hasProfile(const QString& path) const;
122
123Q_SIGNALS:
125 void profileChanged(const QString& path);
126
129
131 void ownerReloaded(const QString& ownerTag);
132
133private:
134 static std::atomic<PhosphorProfileRegistry*> s_defaultRegistry;
135
136 mutable std::mutex m_mutex;
137 QHash<QString, Profile> m_profiles;
138 QHash<QString, QString> m_owners;
139 QString m_lowPrecedenceOwnerTag;
140};
141
142} // namespace PhosphorAnimation
Registry mapping profile path strings to Profile values.
Definition PhosphorProfileRegistry.h:23
void reloadAll(const QHash< QString, Profile > &profiles)
Wholesale replace the entire registry. TEST-ONLY semantics.
std::optional< Profile > resolve(const QString &path) const
Resolve path to a Profile if registered.
int profileCount() const
Current path count. Thread-safe.
Profile resolveWithInheritance(const QString &path, const QString &lowPrecedenceOwnerTag) const
void registerProfile(const QString &path, const Profile &profile, const QString &ownerTag)
Register or replace at path, stamped with an owner tag.
QHash< QString, Profile > snapshot() const
Thread-safe copy of every registered (path → Profile) pair, owner tags discarded.
Profile resolveWithInheritance(const QString &path) const
Resolve path with parent-chain inheritance.
void reloadFromOwner(const QString &ownerTag, const QHash< QString, Profile > &profiles)
Replace the subset owned by ownerTag with profiles.
void clear()
Clear the registry. Fires profilesReloaded().
PhosphorProfileRegistry(const PhosphorProfileRegistry &)=delete
void profileChanged(const QString &path)
Fired when a profile is registered, replaced, or unregistered.
void registerProfile(const QString &path, const Profile &profile)
Register or replace the profile at path (direct/untagged owner).
void ownerReloaded(const QString &ownerTag)
Fired at the end of a reloadFromOwner/clearOwner batch if any changes occurred.
static PhosphorProfileRegistry * defaultRegistry()
Read the process-wide default; nullptr if none published yet.
void clearOwner(const QString &ownerTag)
Remove every entry owned by ownerTag.
void profilesReloaded()
Fired only on wholesale operations (reloadAll, clear).
void unregisterProfile(const QString &path)
Remove path. Fires profileChanged if it existed.
QString ownerOf(const QString &path) const
Current owner tag for path, or empty string.
bool hasProfile(const QString &path) const
Is path registered? Thread-safe.
PhosphorProfileRegistry(QObject *parent=nullptr)
PhosphorProfileRegistry & operator=(const PhosphorProfileRegistry &)=delete
void setLowPrecedenceOwnerTag(const QString &tag)
Configure the owner tag whose entries should be treated as the lowest-precedence layer in resolveWith...
static void setDefaultRegistry(PhosphorProfileRegistry *registry)
Publish registry as the process-wide default for QML resolution.
Configuration for a single animation event.
Definition Profile.h:33
Definition AnimatedValue.h:31