QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
qgsrangerequestcache.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrangerequestcache.h
3 --------------------
4 begin : April 2022
5 copyright : (C) 2022 by Belgacem Nedjima
6 email : belgacem dot nedjima at gmail dot com
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 QGSRANGEREQUESTCACHE_H
19#define QGSRANGEREQUESTCACHE_H
20
21#include <QtGlobal>
22#include <QMap>
23#include <QByteArray>
24#include <QUrl>
25#include <QFileInfoList>
26#include <QDir>
27#include <QNetworkRequest>
28
29#include "qgis_core.h"
30
31#define SIP_NO_FILE
32
33
43class CORE_EXPORT QgsRangeRequestCache
44{
45 public:
48
50 bool hasEntry( const QNetworkRequest &request );
52 QByteArray entry( const QNetworkRequest &request );
54 void registerEntry( const QNetworkRequest &request, QByteArray data );
55
57 void clear();
58
64 bool setCacheDirectory( const QString &path );
66 void setCacheSize( qint64 maxBytes );
67
69 QString error() const { return mError; }
70
71 friend class TestQgsCopcProvider;
72 private:
73 QString mError;
74 QString mCacheDir;
75 qint64 mMaxDataSize = 256 * 1024 * 1024;
76
77 QString rangeFileName( const QNetworkRequest &request ) const;
78
79 QByteArray readFile( const QString &fileName );
80 bool writeFile( const QString &fileName, QByteArray data );
81 bool removeFile( const QString &fileName );
82
83 void expire();
84
85 QFileInfoList cacheEntries();
86};
87
88#endif // QGSRANGEREQUESTCACHE_H
A custom cache for handling the storage and retrieval of HTTP range requests on disk.
QString error() const
Returns the last error that occurred when manipulating the cache.