Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
MetadataPackRegistryBase.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 <PhosphorFsLoader/phosphorfsloader_export.h>
8
9#include <QtCore/QObject>
10#include <QtCore/QString>
11#include <QtCore/QStringList>
12
13#include <memory>
14
15QT_BEGIN_NAMESPACE
16class QLoggingCategory;
17QT_END_NAMESPACE
18
19namespace PhosphorFsLoader {
20
21class IScanStrategy;
22
60class PHOSPHORFSLOADER_EXPORT MetadataPackRegistryBase : public QObject
61{
62 Q_OBJECT
63 Q_DISABLE_COPY_MOVE(MetadataPackRegistryBase)
64
65public:
67
79 void addSearchPath(const QString& path, LiveReload liveReload = LiveReload::On);
80
94 void addSearchPaths(const QStringList& paths, LiveReload liveReload = LiveReload::On,
95 RegistrationOrder order = RegistrationOrder::LowestPriorityFirst);
96
99 QStringList searchPaths() const;
100
118 void setUserPath(const QString& path);
119
125 Q_INVOKABLE void refresh();
126
127protected:
148 MetadataPackRegistryBase(const QLoggingCategory& logCat, std::unique_ptr<IScanStrategy> strategy,
149 QObject* parent = nullptr);
150
157 virtual void onUserPathChanged(const QString& path) = 0;
158
164 {
165 return m_strategy.get();
166 }
167
172 {
173 return m_watcher.get();
174 }
175
176private:
177 // Declaration order is load-bearing for destruction safety: members
178 // are torn down in reverse declaration order, so `m_watcher` (which
179 // holds a borrowed reference into `*m_strategy`) MUST be declared
180 // AFTER `m_strategy`. Without this ordering, the strategy reference
181 // inside the watcher would dangle during base teardown.
182 std::unique_ptr<IScanStrategy> m_strategy;
183 std::unique_ptr<WatchedDirectorySet> m_watcher;
184 QString m_userPath;
185 const QLoggingCategory* m_logCat;
186};
187
188} // namespace PhosphorFsLoader
Pluggable enumeration / parse / commit policy for WatchedDirectorySet.
Definition IScanStrategy.h:63
QObject base for registries hosting a MetadataPackScanStrategy<Payload>.
Definition MetadataPackRegistryBase.h:61
MetadataPackRegistryBase(const QLoggingCategory &logCat, std::unique_ptr< IScanStrategy > strategy, QObject *parent=nullptr)
Construct the base, taking ownership of strategy.
IScanStrategy * strategy() const
Strategy accessor for subclasses.
Definition MetadataPackRegistryBase.h:163
void addSearchPath(const QString &path, LiveReload liveReload=LiveReload::On)
Add a single search-path directory.
QStringList searchPaths() const
Currently-registered search paths in registration order.
WatchedDirectorySet * watcher() const
Watcher accessor for subclasses that need direct ops not covered by the base API (e....
Definition MetadataPackRegistryBase.h:171
void setUserPath(const QString &path)
Mark path as the user-data root for isUser classification on discovered packs.
virtual void onUserPathChanged(const QString &path)=0
Hook invoked from setUserPath when the path actually changes.
void addSearchPaths(const QStringList &paths, LiveReload liveReload=LiveReload::On, RegistrationOrder order=RegistrationOrder::LowestPriorityFirst)
Add multiple search-path directories in one shot.
void refresh()
Synchronous rescan — re-walks every search path on the calling stack, replaces the strategy's pack ma...
Watcher + debounce + rescan scaffolding for filesystem-backed loaders.
Definition WatchedDirectorySet.h:102
Definition DirectoryLoader.h:18
RegistrationOrder
Caller's declared priority direction for registerDirectories / setDirectories input.
Definition WatchedDirectorySet.h:58
LiveReload
Opt-in policy for directory watching.
Definition WatchedDirectorySet.h:34