QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
21 QgsNetworkDiskCache::ExpirableNetworkDiskCache QgsNetworkDiskCache::smDiskCache;
22 QMutex QgsNetworkDiskCache::smDiskCacheMutex;
23 
24 QgsNetworkDiskCache::QgsNetworkDiskCache( QObject *parent )
25  : QNetworkDiskCache( parent )
26 {
27 }
28 
30 {
31 }
32 
34 {
35  QMutexLocker lock( &smDiskCacheMutex );
36  return smDiskCache.cacheDirectory();
37 }
38 
40 {
41  QMutexLocker lock( &smDiskCacheMutex );
42  smDiskCache.setCacheDirectory( cacheDir );
43 }
44 
46 {
47  QMutexLocker lock( &smDiskCacheMutex );
48  return smDiskCache.maximumCacheSize();
49 }
50 
52 {
53  QMutexLocker lock( &smDiskCacheMutex );
54  smDiskCache.setMaximumCacheSize( size );
55 }
56 
58 {
59  QMutexLocker lock( &smDiskCacheMutex );
60  return smDiskCache.cacheSize();
61 }
62 
64 {
65  QMutexLocker lock( &smDiskCacheMutex );
66  return smDiskCache.metaData( url );
67 }
68 
70 {
71  QMutexLocker lock( &smDiskCacheMutex );
72  smDiskCache.updateMetaData( metaData );
73 }
74 
76 {
77  QMutexLocker lock( &smDiskCacheMutex );
78  return smDiskCache.data( url );
79 }
80 
82 {
83  QMutexLocker lock( &smDiskCacheMutex );
84  return smDiskCache.remove( url );
85 }
86 
88 {
89  QMutexLocker lock( &smDiskCacheMutex );
90  return smDiskCache.prepare( metaData );
91 }
92 
94 {
95  QMutexLocker lock( &smDiskCacheMutex );
96  smDiskCache.insert( device );
97 }
98 
100 {
101  QMutexLocker lock( &smDiskCacheMutex );
102  return smDiskCache.fileMetaData( fileName );
103 }
104 
106 {
107  QMutexLocker lock( &smDiskCacheMutex );
108  return smDiskCache.runExpire();
109 }
110 
112 {
113  QMutexLocker lock( &smDiskCacheMutex );
114  return smDiskCache.clear();
115 }
bool remove(const QUrl &url) override
qint64 cacheSize() const override
void setCacheDirectory(const QString &cacheDir)
void updateMetaData(const QNetworkCacheMetaData &metaData) override
void insert(QIODevice *device) override
QString cacheDirectory() const
QNetworkCacheMetaData fileMetaData(const QString &fileName) const
virtual qint64 expire() override
QNetworkCacheMetaData metaData(const QUrl &url) override
qint64 maximumCacheSize() const
QIODevice * data(const QUrl &url) override
QIODevice * prepare(const QNetworkCacheMetaData &metaData) override
void setMaximumCacheSize(qint64 size)