QGIS API Documentation  3.6.0-Noosa (5873452)
qgsserversettings.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsserversettings.h
3  -------------------
4  begin : December 19, 2016
5  copyright : (C) 2016 by Paul Blottiere
6  email : paul dot blottiere at oslandia dot com
7 
8 ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 
20 #ifndef QGSSERVERSETTINGS_H
21 #define QGSSERVERSETTINGS_H
22 
23 #include <QObject>
24 #include <QMetaEnum>
25 
26 #include "qgsmessagelog.h"
27 #include "qgis_server.h"
28 #include "qgis_sip.h"
29 
36 #ifndef SIP_RUN
37 class SERVER_EXPORT QgsServerSettingsEnv : public QObject
38 {
39  Q_OBJECT
40 
41  public:
43  enum Source
44  {
47  INI_FILE
48  };
49  Q_ENUM( Source )
50 
51 
52  enum EnvVar
53  {
63  QGIS_SERVER_CACHE_SIZE
64  };
65  Q_ENUM( EnvVar )
66 };
67 #endif
68 
75 class SERVER_EXPORT QgsServerSettings
76 {
77  public:
79  {
82  QString descr;
83  QString iniKey;
84  QVariant::Type type;
85  QVariant defaultVal;
86  QVariant val;
87  };
88 
93 
97  void load();
98 
103  bool load( const QString &envVarName );
104 
108  void logSummary() const;
109 
114  QString iniFile() const;
115 
120  bool parallelRendering() const;
121 
126  int maxThreads() const;
127 
132  int maxCacheLayers() const;
133 
138  Qgis::MessageLevel logLevel() const;
139 
144  QString projectFile() const;
145 
150  QString logFile() const;
151 
157  bool logStderr() const;
158 
163  qint64 cacheSize() const;
164 
169  QString cacheDirectory() const;
170 
171  private:
172  void initSettings();
173  QVariant value( QgsServerSettingsEnv::EnvVar envVar ) const;
174  QMap<QgsServerSettingsEnv::EnvVar, QString> getEnv() const;
175  void loadQSettings( const QString &envOptPath ) const;
176  void prioritize( const QMap<QgsServerSettingsEnv::EnvVar, QString> &env );
177 
178  QMap< QgsServerSettingsEnv::EnvVar, Setting > mSettings;
179 };
180 
181 #endif
Source
Source of the parameter used in the configuration.
Provides a way to retrieve settings by prioritizing according to environment variables, ini file and default values.
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition: qgis.h:66
#define SIP_SKIP
Definition: qgis_sip.h:119
Provides some enum describing the environment currently supported for configuration.
QgsServerSettingsEnv::EnvVar envVar
QgsServerSettingsEnv::Source src
EnvVar
Environment variables to configure the server.