QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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
24#include <memory>
25
26#include "qgis.h"
28
29#include <QHash>
30#include <QString>
31
32class QgsService;
34class QgsServerApi;
36
48class SERVER_EXPORT QgsServiceRegistry
49{
50 public:
51 QgsServiceRegistry() = default;
53
62 QgsService *getService( const QString &name, const QString &version = QString() );
63
75
83
95 int unregisterApi( const QString &name, const QString &version = QString() );
96
101 QgsServerApi *apiForRequest( const QgsServerRequest &request ) const SIP_SKIP;
102
113 QgsServerApi *getApi( const QString &name, const QString &version = QString() );
114
125 int unregisterService( const QString &name, const QString &version = QString() );
126
132 void init( const QString &nativeModulepath, QgsServerInterface *serverIface = nullptr );
133
137 void cleanUp();
138
139 private:
140 // XXX consider using QMap because of the few numbers of
141 // elements to handle
142 typedef QHash<QString, std::shared_ptr<QgsService>> ServiceTable;
143 typedef QHash<QString, std::shared_ptr<QgsServerApi>> ApiTable;
144 typedef QHash<QString, QPair<QString, QString>> VersionTable;
145
146 QgsServiceNativeLoader mNativeLoader;
147
148 ServiceTable mServices;
149 VersionTable mServiceVersions;
150 ApiTable mApis;
151 VersionTable mApiVersions;
152};
153
154#endif
Server generic API endpoint abstract base class.
Defines interfaces exposed by QGIS Server and made available to plugins.
Defines requests passed to QgsService classes.
Defines the native service module loader for QGIS server services.
void cleanUp()
Clean up registered service and unregister modules.
bool registerApi(QgsServerApi *api)
Registers the QgsServerApi api.
int unregisterService(const QString &name, const QString &version=QString())
Unregister service from its name and version.
int unregisterApi(const QString &name, const QString &version=QString())
Unregisters API from its name and version.
QgsServiceRegistry()=default
QgsServerApi * apiForRequest(const QgsServerRequest &request) const
Searches the API register for an API matching the request and returns a (possibly NULL) pointer to it...
void init(const QString &nativeModulepath, QgsServerInterface *serverIface=nullptr)
Initialize registry, load modules and auto register services.
QgsService * getService(const QString &name, const QString &version=QString())
Retrieve a service from its name.
void registerService(QgsService *service)
Register a service by its name and version.
QgsServerApi * getApi(const QString &name, const QString &version=QString())
Retrieves an API from its name.
Defines interfaces for QGIS server services.
Definition qgsservice.h:38
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36