QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsnetworkdiskcache.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsnetworkdiskcache.cpp - Thread-safe interface for QNetworkDiskCache
3 -------------------
4 begin : 2016-03-05
5 copyright : (C) 2016 by Juergen E. Fischer
6 email : jef at norbit dot de
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18
19#include "qgsnetworkdiskcache.h"
20
22ExpirableNetworkDiskCache QgsNetworkDiskCache::sDiskCache;
24QMutex QgsNetworkDiskCache::sDiskCacheMutex;
25
26QgsNetworkDiskCache::QgsNetworkDiskCache( QObject *parent )
27 : QNetworkDiskCache( parent )
28{
29}
30
32{
33 const QMutexLocker lock( &sDiskCacheMutex );
34 return sDiskCache.cacheDirectory();
35}
36
37void QgsNetworkDiskCache::setCacheDirectory( const QString &cacheDir )
38{
39 const QMutexLocker lock( &sDiskCacheMutex );
40 sDiskCache.setCacheDirectory( cacheDir );
41}
42
44{
45 const QMutexLocker lock( &sDiskCacheMutex );
46 return sDiskCache.maximumCacheSize();
47}
48
50{
51 const QMutexLocker lock( &sDiskCacheMutex );
52 sDiskCache.setMaximumCacheSize( size );
53}
54
56{
57 const QMutexLocker lock( &sDiskCacheMutex );
58 return sDiskCache.cacheSize();
59}
60
61QNetworkCacheMetaData QgsNetworkDiskCache::metaData( const QUrl &url )
62{
63 const QMutexLocker lock( &sDiskCacheMutex );
64 return sDiskCache.metaData( url );
65}
66
67void QgsNetworkDiskCache::updateMetaData( const QNetworkCacheMetaData &metaData )
68{
69 const QMutexLocker lock( &sDiskCacheMutex );
70 sDiskCache.updateMetaData( metaData );
71}
72
73QIODevice *QgsNetworkDiskCache::data( const QUrl &url )
74{
75 const QMutexLocker lock( &sDiskCacheMutex );
76 return sDiskCache.data( url );
77}
78
79bool QgsNetworkDiskCache::remove( const QUrl &url )
80{
81 const QMutexLocker lock( &sDiskCacheMutex );
82 return sDiskCache.remove( url );
83}
84
85QIODevice *QgsNetworkDiskCache::prepare( const QNetworkCacheMetaData &metaData )
86{
87 const QMutexLocker lock( &sDiskCacheMutex );
88 return sDiskCache.prepare( metaData );
89}
90
91void QgsNetworkDiskCache::insert( QIODevice *device )
92{
93 const QMutexLocker lock( &sDiskCacheMutex );
94 sDiskCache.insert( device );
95}
96
97QNetworkCacheMetaData QgsNetworkDiskCache::fileMetaData( const QString &fileName ) const
98{
99 const QMutexLocker lock( &sDiskCacheMutex );
100 return sDiskCache.fileMetaData( fileName );
101}
102
104{
105 const QMutexLocker lock( &sDiskCacheMutex );
106 return sDiskCache.runExpire();
107}
108
110{
111 const QMutexLocker lock( &sDiskCacheMutex );
112 return sDiskCache.clear();
113}
void setCacheDirectory(const QString &cacheDir)
QIODevice * data(const QUrl &url) override
void updateMetaData(const QNetworkCacheMetaData &metaData) override
QNetworkCacheMetaData metaData(const QUrl &url) override
qint64 maximumCacheSize() const
QNetworkCacheMetaData fileMetaData(const QString &fileName) const
void insert(QIODevice *device) override
QIODevice * prepare(const QNetworkCacheMetaData &metaData) override
bool remove(const QUrl &url) override
void setMaximumCacheSize(qint64 size)
qint64 cacheSize() const override
QString cacheDirectory() const
qint64 expire() override