You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PayloadAPP/Src/RescueLoad/map/tianditu/include/timapcacheworker.h

69 lines
2.0 KiB
C

/**************************************************************************
* TiMapCacheWorker.h
* =======================================================================
*
* 2021-5-14
* 499131808@qq.com
* Q Q 499131808
*
*
* 使
*使,
* ======================================================================
*
*
*
* ======================================================================
*
***************************************************************************/
#pragma once
#include <QHostInfo>
#include <QMutex>
#include <QQueue>
#include <QSqlDatabase>
#include <QThread>
#include <QWaitCondition>
class TiMapTask;
/**
* @brief The TiMapCacheWorker class
* /\ 线
*/
class TiMapCacheWorker : public QThread
{
Q_OBJECT
public:
TiMapCacheWorker();
void quit();
bool enqueueTask(TiMapTask* task);
void setDBName(const QString& path);
// QThread interface
protected:
void run() override;
private:
void runTask(TiMapTask* task);
void clear();
bool init();
bool openDB();
bool createDB(QSqlDatabase& db, bool createDefault = true);
void closeDB();
void testInternet(TiMapTask* task);
bool testTask(TiMapTask* task);
void getTile(TiMapTask* task);
void saveTile(TiMapTask* task);
private:
QString m_dbPath;
QMutex m_taskQueueMutex;
QWaitCondition m_waitCond;
QQueue<TiMapTask*> m_taskQueue;
QScopedPointer<QSqlDatabase> m_db;
std::atomic_bool m_valid; // 数据库是否有效,有效指数据库打开并已初始化化
std::atomic_bool m_isInit;
int m_hostLookupID = 0;
};