QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
22 ExpirableNetworkDiskCache QgsNetworkDiskCache::sDiskCache;
24 QMutex QgsNetworkDiskCache::sDiskCacheMutex;
25 
26 QgsNetworkDiskCache::QgsNetworkDiskCache( QObject *parent )
27  : QNetworkDiskCache( parent )
28 {
29 }
30 
32 {
33  QMutexLocker lock( &sDiskCacheMutex );
34  return sDiskCache.cacheDirectory();
35 }
36 
37 void QgsNetworkDiskCache::setCacheDirectory( const QString &cacheDir )
38 {
39  QMutexLocker lock( &sDiskCacheMutex );
40  sDiskCache.setCacheDirectory( cacheDir );
41 }
42 
44 {
45  QMutexLocker lock( &sDiskCacheMutex );
46  return sDiskCache.maximumCacheSize();
47 }
48 
50 {
51  QMutexLocker lock( &sDiskCacheMutex );
52  sDiskCache.setMaximumCacheSize( size );
53 }
54 
56 {
57  QMutexLocker lock( &sDiskCacheMutex );
58  return sDiskCache.cacheSize();
59 }
60 
61 QNetworkCacheMetaData QgsNetworkDiskCache::metaData( const QUrl &url )
62 {
63  QMutexLocker lock( &sDiskCacheMutex );
64  return sDiskCache.metaData( url );
65 }
66 
67 void QgsNetworkDiskCache::updateMetaData( const QNetworkCacheMetaData &metaData )
68 {
69  QMutexLocker lock( &sDiskCacheMutex );
70  sDiskCache.updateMetaData( metaData );
71 }
72 
73 QIODevice *QgsNetworkDiskCache::data( const QUrl &url )
74 {
75  QMutexLocker lock( &sDiskCacheMutex );
76  return sDiskCache.data( url );
77 }
78 
79 bool QgsNetworkDiskCache::remove( const QUrl &url )
80 {
81  QMutexLocker lock( &sDiskCacheMutex );
82  return sDiskCache.remove( url );
83 }
84 
85 QIODevice *QgsNetworkDiskCache::prepare( const QNetworkCacheMetaData &metaData )
86 {
87  QMutexLocker lock( &sDiskCacheMutex );
88  return sDiskCache.prepare( metaData );
89 }
90 
91 void QgsNetworkDiskCache::insert( QIODevice *device )
92 {
93  QMutexLocker lock( &sDiskCacheMutex );
94  sDiskCache.insert( device );
95 }
96 
97 QNetworkCacheMetaData QgsNetworkDiskCache::fileMetaData( const QString &fileName ) const
98 {
99  QMutexLocker lock( &sDiskCacheMutex );
100  return sDiskCache.fileMetaData( fileName );
101 }
102 
104 {
105  QMutexLocker lock( &sDiskCacheMutex );
106  return sDiskCache.runExpire();
107 }
108 
110 {
111  QMutexLocker lock( &sDiskCacheMutex );
112  return sDiskCache.clear();
113 }
QgsNetworkDiskCache::cacheDirectory
QString cacheDirectory() const
Definition: qgsnetworkdiskcache.cpp:31
QgsNetworkDiskCache::prepare
QIODevice * prepare(const QNetworkCacheMetaData &metaData) override
Definition: qgsnetworkdiskcache.cpp:85
QgsNetworkDiskCache::metaData
QNetworkCacheMetaData metaData(const QUrl &url) override
Definition: qgsnetworkdiskcache.cpp:61
QgsNetworkDiskCache::setMaximumCacheSize
void setMaximumCacheSize(qint64 size)
Definition: qgsnetworkdiskcache.cpp:49
QgsNetworkDiskCache::setCacheDirectory
void setCacheDirectory(const QString &cacheDir)
Definition: qgsnetworkdiskcache.cpp:37
QgsNetworkDiskCache::fileMetaData
QNetworkCacheMetaData fileMetaData(const QString &fileName) const
Definition: qgsnetworkdiskcache.cpp:97
QgsNetworkDiskCache::updateMetaData
void updateMetaData(const QNetworkCacheMetaData &metaData) override
Definition: qgsnetworkdiskcache.cpp:67
QgsNetworkDiskCache::maximumCacheSize
qint64 maximumCacheSize() const
Definition: qgsnetworkdiskcache.cpp:43
QgsNetworkDiskCache::cacheSize
qint64 cacheSize() const override
Definition: qgsnetworkdiskcache.cpp:55
QgsNetworkDiskCache::data
QIODevice * data(const QUrl &url) override
Definition: qgsnetworkdiskcache.cpp:73
qgsnetworkdiskcache.h
QgsNetworkDiskCache::insert
void insert(QIODevice *device) override
Definition: qgsnetworkdiskcache.cpp:91
QgsNetworkDiskCache::clear
void clear() override
Definition: qgsnetworkdiskcache.cpp:109
QgsNetworkDiskCache::expire
qint64 expire() override
Definition: qgsnetworkdiskcache.cpp:103
QgsNetworkDiskCache::remove
bool remove(const QUrl &url) override
Definition: qgsnetworkdiskcache.cpp:79