libosmscout  1.1.1
DBJob.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_DBOPERATION_H
2 #define OSMSCOUT_CLIENT_QT_DBOPERATION_H
3 
4 /*
5  OSMScout - a Qt backend for libosmscout and libosmscout-map
6  Copyright (C) 2017 Lukas Karas
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22 
23 #include <QObject>
24 #include <QHash>
25 #include <QList>
26 #include <QThread>
27 #include <QReadWriteLock>
28 
30 #include <osmscout/DBInstance.h>
31 #include <osmscout/DataTileCache.h>
32 
34 
35 namespace osmscout {
36 
40 class OSMSCOUT_CLIENT_QT_API DBJob : public QObject{
41  Q_OBJECT
42 
43 protected:
45  std::list<DBInstanceRef> databases;
46  QReadLocker *locker;
47  QThread *thread;
48 
49 public:
50  DBJob();
51  ~DBJob() override;
52 
53  virtual void Run(const osmscout::BasemapDatabaseRef& basempaDatabase,
54  const std::list<DBInstanceRef> &databases, QReadLocker *locker);
55  virtual void Close();
56 };
57 
59  Q_OBJECT
60 protected:
65  QMap<QString,osmscout::MapService::CallbackId> callbacks;
66 
67  QMap<QString,QMap<osmscout::TileKey,osmscout::TileRef>> allTiles;
68  QMap<QString,QMap<osmscout::TileKey,osmscout::TileRef>> loadingTiles;
69  QMap<QString,QMap<osmscout::TileKey,osmscout::TileRef>> loadedTiles;
70 
71 protected slots:
72  void onTileStateChanged(QString dbPath,const osmscout::TileRef tile);
73 
74 signals:
78  void tileStateChanged(QString dbPath,const osmscout::TileRef tile);
79 
80  void databaseLoaded(QString dbPath,QList<osmscout::TileRef> tiles);
81 
82  void finished(QMap<QString,QMap<osmscout::TileKey,osmscout::TileRef>> tiles);
83 
84 public:
85  DBLoadJob(osmscout::MercatorProjection lookupProjection,
86  unsigned long maximumAreaLevel,
87  bool lowZoomOptimization,
88  bool closeOnFinish=true);
89  ~DBLoadJob() override;
90 
91  void Run(const osmscout::BasemapDatabaseRef& basempaDatabase,
92  const std::list<DBInstanceRef> &databases,
93  QReadLocker *locker) override;
94  void Close() override;
95 
96  bool IsFinished() const;
97  QMap<QString,QMap<osmscout::TileKey,osmscout::TileRef>> GetAllTiles() const;
98 
108  bool AddTileDataToMapData(QString dbPath,
109  const QList<osmscout::TileRef> &tiles,
110  osmscout::MapData &data);
111 };
112 
113 }
114 
115 #endif /* OSMSCOUT_CLIENT_QT_DBOPERATION_H */
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
std::list< DBInstanceRef > databases
borrowed databases
Definition: DBJob.h:45
QMap< QString, QMap< osmscout::TileKey, osmscout::TileRef > > loadedTiles
Definition: DBJob.h:69
std::shared_ptr< Breaker > BreakerRef
Definition: Breaker.h:65
std::shared_ptr< Tile > TileRef
Definition: DataTileCache.h:443
QReadLocker * locker
database locker
Definition: DBJob.h:46
Definition: MapService.h:52
Definition: Projection.h:333
osmscout::BreakerRef breaker
Definition: DBJob.h:62
QThread * thread
job thread
Definition: DBJob.h:47
osmscout::AreaSearchParameter searchParameter
Definition: DBJob.h:64
Definition: Area.h:38
osmscout::MercatorProjection lookupProjection
Definition: DBJob.h:63
Definition: DBJob.h:40
QMap< QString, QMap< osmscout::TileKey, osmscout::TileRef > > loadingTiles
Definition: DBJob.h:68
QMap< QString, osmscout::MapService::CallbackId > callbacks
Definition: DBJob.h:65
Definition: DBJob.h:58
osmscout::BasemapDatabaseRef basemapDatabase
Optional reference to the basemap database.
Definition: DBJob.h:44
bool closeOnFinish
Definition: DBJob.h:61
QMap< QString, QMap< osmscout::TileKey, osmscout::TileRef > > allTiles
Definition: DBJob.h:67
std::shared_ptr< BasemapDatabase > BasemapDatabaseRef
Reference counted reference to an Database instance.
Definition: BasemapDatabase.h:88