From ca8e0c3991e669f290654e1f8d7dd59d4972d139 Mon Sep 17 00:00:00 2001 From: elpaso Date: Fri, 10 Oct 2014 19:28:20 +0200 Subject: [PATCH] Added comments for bindings. --- python/server/qgscapabilitiescache.sip | 27 ++++++++-- python/server/qgsmapserviceexception.sip | 33 ++++++++++-- python/server/qgsrequesthandler.sip | 66 ++++++++++++++++++------ python/server/qgsserverfilter.sip | 20 +++++-- python/server/qgsserverinterface.sip | 35 +++++++++++-- python/server/qgsserverlogger.sip | 34 ------------ python/server/server.sip | 1 - 7 files changed, 147 insertions(+), 69 deletions(-) delete mode 100644 python/server/qgsserverlogger.sip diff --git a/python/server/qgscapabilitiescache.sip b/python/server/qgscapabilitiescache.sip index c534f94ae173..b40a4df39ce4 100644 --- a/python/server/qgscapabilitiescache.sip +++ b/python/server/qgscapabilitiescache.sip @@ -1,12 +1,29 @@ +/*************************************************************************** + qgscapabilitiescache.sip -/**A cache for capabilities xml documents (by configuration file path)*/ + A cache for capabilities xml documents (by configuration file path) + ------------------- + begin : 2014-09-10 + copyright : (C) 2014 by Alessandro Pasotti + email : a dot pasotti at itopen dot it + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/** +* \class QgsCapabilitiesCache +* \brief A cache for capabilities xml documents (by configuration file path) +*/ class QgsCapabilitiesCache: public QObject { %TypeHeaderCode -#include -#include -#include -#include #include "qgscapabilitiescache.h" %End public: diff --git a/python/server/qgsmapserviceexception.sip b/python/server/qgsmapserviceexception.sip index 2c62cc8b83ae..7723b845cc6d 100644 --- a/python/server/qgsmapserviceexception.sip +++ b/python/server/qgsmapserviceexception.sip @@ -1,9 +1,32 @@ +/*************************************************************************** + qgsmapserviceexception.sip + QGIS Server exception + ------------------- + begin : 2014-09-10 + copyright : (C) 2014 by Alessandro Pasotti + email : a dot pasotti at itopen dot it + ***************************************************************************/ -/**Exception class for WMS service exceptions. The most important codes are: -"InvalidFormat" -"Invalid CRS" -"LayerNotDefined" / "StyleNotDefined" -"OperationNotSupported"*/ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +/** + * \class QgsMapServiceException + * \brief Exception class for WMS service exceptions. + * + * The most important codes are: + * * "InvalidFormat" + * * "Invalid CRS" + * * "LayerNotDefined" / "StyleNotDefined" + * * "OperationNotSupported" + */ class QgsMapServiceException { diff --git a/python/server/qgsrequesthandler.sip b/python/server/qgsrequesthandler.sip index 101d66823760..008695661230 100644 --- a/python/server/qgsrequesthandler.sip +++ b/python/server/qgsrequesthandler.sip @@ -1,5 +1,24 @@ -/**This class is an interface hiding the details of reading input and writing output from/to a wms request mechanism. -Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage as a standalone command line executable*/ +/*************************************************************************** + qgsrequesthandler.sip + + This class is an interface hiding the details of reading input and + writing output from/to a wms request mechanism + ------------------- + begin : 2014-09-10 + copyright : (C) 2014 by Alessandro Pasotti + email : a dot pasotti at itopen dot it + ***************************************************************************/ + + +/** + * \class QgsRequestHandler + * \brief This class is an interface hiding the details of reading input and + * writing output from/to a wms request mechanism. + * + * Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage + * as a standalone command line executable + */ + class QgsRequestHandler { %TypeHeaderCode @@ -10,33 +29,28 @@ class QgsRequestHandler public: - virtual void parseInput() = 0; - virtual void setGetMapResponse( const QString& service, QImage* img, int imageQuality ) = 0; - virtual void setGetCapabilitiesResponse( const QDomDocument& doc ) = 0; - virtual void setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) = 0; - virtual void setServiceException( QgsMapServiceException ex ) = 0; - virtual void setGetStyleResponse( const QDomDocument& doc ) = 0; - virtual void setGetPrintResponse( QByteArray* ba ) = 0; - virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) = 0; - virtual void setGetFeatureResponse( QByteArray* ba ) = 0; - virtual void endGetFeatureResponse( QByteArray* ba ) = 0; - virtual void setGetCoverageResponse( QByteArray* ba ) = 0; - /**Set an HTTP header*/ virtual void setHeader( const QString &name, const QString &value ) = 0; /**Remove an HTTP header*/ virtual int removeHeader( const QString &name ) = 0; /**Delete all HTTP headers*/ virtual void clearHeaders( ) = 0; + /**Returns the response body*/ + virtual QByteArray* body(); /**Append the bytestream to response body*/ virtual void appendBody( const QByteArray &body) = 0; /**Clears the response body*/ virtual void clearBody( ) = 0; + /**Set the info format string such as "text/xml"*/ virtual void setInfoFormat( const QString &format ) = 0; - virtual void sendResponse( ) const = 0; + /**Check wether there is any header set or the body is not empty*/ virtual bool responseReady() const = 0; /**Pointer to last raised exception*/ virtual bool exceptionRaised() const = 0; + /**Return a copy of the parsed parameters as a key-value pair, to modify + * a parameter setParameter( const QString &key, const QString &value) + * and removeParameter(const QString &key) must be used + */ QMap parameterMap( ); /**Set a request parameter*/ virtual void setParameter(const QString &key, const QString &value) = 0; @@ -44,12 +58,32 @@ class QgsRequestHandler virtual int removeParameter(const QString &key) = 0; /**Return a request parameter*/ virtual QString parameter(const QString &key) const = 0; + /**Return the image format*/ QString format() const; + /**Return the format string as requested by the client*/ + QString infoFormat() const; + +private: -protected: + /* Not yet part of the API */ virtual void sendHeaders( ) const = 0; virtual void sendBody( ) const = 0; + /**Send out the response writing to FCGI stdout*/ + virtual void sendResponse( ) const = 0; + + virtual void parseInput() = 0; + virtual void setGetMapResponse( const QString& service, QImage* img, int imageQuality ) = 0; + virtual void setGetCapabilitiesResponse( const QDomDocument& doc ) = 0; + virtual void setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) = 0; + virtual void setServiceException( QgsMapServiceException ex ) = 0; + virtual void setGetStyleResponse( const QDomDocument& doc ) = 0; + virtual void setGetPrintResponse( QByteArray* ba ) = 0; + virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) = 0; + virtual void setGetFeatureResponse( QByteArray* ba ) = 0; + virtual void endGetFeatureResponse( QByteArray* ba ) = 0; + virtual void setGetCoverageResponse( QByteArray* ba ) = 0; + }; diff --git a/python/server/qgsserverfilter.sip b/python/server/qgsserverfilter.sip index 40a91203a549..61b5104add3f 100644 --- a/python/server/qgsserverfilter.sip +++ b/python/server/qgsserverfilter.sip @@ -17,10 +17,13 @@ ***************************************************************************/ /** - * QgsServerFilter - * Class defining I/O filters for Qgis Mapserver and - * implemented in plugins + * \class QgsServerFilter + * \brief Class defining I/O filters for Qgis Mapserver and + * implemented in plugins. * + * Filters can define any (or none) of the following hooks: + * * requestReady() - called when request is ready + * * responseReady() - called when the response is ready */ class QgsServerFilter @@ -32,12 +35,21 @@ class QgsServerFilter public: - /** Constructor */ + /** Constructor + * QgsServerInterface passed to plugins constructors + * and must be passed to QgsServerFilter instances. + */ QgsServerFilter( QgsServerInterface* serverInterface /Transfer/); /** Destructor */ virtual ~QgsServerFilter(); + /** Return the QgsServerInterface instance*/ QgsServerInterface* serverInterface( ); + /** Method called when the QgsRequestHandler is ready and populated with + * parameters, just before entering the main switch for core services.*/ virtual void requestReady(); + /** Method called when the QgsRequestHandler processing has done and + * the response is ready, just after the main switch for core services. + */ virtual void responseReady(); }; diff --git a/python/server/qgsserverinterface.sip b/python/server/qgsserverinterface.sip index a308e6666490..4b4de41307d9 100644 --- a/python/server/qgsserverinterface.sip +++ b/python/server/qgsserverinterface.sip @@ -1,9 +1,31 @@ +/*************************************************************************** + qgsserverinterface.sip + + Class defining the interface made available to server plugins. + ------------------- + begin : 2014-09-10 + copyright : (C) 2014 by Alessandro Pasotti + email : a dot pasotti at itopen dot it + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + /** * \class QgsServerInterface - * \brief Class defining interfaces - * made available to server plugins. + * \brief Class defining the interface made available to server plugins. * - * Only functionality exposed by QgisServerInterface can be used in server plugins. + * This class provides methods to access the request handler and + * the capabilties cache. A method to read the environment + * variables set in the main FCGI loop is also available. + * Plugins can add listeners (instances of QgsServerFilter) with + * a certain priority through the registerFilter( QgsServerFilter* , int) method. */ @@ -16,10 +38,15 @@ class QgsServerInterface %End public: - virtual QgsCapabilitiesCache* capabiblitiesCache() = 0 /KeepReference/; + /**Returns the current request handler*/ virtual QgsRequestHandler* requestHandler( ) = 0 /KeepReference/; + /**Returns the capabilities cache*/ + virtual QgsCapabilitiesCache* capabiblitiesCache() = 0 /KeepReference/; // Tansfer ownership to avoid garbage collector to call dtor + /** Register a filter with the given priority. The filter's requestReady() + * and responseReady() methods will be called from the loop*/ virtual void registerFilter( QgsServerFilter* filter /Transfer/, int priority = 0 ) = 0; + /**Return an environment variable set by FCGI*/ virtual QString getEnv(const QString& name ) const = 0; // Commented because of problems with typedef QgsServerFiltersMap, provided // methods to alter the filters map into QgsRequestHandler API diff --git a/python/server/qgsserverlogger.sip b/python/server/qgsserverlogger.sip deleted file mode 100644 index d1c60dc01cc8..000000000000 --- a/python/server/qgsserverlogger.sip +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** - qgsserverlogger.h - ----------------- - begin : May 5, 2014 - copyright : (C) 2014 by Marco Hugentobler - email : marco dot hugentobler at sourcepole 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. * - * * - ***************************************************************************/ - - -/**Writes message log into server logfile*/ -class QgsServerLogger: public QObject -{ -%TypeHeaderCode - #include "qgsserverlogger.h" -%End - - public: - static QgsServerLogger* instance(); - - int logLevel(); - - public slots: - void logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level ); - -}; diff --git a/python/server/server.sip b/python/server/server.sip index e06aa879b0dd..c5125a702e46 100644 --- a/python/server/server.sip +++ b/python/server/server.sip @@ -10,7 +10,6 @@ %Import core/core.sip %Include qgsserverfilter.sip -%Include qgsserverlogger.sip %Include qgsmapserviceexception.sip %Include qgscapabilitiescache.sip %Include qgsrequesthandler.sip