QGIS API Documentation 3.99.0-Master (a8f284845db)
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 "qgis_core.h"
22
23#include <QByteArray>
24#include <QDir>
25#include <QFileInfoList>
26#include <QMap>
27#include <QNetworkRequest>
28#include <QUrl>
29#include <QtGlobal>
30
31#define SIP_NO_FILE
32
42class CORE_EXPORT QgsRangeRequestCache
43{
44 public:
46
48 bool hasEntry( const QNetworkRequest &request );
50 QByteArray entry( const QNetworkRequest &request );
52 void registerEntry( const QNetworkRequest &request, QByteArray data );
53
55 void clear();
56
62 bool setCacheDirectory( const QString &path );
64 void setCacheSize( qint64 maxBytes );
65
67 QString error() const { return mError; }
68
69 friend class TestQgsCopcProvider;
70 private:
71 QString mError;
72 QString mCacheDir;
73 qint64 mMaxDataSize = 256 * 1024 * 1024;
74
75 QString rangeFileName( const QNetworkRequest &request ) const;
76
77 QByteArray readFile( const QString &fileName );
78 bool writeFile( const QString &fileName, QByteArray data );
79 bool removeFile( const QString &fileName );
80
81 void expire();
82
83 QFileInfoList cacheEntries();
84};
85
86#endif // QGSRANGEREQUESTCACHE_H
void clear()
Clears the cache removing all of the files.
bool hasEntry(const QNetworkRequest &request)
Checks whether the range request exists in the cache.
QString error() const
Returns the last error that occurred when manipulating the cache.
bool setCacheDirectory(const QString &path)
Set the Cache Directory object.
QByteArray entry(const QNetworkRequest &request)
Returns the range request data stored in the cache and an empty byte array if the data is not in the ...
void registerEntry(const QNetworkRequest &request, QByteArray data)
Adds the range request data into the cache.
void setCacheSize(qint64 maxBytes)
Sets the cache size.