-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsconfigcache.h
82 lines (65 loc) · 2.54 KB
/
qgsconfigcache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/***************************************************************************
qgsconfigcache.h
----------------
begin : July 24th, 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSCONFIGCACHE_H
#define QGSCONFIGCACHE_H
#include "qgsconfig.h"
#include <QCache>
#include <QFileSystemWatcher>
#include <QMap>
#include <QObject>
#include <QDomDocument>
#include "qgis_server.h"
#include "qgis_sip.h"
class QgsProject;
/**
* \ingroup server
* \brief Cache for server configuration.
* \since QGIS 2.8
*/
class SERVER_EXPORT QgsConfigCache : public QObject
{
Q_OBJECT
public:
/**
* Returns the current instance.
*/
static QgsConfigCache *instance();
/**
* Removes an entry from cache.
* \param path The path of the project
*/
void removeEntry( const QString &path );
/**
* If the project is not cached yet, then the project is read thanks to the
* path. If the project is not available, then a nullptr is returned.
* \param path the filename of the QGIS project
* \returns the project or nullptr if an error happened
* \since QGIS 3.0
*/
const QgsProject *project( const QString &path );
private:
QgsConfigCache() SIP_FORCE;
//! Check for configuration file updates (remove entry from cache if file changes)
QFileSystemWatcher mFileSystemWatcher;
//! Returns xml document for project file / sld or 0 in case of errors
QDomDocument *xmlDocument( const QString &filePath );
QCache<QString, QDomDocument> mXmlDocumentCache;
QCache<QString, QgsProject> mProjectCache;
private slots:
//! Removes changed entry from this cache
void removeChangedEntry( const QString &path );
};
#endif // QGSCONFIGCACHE_H