Qt
6.x
The Qt SDK
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
22
#include "
qabstractgeotilecache_p.h
"
23
24
QT_BEGIN_NAMESPACE
25
26
class
QGeoMappingManager
;
27
28
class
QGeoTile;
29
class
QGeoCachedTileMemory
;
30
class
QGeoFileTileCache
;
31
32
class
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 */
36
class
QGeoCachedTileDisk
37
{
38
public
:
39
~QGeoCachedTileDisk
();
40
41
QGeoTileSpec
spec
;
42
QString
filename
;
43
QString
format
;
44
QGeoFileTileCache
*
cache
=
nullptr
;
45
};
46
47
/* Custom eviction policy for the disk cache, to avoid deleting all the files
48
* when the application closes */
49
class
Q_LOCATION_PRIVATE_EXPORT
QCache3QTileEvictionPolicy
:
public
QCache3QDefaultEvictionPolicy
<QGeoTileSpec,QGeoCachedTileDisk>
50
{
51
protected
:
52
void
aboutToBeRemoved
(
const
QGeoTileSpec
&
key
,
QSharedPointer<QGeoCachedTileDisk>
obj
);
53
void
aboutToBeEvicted
(
const
QGeoTileSpec
&
key
,
QSharedPointer<QGeoCachedTileDisk>
obj
);
54
};
55
56
class
Q_LOCATION_PRIVATE_EXPORT
QGeoFileTileCache
:
public
QAbstractGeoTileCache
57
{
58
Q_OBJECT
59
public
:
60
QGeoFileTileCache
(
const
QString
&
directory
=
QString
(),
QObject
*
parent
=
nullptr
);
61
~QGeoFileTileCache
();
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
100
protected
:
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
122
QString
directory_
;
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
134
QT_END_NAMESPACE
135
136
#endif
// QGEOFILETILECACHE_P_H
QAbstractGeoTileCache
Definition
qabstractgeotilecache_p.h:46
QAbstractGeoTileCache::CostStrategy
CostStrategy
Definition
qabstractgeotilecache_p.h:49
QAbstractGeoTileCache::AllCaches
@ AllCaches
Definition
qabstractgeotilecache_p.h:57
QByteArray
\inmodule QtCore
Definition
qbytearray.h:57
QCache3QDefaultEvictionPolicy
Definition
qcache3q_p.h:24
QCache3QDefaultEvictionPolicy::aboutToBeEvicted
void aboutToBeEvicted(const Key &key, QSharedPointer< T > obj)
Definition
qcache3q_p.h:34
QCache3QDefaultEvictionPolicy::aboutToBeRemoved
void aboutToBeRemoved(const Key &key, QSharedPointer< T > obj)
Definition
qcache3q_p.h:41
QCache3QTileEvictionPolicy
Definition
qgeofiletilecache_p.h:50
QCache3Q
Definition
qcache3q_p.h:76
QGeoCachedTileDisk
Definition
qgeofiletilecache_p.h:37
QGeoCachedTileDisk::cache
QGeoFileTileCache * cache
Definition
qgeofiletilecache_p.h:44
QGeoCachedTileDisk::filename
QString filename
Definition
qgeofiletilecache_p.h:42
QGeoCachedTileDisk::format
QString format
Definition
qgeofiletilecache_p.h:43
QGeoCachedTileDisk::spec
QGeoTileSpec spec
Definition
qgeofiletilecache_p.h:41
QGeoCachedTileDisk::~QGeoCachedTileDisk
~QGeoCachedTileDisk()
Definition
qgeofiletilecache.cpp:46
QGeoCachedTileMemory
Definition
qgeofiletilecache.cpp:18
QGeoFileTileCache
Definition
qgeofiletilecache_p.h:57
QGeoFileTileCache::memoryCache_
QCache3Q< QGeoTileSpec, QGeoCachedTileMemory > memoryCache_
Definition
qgeofiletilecache_p.h:119
QGeoFileTileCache::textureCache_
QCache3Q< QGeoTileSpec, QGeoTileTexture > textureCache_
Definition
qgeofiletilecache_p.h:120
QGeoFileTileCache::directory_
QString directory_
Definition
qgeofiletilecache_p.h:122
QGeoFileTileCache::diskCache_
QCache3Q< QGeoTileSpec, QGeoCachedTileDisk, QCache3QTileEvictionPolicy > diskCache_
Definition
qgeofiletilecache_p.h:118
QGeoMappingManager
\inmodule QtLocation
Definition
qgeomappingmanager_p.h:35
QGeoTileSpec
Definition
qgeotilespec_p.h:32
QImage
\inmodule QtGui
Definition
qimage.h:37
QObject
\inmodule QtCore
Definition
qobject.h:90
QSharedPointer
\inmodule QtCore
Definition
qsharedpointer_impl.h:256
QString
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition
qstring.h:127
insert
cache insert(employee->id(), employee)
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1545
image
Definition
image.cpp:4
qabstractgeotilecache_p.h
qcache3q_p.h
get
static QDBusError::ErrorType get(const char *name)
Definition
qdbuserror.cpp:55
key
GLuint64 key
Definition
qopengles2ext.h:2268
format
GLint GLsizei GLsizei GLenum format
Definition
qopengles2ext.h:206
obj
GLhandleARB obj
[2]
Definition
qopenglext.h:4164
init
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
Definition
qtextboundaryfinder.cpp:10
Q_OBJECT
#define Q_OBJECT
Definition
qtmetamacros.h:117
directory
QString directory
Definition
src_network_access_qnetworkdiskcache.cpp:7
parent
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
Definition
uiaclientinterfaces_p.h:209
qtlocation
src
location
maps
qgeofiletilecache_p.h
Generated by
1.9.7