Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qgeofiletilecache_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QGEOFILETILECACHE_P_H
4#define QGEOFILETILECACHE_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <QtLocation/private/qlocationglobal_p.h>
18
19#include <QObject>
20#include "qcache3q_p.h"
21
23
25
27
28class QGeoTile;
31
32class QImage;
33
34/* This would be internal to qgeofiletilecache.cpp except that the eviction
35 * policy can't be defined without it being concrete here */
46
47/* Custom eviction policy for the disk cache, to avoid deleting all the files
48 * when the application closes */
49class Q_LOCATION_EXPORT QCache3QTileEvictionPolicy : public QCache3QDefaultEvictionPolicy<QGeoTileSpec,QGeoCachedTileDisk>
50{
51protected:
52 void aboutToBeRemoved(const QGeoTileSpec &key, QSharedPointer<QGeoCachedTileDisk> obj);
53 void aboutToBeEvicted(const QGeoTileSpec &key, QSharedPointer<QGeoCachedTileDisk> obj);
54};
55
56class Q_LOCATION_EXPORT QGeoFileTileCache : public QAbstractGeoTileCache
57{
59public:
60 QGeoFileTileCache(const QString &directory = QString(), QObject *parent = nullptr);
62
63 void setMaxDiskUsage(int diskUsage) override;
64 int maxDiskUsage() const override;
65 int diskUsage() const override;
66
67 void setMaxMemoryUsage(int memoryUsage) override;
68 int maxMemoryUsage() const override;
69 int memoryUsage() const override;
70
71 void setMinTextureUsage(int textureUsage) override;
72 void setExtraTextureUsage(int textureUsage) override;
73 int maxTextureUsage() const override;
74 int minTextureUsage() const override;
75 int textureUsage() const override;
76 void clearAll() override;
77 void clearMapId(int mapId);
78 void setCostStrategyDisk(CostStrategy costStrategy) override;
79 CostStrategy costStrategyDisk() const override;
80 void setCostStrategyMemory(CostStrategy costStrategy) override;
81 CostStrategy costStrategyMemory() const override;
82 void setCostStrategyTexture(CostStrategy costStrategy) override;
83 CostStrategy costStrategyTexture() const override;
84
85
86 QSharedPointer<QGeoTileTexture> get(const QGeoTileSpec &spec) override;
87
88 // can be called without a specific tileCache pointer
89 static void evictFromDiskCache(QGeoCachedTileDisk *td);
90 static void evictFromMemoryCache(QGeoCachedTileMemory *tm);
91
92 void insert(const QGeoTileSpec &spec,
93 const QByteArray &bytes,
94 const QString &format,
95 QAbstractGeoTileCache::CacheAreas areas = QAbstractGeoTileCache::AllCaches) override;
96
97 static QString tileSpecToFilenameDefault(const QGeoTileSpec &spec, const QString &format, const QString &directory);
98 static QGeoTileSpec filenameToTileSpecDefault(const QString &filename);
99
100protected:
101 void init() override;
102 void printStats() override;
103 void loadTiles();
104
105 QString directory() const;
106
107 QSharedPointer<QGeoCachedTileDisk> addToDiskCache(const QGeoTileSpec &spec, const QString &filename);
108 bool addToDiskCache(const QGeoTileSpec &spec, const QString &filename, const QByteArray &bytes);
109 void addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format);
110 QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QImage &image);
111 QSharedPointer<QGeoTileTexture> getFromMemory(const QGeoTileSpec &spec);
112 QSharedPointer<QGeoTileTexture> getFromDisk(const QGeoTileSpec &spec);
113
114 virtual bool isTileBogus(const QByteArray &bytes) const;
115 virtual QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const;
116 virtual QGeoTileSpec filenameToTileSpec(const QString &filename) const;
117
118 QCache3Q<QGeoTileSpec, QGeoCachedTileDisk, QCache3QTileEvictionPolicy> diskCache_;
119 QCache3Q<QGeoTileSpec, QGeoCachedTileMemory> memoryCache_;
120 QCache3Q<QGeoTileSpec, QGeoTileTexture> textureCache_;
121
123
124 int minTextureUsage_ = 0;
125 int extraTextureUsage_ = 0;
126 CostStrategy costStrategyDisk_ = ByteSize;
127 CostStrategy costStrategyMemory_ = ByteSize;
128 CostStrategy costStrategyTexture_ = ByteSize;
129 bool isDiskCostSet_ = false;
130 bool isMemoryCostSet_ = false;
131 bool isTextureCostSet_ = false;
132};
133
135
136#endif // QGEOFILETILECACHE_P_H
\inmodule QtCore
Definition qbytearray.h:57
QGeoFileTileCache * cache
QCache3Q< QGeoTileSpec, QGeoCachedTileMemory > memoryCache_
QCache3Q< QGeoTileSpec, QGeoTileTexture > textureCache_
QCache3Q< QGeoTileSpec, QGeoCachedTileDisk, QCache3QTileEvictionPolicy > diskCache_
\inmodule QtLocation
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
cache insert(employee->id(), employee)
Combined button and popup list for selecting options.
Definition image.cpp:4
static QDBusError::ErrorType get(const char *name)
GLuint64 key
GLint GLsizei GLsizei GLenum format
GLhandleARB obj
[2]
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_OBJECT