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
71 Profile resolveWithInheritance(const QString& path) const;
72
79 void setLowPrecedenceOwnerTag(const QString& tag);
80
82 void registerProfile(const QString& path, const Profile& profile);
83
85 void registerProfile(const QString& path, const Profile& profile, const QString& ownerTag);
86
96 void unregisterProfile(const QString& path);
97
100 void reloadFromOwner(const QString& ownerTag, const QHash<QString, Profile>& profiles);
101
103 void clearOwner(const QString& ownerTag);
104
106 void reloadAll(const QHash<QString, Profile>& profiles);
107
109 void clear();
110
112 QString ownerOf(const QString& path) const;
113
127 QHash<QString, Profile> snapshot() const;
128
139 QHash<QString, Profile> snapshotExcludingLowPrecedence() const;
140
144 int profileCount() const;
145
147 bool hasProfile(const QString& path) const;
148
149Q_SIGNALS:
151 void profileChanged(const QString& path);
152
155
157 void ownerReloaded(const QString& ownerTag);
158
159private:
160 static std::atomic<PhosphorProfileRegistry*> s_defaultRegistry;
161
162 mutable std::mutex m_mutex;
163
167 QHash<QString, Profile> m_profiles;
168 QHash<QString, QString> m_owners;
169
177 QHash<QString, Profile> m_seedProfiles;
178
179 QString m_lowPrecedenceOwnerTag;
180};
181
182} // namespace PhosphorAnimation
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 across BOTH layers, so a registry whose whole content is seeds does not report emp...
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 NON-SEED (path → Profile) pair, owner tags discarded.
QHash< QString, Profile > snapshotExcludingLowPrecedence() const
The same content as snapshot(), named for the reason a publisher needs it.
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 from the NON-SEED layer.
QString ownerOf(const QString &path) const
Current owner tag for path, or empty string.
bool hasProfile(const QString &path) const
Is path registered in EITHER layer? 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:32