QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsserver.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsserver.h
3  QGIS Server main class.
4  -------------------
5  begin : June 05, 2015
6  copyright : (C) 2015 by Alessandro Pasotti
7  email : a dot pasotti at itopen dot it
8 
9  Based on previous work from:
10 
11  begin : July 04, 2006
12  copyright : (C) 2006 by Marco Hugentobler & Ionut Iosifescu Enescu
13  email : marco dot hugentobler at karto dot baug dot ethz dot ch
14 
15  ***************************************************************************/
16 
17 /***************************************************************************
18  * *
19  * This program is free software; you can redistribute it and/or modify *
20  * it under the terms of the GNU General Public License as published by *
21  * the Free Software Foundation; either version 2 of the License, or *
22  * (at your option) any later version. *
23  * *
24  ***************************************************************************/
25 
26 
27 #ifndef QGSSERVER_H
28 #define QGSSERVER_H
29 
30 #include <QFileInfo>
31 #include "qgsrequesthandler.h"
32 #include "qgsapplication.h"
33 #include "qgsmaprenderer.h"
34 #include "qgsconfigcache.h"
35 #include "qgscapabilitiescache.h"
36 
37 #ifdef HAVE_SERVER_PYTHON_PLUGINS
38 #include "qgsserverplugins.h"
39 #include "qgsserverfilter.h"
40 #include "qgsserverinterfaceimpl.h"
41 #endif
42 
43 
47 class SERVER_EXPORT QgsServer
48 {
49  public:
54  QgsServer( int & argc, char ** argv );
56  QgsServer();
57  ~QgsServer();
58 
62  static bool init( int & argc, char ** argv );
64  static bool init();
65 
71  void putenv( const QString &var, const QString &val );
72 
84  QPair<QByteArray, QByteArray> handleRequest( const QString& queryString = QString() );
85 #if 0
86  // The following code was used to test type conversion in python bindings
88 #endif
89 
91 #ifdef HAVE_SERVER_PYTHON_PLUGINS
92  QgsServerInterfaceImpl* serverInterface() { return sServerInterface; }
93 #endif
94 
95  private:
96 
97  void saveEnvVars();
98 
100  void saveEnvVar( const QString& variableName );
101 
102  // All functions that where previously in the main file are now
103  // static methods of this class
104  static QString configPath( const QString& defaultConfigPath,
105  const QMap<QString, QString>& parameters );
106  // Mainly for debug
107  static void dummyMessageHandler( QtMsgType type, const char *msg );
108  // Mainly for debug
109  static void printRequestInfos();
110  // Mainly for debug
111  static void printRequestParameters(
112  const QMap< QString, QString>& parameterMap,
113  int logLevel );
114  static QFileInfo defaultProjectFile();
115  static QFileInfo defaultAdminSLD();
116  static void setupNetworkAccessManager();
118  static QgsRequestHandler* createRequestHandler( const bool captureOutput = false );
119 
120  // Return the server name
121  static QString &serverName();
122 
123  // Status
124  static QString* sConfigFilePath;
125  static QgsCapabilitiesCache* sCapabilitiesCache;
126  static QgsMapRenderer* sMapRenderer;
127 #ifdef HAVE_SERVER_PYTHON_PLUGINS
128  static QgsServerInterfaceImpl* sServerInterface;
129  static bool sInitPython;
130 #endif
131  static bool sInitialised;
133  static char* sArgv[1];
134  static int sArgc;
135  static QgsApplication* sQgsApplication;
136  static bool sCaptureOutput;
137 
139  QHash< QString, QString > mEnvironmentVariables;
140 };
141 #endif // QGSSERVER_H
142 
Extends QApplication to provide access to QGIS specific resources such as theme paths, database paths etc.
A non GUI class for rendering a map layer set onto a QPainter.
This class is an interface hiding the details of reading input and writing output from/to a wms reque...
The QgsServer class provides OGC web services.
Definition: qgsserver.h:47
A cache for capabilities xml documents (by configuration file path)