QGIS API Documentation 3.41.0-Master (3440c17df1d)
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:
47
49 bool hasEntry( const QNetworkRequest &request );
51 QByteArray entry( const QNetworkRequest &request );
53 void registerEntry( const QNetworkRequest &request, QByteArray data );
54
56 void clear();
57
63 bool setCacheDirectory( const QString &path );
65 void setCacheSize( qint64 maxBytes );
66
68 QString error() const { return mError; }
69
70 friend class TestQgsCopcProvider;
71 private:
72 QString mError;
73 QString mCacheDir;
74 qint64 mMaxDataSize = 256 * 1024 * 1024;
75
76 QString rangeFileName( const QNetworkRequest &request ) const;
77
78 QByteArray readFile( const QString &fileName );
79 bool writeFile( const QString &fileName, QByteArray data );
80 bool removeFile( const QString &fileName );
81
82 void expire();
83
84 QFileInfoList cacheEntries();
85};
86
87#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.