QGIS API Documentation  3.2.0-Bonn (bc43194)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 }
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
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)