QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsfilterresponsedecorator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfilterresponsedecorator.h
3 
4  Define response adapter for handling filter's hooks
5  -------------------
6  begin : 2017-01-05
7  copyright : (C) 2017 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 QGSFILTERRESPONSEDECORATOR_H
20 #define QGSFILTERRESPONSEDECORATOR_H
21 
22 #define SIP_NO_FILE
23 
24 
25 #include "qgsserverresponse.h"
26 #include "qgsserverfilter.h"
27 #include "qgsserverexception.h"
28 
36 {
37  public:
38 
45 
49  void start() SIP_THROW( QgsServerException ) SIP_VIRTUALERRORHANDLER( server_exception_handler );
50 
51  // QgsServerResponse overrides
52 
53  void setHeader( const QString &key, const QString &value ) override { mResponse.setHeader( key, value ); }
54 
55  void removeHeader( const QString &key ) override { mResponse.removeHeader( key ); }
56 
57  QString header( const QString &key ) const override { return mResponse.header( key ); }
58 
59  QMap<QString, QString> headers() const override { return mResponse.headers(); }
60 
61  bool headersSent() const override { return mResponse.headersSent(); }
62 
63  void setStatusCode( int code ) override { mResponse.setStatusCode( code ); }
64 
65  int statusCode() const override { return mResponse.statusCode(); }
66 
67  void sendError( int code, const QString &message ) override { mResponse.sendError( code, message ); }
68 
69  QIODevice *io() override { return mResponse.io(); }
70 
71  void finish() override;
72 
73  void flush() override;
74 
75  void clear() override { mResponse.clear(); }
76 
77  QByteArray data() const override { return mResponse.data(); }
78 
79  void truncate() override { mResponse.truncate(); }
80 
81  private:
82  QgsServerFiltersMap mFilters;
83  QgsServerResponse &mResponse;
84 };
85 
86 #endif
87 
88 
89 
90 
91 
QgsFilterResponseDecorator::clear
void clear() override
Reset all headers and content for this response.
Definition: qgsfilterresponsedecorator.h:75
QgsFilterResponseDecorator::start
void start() SIP_THROW(QgsServerException)
Call filters requestReady() method.
Definition: qgsfilterresponsedecorator.cpp:30
QgsServerResponse::truncate
virtual void truncate()=0
Truncate data.
QgsServerResponse::clear
virtual void clear()=0
Reset all headers and content for this response.
QgsFilterResponseDecorator::sendError
void sendError(int code, const QString &message) override
Send error This method delegates error handling at the server level.
Definition: qgsfilterresponsedecorator.h:67
QgsFilterResponseDecorator::flush
void flush() override
Flushes the current output buffer to the network.
Definition: qgsfilterresponsedecorator.cpp:55
QgsFilterResponseDecorator::truncate
void truncate() override
Truncate data.
Definition: qgsfilterresponsedecorator.h:79
QgsFilterResponseDecorator::finish
void finish() override
Finish the response, ending the transaction.
Definition: qgsfilterresponsedecorator.cpp:41
QgsFilterResponseDecorator::header
QString header(const QString &key) const override
Returns the header value.
Definition: qgsfilterresponsedecorator.h:57
QgsServerResponse::statusCode
virtual int statusCode() const =0
Returns the http status code.
QgsFilterResponseDecorator::removeHeader
void removeHeader(const QString &key) override
Clear header Undo a previous 'setHeader' call.
Definition: qgsfilterresponsedecorator.h:55
SIP_THROW
#define SIP_THROW(name)
Definition: qgis_sip.h:189
QgsFilterResponseDecorator::headersSent
bool headersSent() const override
Returns true if the headers have already been sent.
Definition: qgsfilterresponsedecorator.h:61
qgsserverresponse.h
QgsServerResponse::header
virtual QString header(const QString &key) const =0
Returns the header value.
QgsServerResponse::setStatusCode
virtual void setStatusCode(int code)=0
Set the http status code.
QgsServerResponse::removeHeader
virtual void removeHeader(const QString &key)=0
Clear header Undo a previous 'setHeader' call.
QgsServerResponse::data
virtual QByteArray data() const =0
Gets the data written so far.
QgsFilterResponseDecorator::QgsFilterResponseDecorator
QgsFilterResponseDecorator(QgsServerFiltersMap filters, QgsServerResponse &response)
Constructor for QgsFilterResponseDecorator.
Definition: qgsfilterresponsedecorator.cpp:24
QgsFilterResponseDecorator
Class defining decorator for calling filter's hooks.
Definition: qgsfilterresponsedecorator.h:36
QgsServerResponse::headersSent
virtual bool headersSent() const =0
Returns true if the headers have already been sent.
QgsFilterResponseDecorator::statusCode
int statusCode() const override
Returns the http status code.
Definition: qgsfilterresponsedecorator.h:65
QgsFilterResponseDecorator::setHeader
void setHeader(const QString &key, const QString &value) override
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
Definition: qgsfilterresponsedecorator.h:53
QgsServerException
Exception base class for server exceptions.
Definition: qgsserverexception.h:43
QgsFilterResponseDecorator::setStatusCode
void setStatusCode(int code) override
Set the http status code.
Definition: qgsfilterresponsedecorator.h:63
QgsServerResponse::io
virtual QIODevice * io()=0
Returns the underlying QIODevice.
QgsServerFiltersMap
QMultiMap< int, QgsServerFilter * > QgsServerFiltersMap
Definition: qgsserverfilter.h:89
QgsFilterResponseDecorator::headers
QMap< QString, QString > headers() const override
Returns the header value.
Definition: qgsfilterresponsedecorator.h:59
qgsserverfilter.h
QgsFilterResponseDecorator::data
QByteArray data() const override
Gets the data written so far.
Definition: qgsfilterresponsedecorator.h:77
qgsserverexception.h
QgsFilterResponseDecorator::io
QIODevice * io() override
Returns the underlying QIODevice.
Definition: qgsfilterresponsedecorator.h:69
QgsServerResponse::headers
virtual QMap< QString, QString > headers() const =0
Returns the header value.
QgsServerResponse::sendError
virtual void sendError(int code, const QString &message)=0
Send error This method delegates error handling at the server level.
QgsServerResponse
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
Definition: qgsserverresponse.h:44
QgsServerResponse::setHeader
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
SIP_VIRTUALERRORHANDLER
#define SIP_VIRTUALERRORHANDLER(name)
Definition: qgis_sip.h:182