QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
25 #ifndef SIP_RUN
26 
28 
35 class CORE_EXPORT QgsSourceCacheEntry : public QgsAbstractContentCacheEntry
36 {
37  public:
38 
42  QgsSourceCacheEntry( const QString &path ) ;
43 
45  QString filePath;
46 
47  int dataSize() const override;
48  void dump() const override;
49  bool isEqual( const QgsAbstractContentCacheEntry *other ) const override;
50 
51 };
52 
54 #endif
55 
66 #ifdef SIP_RUN
67 class CORE_EXPORT QgsSourceCache : public QgsAbstractContentCacheBase // for sip we skip to the base class and avoid the template difficulty
68 {
69 #else
70 class CORE_EXPORT QgsSourceCache : public QgsAbstractContentCache< QgsSourceCacheEntry >
71 {
72 #endif
73  Q_OBJECT
74 
75  public:
76 
80  QgsSourceCache( QObject *parent SIP_TRANSFERTHIS = nullptr );
81 
87  QString localFilePath( const QString &path, bool blocking = false );
88 
89  signals:
90 
94  void remoteSourceFetched( const QString &url );
95 
96  private:
97 
98  QString fetchSource( const QString &path, bool &isBroken, bool blocking = false ) const;
99 
100  std::unique_ptr< QTemporaryDir > temporaryDir;
101 };
102 
103 #endif // QGSSOURCECACHE_H
QgsAbstractContentCacheEntry::isEqual
virtual bool isEqual(const QgsAbstractContentCacheEntry *other) const =0
Tests whether this entry matches another entry.
QgsAbstractContentCacheEntry::dump
virtual void dump() const =0
Dumps debugging strings containing the item's properties.
qgis_sip.h
QgsSourceCache
A cache for source strings that returns a local file path containing the source content.
Definition: qgssourcecache.h:71
QgsAbstractContentCacheEntry::dataSize
virtual int dataSize() const =0
Returns the memory usage in bytes for the entry.
QgsAbstractContentCacheEntry
Base class for entries in a QgsAbstractContentCache.
Definition: qgsabstractcontentcache.h:48
QgsAbstractContentCacheBase
A QObject derived base class for QgsAbstractContentCache.
Definition: qgsabstractcontentcache.h:131
qgsabstractcontentcache.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsAbstractContentCache
Abstract base class for file content caches, such as SVG or raster image caches.
Definition: qgsabstractcontentcache.h:190
QgsSourceCache::remoteSourceFetched
void remoteSourceFetched(const QString &url)
Emitted when the cache has finished retrieving a 3D model from a remote url.