QGIS API Documentation  3.24.2-Tisler (13c1a02865)
qgsserviceregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsserviceregistry.h
3 
4  Class defining the service manager for QGIS server services.
5  -------------------
6  begin : 2016-12-05
7  copyright : (C) 2016 by David Marteau
8  email : david dot marteau at 3liz dot com
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 #ifndef QGSSERVICEREGISTRY_H
20 #define QGSSERVICEREGISTRY_H
21 
22 #include "qgsconfig.h"
23 #include "qgis.h"
24 
25 #include <QHash>
26 #include <QString>
27 
28 #include "qgsservicenativeloader.h"
29 #include <memory>
30 
31 class QgsService;
32 class QgsServerRequest;
33 class QgsServerApi;
34 class QgsServerInterface;
35 
49 class SERVER_EXPORT QgsServiceRegistry
50 {
51 
52  public:
53 
55  QgsServiceRegistry() = default;
56 
59 
68  QgsService *getService( const QString &name, const QString &version = QString() );
69 
80  void registerService( QgsService *service SIP_TRANSFER );
81 
88  bool registerApi( QgsServerApi *api SIP_TRANSFER );
89 
101  int unregisterApi( const QString &name, const QString &version = QString() );
102 
107  QgsServerApi *apiForRequest( const QgsServerRequest &request ) const SIP_SKIP;
108 
119  QgsServerApi *getApi( const QString &name, const QString &version = QString() );
120 
131  int unregisterService( const QString &name, const QString &version = QString() );
132 
138  void init( const QString &nativeModulepath, QgsServerInterface *serverIface = nullptr );
139 
143  void cleanUp();
144 
145  private:
146 
147  // XXX consider using QMap because of the few numbers of
148  // elements to handle
149  typedef QHash<QString, std::shared_ptr<QgsService> > ServiceTable;
150  typedef QHash<QString, std::shared_ptr<QgsServerApi> > ApiTable;
151  typedef QHash<QString, QPair<QString, QString> > VersionTable;
152 
153  QgsServiceNativeLoader mNativeLoader;
154 
155  ServiceTable mServices;
156  VersionTable mServiceVersions;
157  ApiTable mApis;
158  VersionTable mApiVersions;
159 
160 };
161 
162 #endif
163 
Server generic API endpoint abstract base class.
Definition: qgsserverapi.h:81
QgsServerInterface Class defining interfaces exposed by QGIS Server and made available to plugins.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
Class defining the native service module loader for QGIS server services.
QgsServiceRegistry Class defining the registry manager for QGIS server services.
QgsServiceRegistry()=default
Constructor.
QgsService Class defining interfaces for QGIS server services.
Definition: qgsservice.h:40
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36