QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
22#include "qgis_sip.h"
23#include "qgis_core.h"
24
25class QTemporaryDir;
26
27#ifndef SIP_RUN
28
30
37class CORE_EXPORT QgsSourceCacheEntry : public QgsAbstractContentCacheEntry
38{
39 public:
40
44 QgsSourceCacheEntry( const QString &path ) ;
45
47 QString filePath;
48
49 int dataSize() const override;
50 void dump() const override;
51 bool isEqual( const QgsAbstractContentCacheEntry *other ) const override;
52
53};
54
56#endif
57
68#ifdef SIP_RUN
69class CORE_EXPORT QgsSourceCache : public QgsAbstractContentCacheBase // for sip we skip to the base class and avoid the template difficulty
70{
71#else
72class CORE_EXPORT QgsSourceCache : public QgsAbstractContentCache< QgsSourceCacheEntry >
73{
74#endif
75 Q_OBJECT
76
77 public:
78
82 QgsSourceCache( QObject *parent SIP_TRANSFERTHIS = nullptr );
83
89 QString localFilePath( const QString &path, bool blocking = false );
90
91 signals:
92
96 void remoteSourceFetched( const QString &url );
97
98 private:
99
100 QString fetchSource( const QString &path, bool &isBroken, bool blocking = false ) const;
101
102 std::unique_ptr< QTemporaryDir > temporaryDir;
103};
104
105#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.
Abstract base class for file content caches, such as SVG or raster image caches.
A cache for source strings that returns a local file path containing the source content.
void remoteSourceFetched(const QString &url)
Emitted when the cache has finished retrieving a 3D model from a remote url.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53