QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCTileCacheWorker.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QElapsedTimer>
4#include <QtCore/QMutex>
5#include <QtCore/QQueue>
6#include <QtCore/QString>
7#include <QtCore/QThread>
8#include <QtCore/QWaitCondition>
9
10#include <memory>
11
12class QGCMapTask;
14
15class QGCCacheWorker : public QThread
16{
17 Q_OBJECT
18
19public:
20 explicit QGCCacheWorker(QObject *parent = nullptr);
22
23 void setDatabaseFile(const QString &path) { if (isRunning()) { return; } _databasePath = path; }
24
25public slots:
26 bool enqueueTask(QGCMapTask *task);
27 void stop();
28
29signals:
30 void updateTotals(quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize);
31
32protected:
33 void run() final;
34
35private:
36 void _runTask(QGCMapTask *task);
37
38 void _saveTile(QGCMapTask *task);
39 void _getTile(QGCMapTask *task);
40 void _getTileSets(QGCMapTask *task);
41 void _createTileSet(QGCMapTask *task);
42 void _getTileDownloadList(QGCMapTask *task);
43 void _updateTileDownloadState(QGCMapTask *task);
44 void _pruneCache(QGCMapTask *task);
45 void _deleteTileSet(QGCMapTask *task);
46 void _renameTileSet(QGCMapTask *task);
47 void _resetCacheDatabase(QGCMapTask *task);
48 void _importSets(QGCMapTask *task);
49 void _exportSets(QGCMapTask *task);
50 bool _testTask(QGCMapTask *task);
51 void _emitTotals();
52
53 std::unique_ptr<QGCTileCacheDatabase> _database;
54 QMutex _taskQueueMutex;
55 QQueue<QGCMapTask*> _taskQueue;
56 QWaitCondition _waitc;
57 QString _databasePath;
58 QElapsedTimer _updateTimer;
59 int _updateTimeout = kShortTimeoutMs;
60 std::atomic_bool _dbValid = false;
61 std::atomic_bool _stopRequested = false;
62
63 static constexpr int kShortTimeoutMs = 2000;
64 static constexpr int kLongTimeoutMs = 5000;
65};
bool enqueueTask(QGCMapTask *task)
void updateTotals(quint32 totaltiles, quint64 totalsize, quint32 defaulttiles, quint64 defaultsize)
void setDatabaseFile(const QString &path)