QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
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
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.