QGIS API Documentation 3.39.0-Master (d85f3c2a281)
Loading...
Searching...
No Matches
qgsnetworkdiskcache.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsnetworkdiskcache.h - 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#ifndef QGSNETWORKDISKCACHE_H
19#define QGSNETWORKDISKCACHE_H
20
21#define SIP_NO_FILE
22
23#include "qgis_core.h"
24
25#include <QNetworkDiskCache>
26#include <QMutex>
27
28class QNetworkDiskCache;
29
31
32class ExpirableNetworkDiskCache : public QNetworkDiskCache
33{
34 Q_OBJECT
35
36 public:
37 explicit ExpirableNetworkDiskCache( QObject *parent = nullptr ) : QNetworkDiskCache( parent ) {}
38 qint64 runExpire() { return QNetworkDiskCache::expire(); }
39};
40
42
50class CORE_EXPORT QgsNetworkDiskCache : public QNetworkDiskCache
51{
52 Q_OBJECT
53
54 public:
55
57 QString cacheDirectory() const;
58
60 void setCacheDirectory( const QString &cacheDir );
61
63 qint64 maximumCacheSize() const;
64
66 void setMaximumCacheSize( qint64 size );
67
69 QNetworkCacheMetaData metaData( const QUrl &url ) override;
70
72 void updateMetaData( const QNetworkCacheMetaData &metaData ) override;
73
75 QIODevice *data( const QUrl &url ) override;
76
78 bool remove( const QUrl &url ) override;
79
81 qint64 cacheSize() const override;
82
84 QIODevice *prepare( const QNetworkCacheMetaData &metaData ) override;
85
87 void insert( QIODevice *device ) override;
88
90 QNetworkCacheMetaData fileMetaData( const QString &fileName ) const;
91
96 static qint64 smartCacheSize( const QString &path );
97
98 public slots:
100 void clear() override;
101
102 protected:
104 qint64 expire() override;
105
106 private:
107 explicit QgsNetworkDiskCache( QObject *parent );
108
109 static ExpirableNetworkDiskCache sDiskCache;
110 static QMutex sDiskCacheMutex;
111
113};
114
115#endif // QGSNETWORKDISKCACHE_H
network access manager for QGIS
Wrapper implementation of QNetworkDiskCache with all methods guarded by a mutex soly for internal use...