1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtLocation module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36#ifndef QABSTRACTGEOTILECACHE_P_H
37#define QABSTRACTGEOTILECACHE_P_H
38
39//
40// W A R N I N G
41// -------------
42//
43// This file is not part of the Qt API. It exists purely as an
44// implementation detail. This header file may change from version to
45// version without notice, or even be removed.
46//
47// We mean it.
48//
49
50#include <QtLocation/private/qlocationglobal_p.h>
51
52#include <QObject>
53#include <QCache>
54#include "qcache3q_p.h"
55#include <QSet>
56#include <QMutex>
57#include <QTimer>
58
59#include "qgeotilespec_p.h"
60
61#include <QImage>
62
63QT_BEGIN_NAMESPACE
64
65class QGeoMappingManager;
66class QGeoMappingManagerEngine;
67
68class QGeoTile;
69class QAbstractGeoTileCache;
70
71class QThread;
72
73/* This is also used in the mapgeometry */
74class Q_LOCATION_PRIVATE_EXPORT QGeoTileTexture
75{
76public:
77
78 QGeoTileTexture();
79 ~QGeoTileTexture();
80
81 QGeoTileSpec spec;
82 QImage image;
83 bool textureBound;
84};
85
86class Q_LOCATION_PRIVATE_EXPORT QAbstractGeoTileCache : public QObject
87{
88 Q_OBJECT
89public:
90 enum CostStrategy {
91 Unitary,
92 ByteSize
93 };
94
95 enum CacheArea {
96 DiskCache = 0x01,
97 MemoryCache = 0x02,
98 AllCaches = 0xFF
99 };
100 Q_DECLARE_FLAGS(CacheAreas, CacheArea)
101
102 virtual ~QAbstractGeoTileCache();
103
104 virtual void setMaxDiskUsage(int diskUsage);
105 virtual int maxDiskUsage() const;
106 virtual int diskUsage() const;
107
108 virtual void setMaxMemoryUsage(int memoryUsage);
109 virtual int maxMemoryUsage() const;
110 virtual int memoryUsage() const;
111
112 virtual void setMinTextureUsage(int textureUsage) = 0;
113 virtual void setExtraTextureUsage(int textureUsage) = 0;
114 virtual int maxTextureUsage() const = 0;
115 virtual int minTextureUsage() const = 0;
116 virtual int textureUsage() const = 0;
117 virtual void clearAll() = 0;
118 virtual void setCostStrategyDisk(CostStrategy costStrategy) = 0;
119 virtual CostStrategy costStrategyDisk() const = 0;
120 virtual void setCostStrategyMemory(CostStrategy costStrategy) = 0;
121 virtual CostStrategy costStrategyMemory() const = 0;
122 virtual void setCostStrategyTexture(CostStrategy costStrategy) = 0;
123 virtual CostStrategy costStrategyTexture() const = 0;
124
125 virtual QSharedPointer<QGeoTileTexture> get(const QGeoTileSpec &spec) = 0;
126
127 virtual void insert(const QGeoTileSpec &spec,
128 const QByteArray &bytes,
129 const QString &format,
130 QAbstractGeoTileCache::CacheAreas areas = QAbstractGeoTileCache::AllCaches) = 0;
131 virtual void handleError(const QGeoTileSpec &spec, const QString &errorString);
132 virtual void init() = 0;
133
134 static QString baseCacheDirectory();
135 static QString baseLocationCacheDirectory();
136
137protected:
138 QAbstractGeoTileCache(QObject *parent = 0);
139 virtual void printStats() = 0;
140
141 friend class QGeoTiledMappingManagerEngine;
142};
143
144Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractGeoTileCache::CacheAreas)
145
146QT_END_NAMESPACE
147
148#endif // QABSTRACTGEOTILECACHE_P_H
149

source code of qtlocation/src/location/maps/qabstractgeotilecache_p.h