-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsserver.h
139 lines (113 loc) · 4.54 KB
/
qgsserver.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
/***************************************************************************
qgsserver.h
QGIS Server main class.
-------------------
begin : June 05, 2015
copyright : (C) 2015 by Alessandro Pasotti
email : a dot pasotti at itopen dot it
Based on previous work from:
begin : July 04, 2006
copyright : (C) 2006 by Marco Hugentobler & Ionut Iosifescu Enescu
email : marco dot hugentobler at karto dot baug dot ethz 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 QGSSERVER_H
#define QGSSERVER_H
#include <QFileInfo>
#include "qgsrequesthandler.h"
#include "qgsapplication.h"
#include "qgsconfigcache.h"
#include "qgscapabilitiescache.h"
#include "qgsmapsettings.h"
#include "qgsmessagelog.h"
#include "qgsserviceregistry.h"
#include "qgsserversettings.h"
#include "qgsserverplugins.h"
#include "qgsserverfilter.h"
#include "qgsserverinterfaceimpl.h"
#include "qgis_server.h"
class QgsServerRequest;
class QgsServerResponse;
class QgsProject;
/** \ingroup server
* The QgsServer class provides OGC web services.
*/
class SERVER_EXPORT QgsServer
{
public:
/** Creates the server instance
*/
QgsServer();
/** Set environment variable
* @param var environment variable name
* @param val value
* @note added in 2.14
*/
void putenv( const QString &var, const QString &val );
/** Handles the request.
* The query string is normally read from environment
* but can be also passed in args and in this case overrides the environment
* variable
*
* @param request a QgsServerRequest holding request parameters
* @param response a QgsServerResponse for handling response I/O)
*/
void handleRequest( QgsServerRequest& request, QgsServerResponse& response );
/** Handles the request from query string
* The query string is normally read from environment
* but can be also passed in args and in this case overrides the environment
* variable.
*
* @param queryString QString containing the query string
* @return the response headers and body QPair of QByteArray
*/
QPair<QByteArray, QByteArray> handleRequest( const QString& queryString );
//! Returns a pointer to the server interface
QgsServerInterfaceImpl* serverInterface() { return sServerInterface; }
#ifdef HAVE_SERVER_PYTHON_PLUGINS
//! Initialize python
//! Note: not in python bindings
void initPython( );
#endif
private:
//! Server initialization
static bool init();
// All functions that where previously in the main file are now
// static methods of this class
static QString configPath( const QString& defaultConfigPath,
const QMap<QString, QString>& parameters );
/**
* @brief QgsServer::printRequestParameters prints the request parameters
* @param parameterMap
* @param logLevel
*/
static void printRequestParameters(
const QMap< QString, QString>& parameterMap,
QgsMessageLog::MessageLevel logLevel );
static QFileInfo defaultProjectFile();
static QFileInfo defaultAdminSLD();
static void setupNetworkAccessManager();
//! Create and return a request handler instance
static QgsRequestHandler* createRequestHandler( const QgsServerRequest& request, QgsServerResponse& response );
// Return the server name
static QString &serverName();
// Status
static QString* sConfigFilePath;
static QgsCapabilitiesCache* sCapabilitiesCache;
static QgsServerInterfaceImpl* sServerInterface;
//! Initialization must run once for all servers
static bool sInitialized;
//! service registry
static QgsServiceRegistry sServiceRegistry;
static QgsServerSettings sSettings;
// map of QgsProject
QMap<QString, const QgsProject*> mProjectRegistry;
};
#endif // QGSSERVER_H