RhythmGame 1.4.3
Loading...
Searching...
No Matches
BackbeatCatalog.h
Go to the documentation of this file.
1#ifndef RHYTHMGAME_BACKBEATCATALOG_H
2#define RHYTHMGAME_BACKBEATCATALOG_H
3
4#include "BackbeatSource.h"
5#include <QFutureWatcher>
6#include <QObject>
7#include <QTimer>
8#include <QThreadPool>
9#include <optional>
10
11namespace resource_managers {
12
13class BackbeatCatalog : public QObject
14{
15 Q_OBJECT
16
17 public:
18 struct Update
19 {
20 QList<Table> collections;
21 QString error;
22 std::optional<qint64> revision;
23 int added = 0;
24 int removed = 0;
25 };
26
27 BackbeatCatalog(std::shared_ptr<BackbeatSource> source,
28 const std::filesystem::path& databasePath,
29 db::SqliteCppDb* modelDatabase,
30 db::SqliteCppDb* writeDatabase,
31 QObject* parent = nullptr);
32 ~BackbeatCatalog() override;
33 void refresh(bool force = false);
34
35 // Reads through a separate connection; publication shares the scanner's
36 // writer connection so their transactions serialize without blocking UI
37 // reads.
38 auto synchronize(std::optional<qint64> previousRevision = {}) -> Update;
39
40 signals:
41 void busyChanged(bool busy);
42 void updated(const QList<resource_managers::Table>& collections);
44 void errorChanged(const QString& error);
45
46 private:
47 std::shared_ptr<BackbeatSource> source;
48 std::filesystem::path databasePath;
49 db::SqliteCppDb* modelDatabase;
50 db::SqliteCppDb* writeDatabase;
51 std::atomic_bool cancelled = false;
52 QThreadPool threadPool;
54 QTimer refreshTimer;
55 std::optional<qint64> revision;
56 bool pendingRefresh = false;
57 bool active = false;
58};
59
60} // namespace resource_managers
61#endif
Definition QtArenaRoundLoader.h:29
Database wrapper for SQLiteCpp.
Definition SqliteCppDb.h:30
Definition BackbeatCatalog.h:14
void updated(const QList< resource_managers::Table > &collections)
void refresh(bool force=false)
Definition BackbeatCatalog.cpp:61
~BackbeatCatalog() override
Definition BackbeatCatalog.cpp:54
void errorChanged(const QString &error)
auto synchronize(std::optional< qint64 > previousRevision={}) -> Update
Definition BackbeatCatalog.cpp:80
Classes and functions related to loading and managing resources such as charts, sounds,...
Definition ProfileArenaIdentityProvider.h:12
Definition BackbeatCatalog.h:19
QList< Table > collections
Definition BackbeatCatalog.h:20
int added
Definition BackbeatCatalog.h:23
QString error
Definition BackbeatCatalog.h:21
std::optional< qint64 > revision
Definition BackbeatCatalog.h:22
int removed
Definition BackbeatCatalog.h:24