/
qgsservercachemanager.h
144 lines (121 loc) · 6.37 KB
/
qgsservercachemanager.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/***************************************************************************
qgsservercachemanager.h
-----------------------
begin : 2018-07-05
copyright : (C) 2018 by René-Luc D'Hont
email : rldhont at 3liz dot com
***************************************************************************/
/***************************************************************************
* *
* 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 QGSSERVERCACHEMANAGER_H
#define QGSSERVERCACHEMANAGER_H
#include "qgsservercachefilter.h"
#include "qgsaccesscontrol.h"
#include "qgsserverrequest.h"
#include <QMultiMap>
#include <QDomDocument>
#include "qgis_server.h"
#include "qgis_sip.h"
class QgsProject;
SIP_IF_MODULE( HAVE_SERVER_PYTHON_PLUGINS )
/**
* \ingroup server
* \class QgsServerCacheManager
* \brief A helper class that centralizes caches accesses given by all the server cache filter plugins.
* \since QGIS 3.4
*/
class SERVER_EXPORT QgsServerCacheManager
{
#ifdef SIP_RUN
#include "qgsservercachefilter.h"
#endif
public:
//! Constructor
QgsServerCacheManager();
//! Copy constructor
QgsServerCacheManager( const QgsServerCacheManager © );
//! Assignment operator
QgsServerCacheManager &operator=( const QgsServerCacheManager © );
//! Destructor
~QgsServerCacheManager();
/**
* Returns cached document (or 0 if document not in cache) like capabilities
* \param doc the document to update by content found in cache
* \param project the project used to generate the document to provide path
* \param request the request used to generate the document to provider parameters or data
* \param accessControl the access control to identify different documents for the same request provided by server interface
* \returns true if the document has been found in cache and the document's content set
*/
bool getCachedDocument( QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl ) const;
/**
* Updates or inserts the document in cache like capabilities
* \param doc the document to cache
* \param project the project used to generate the document to provide path
* \param request the request used to generate the document to provider parameters or data
* \param accessControl the access control to identify different documents for the same request provided by server interface
* \returns true if the document has been cached
*/
bool setCachedDocument( const QDomDocument *doc, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl ) const;
/**
* Deletes the cached document
* \param project the project used to generate the document to provide path
* \param request the request used to generate the document to provider parameters or data
* \param accessControl the access control to identify different documents for the same request provided by server interface
* \returns true if the document has been deleted
*/
bool deleteCachedDocument( const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl ) const;
/**
* Deletes all cached documents for a QGIS project
* \param project the project used to generate the document to provide path
* \returns true if the document has been deleted
*/
bool deleteCachedDocuments( const QgsProject *project ) const;
/**
* Returns cached image (or 0 if image not in cache) like tiles
* \param project the project used to generate the image to provide path
* \param request the request used to generate the image to provider parameters or data
* \param accessControl the access control to identify different documents for the same request provided by server interface
* \returns the cached image or 0 if no corresponding image found
*/
QByteArray getCachedImage( const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl ) const;
/**
* Updates or inserts the image in cache like tiles
* \param img the image to cache
* \param project the project used to generate the image to provide path
* \param request the request used to generate the image to provider parameters or data
* \param accessControl the access control to identify different documents for the same request provided by server interface
* \returns true if the image has been cached
*/
bool setCachedImage( const QByteArray *img, const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl ) const;
/**
* Deletes the cached image
* \param project the project used to generate the image to provide path
* \param request the request used to generate the image to provider parameters or data
* \param accessControl the access control to identify different documents for the same request provided by server interface
* \returns true if the image has been deleted
*/
bool deleteCachedImage( const QgsProject *project, const QgsServerRequest &request, QgsAccessControl *accessControl ) const;
/**
* Deletes all cached images for a QGIS project
* \param project the project used to generate the images to provide path
* \returns true if the images have been deleted
*/
bool deleteCachedImages( const QgsProject *project ) const;
/**
* Register a server cache filter
* \param serverCache the server cache to add
* \param priority the priority used to define the order
*/
void registerServerCache( QgsServerCacheFilter *serverCache, int priority = 0 );
private:
QString getCacheKey( bool &cache, QgsAccessControl *accessControl ) const;
//! The ServerCache plugins registry
std::unique_ptr<QgsServerCacheFilterMap> mPluginsServerCaches = nullptr;
};
#endif