QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
qgssourcecache.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssourcecache.h
3 ---------------
4 begin : July 2020
5 copyright : (C) 2020 by Mathieu Pellerin
6 email : nirvn dot asia 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 QGSSOURCECACHE_H
19#define QGSSOURCECACHE_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
24
25class QTemporaryDir;
26
27#ifndef SIP_RUN
28
30
37class CORE_EXPORT QgsSourceCacheEntry : public QgsAbstractContentCacheEntry
38{
39 public:
43 QgsSourceCacheEntry( const QString &path );
44
46 QString filePath;
47
48 int dataSize() const override;
49 void dump() const override;
50 bool isEqual( const QgsAbstractContentCacheEntry *other ) const override;
51};
52
54#endif
55
66#ifdef SIP_RUN
67class CORE_EXPORT QgsSourceCache : public QgsAbstractContentCacheBase // for sip we skip to the base class and avoid the template difficulty
68{
69#else
70class CORE_EXPORT QgsSourceCache : public QgsAbstractContentCache< QgsSourceCacheEntry >
71{
72#endif
73 Q_OBJECT
74
75 public:
79 QgsSourceCache( QObject *parent SIP_TRANSFERTHIS = nullptr );
80
86 QString localFilePath( const QString &path, bool blocking = false );
87
88 signals:
89
93 void remoteSourceFetched( const QString &url );
94
95 private:
96 QString fetchSource( const QString &path, bool &isBroken, bool blocking = false ) const;
97
98 std::unique_ptr< QTemporaryDir > temporaryDir;
99};
100
101#endif // QGSSOURCECACHE_H
A QObject derived base class for QgsAbstractContentCache.
Base class for entries in a QgsAbstractContentCache.
virtual int dataSize() const =0
Returns the memory usage in bytes for the entry.
virtual void dump() const =0
Dumps debugging strings containing the item's properties.
virtual bool isEqual(const QgsAbstractContentCacheEntry *other) const =0
Tests whether this entry matches another entry.
QgsAbstractContentCache(QObject *parent=nullptr, const QString &typeString=QString(), long maxCacheSize=20000000, int fileModifiedCheckTimeout=30000)
A cache for source strings that returns a local file path containing the source content.
QgsSourceCache(QObject *parent=nullptr)
Constructor for QgsSourceCache, with the specified parent object.
void remoteSourceFetched(const QString &url)
Emitted when the cache has finished retrieving a 3D model from a remote url.
QString localFilePath(const QString &path, bool blocking=false)
Returns a local file path reflecting the content of a specified source path.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52