OpenMS
NetworkGetRequest.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Timo Sachsenberg $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/config.h>
12 
13 #include <QtCore/QObject>
14 #include <QtCore/QString>
15 #include <QtCore/QUrl>
16 #include <QtNetwork/QNetworkReply>
17 
18 namespace OpenMS
19 {
20 
22  public QObject
23  {
24  Q_OBJECT
25 
26  public:
27 
32  OPENMS_DLLAPI NetworkGetRequest(QObject* parent = nullptr);
33 
35  OPENMS_DLLAPI ~NetworkGetRequest() override;
37 
38  // set request parameters
39  OPENMS_DLLAPI void setUrl(const QUrl& url);
40 
42  OPENMS_DLLAPI QString getResponse() const;
43 
45  OPENMS_DLLAPI const QByteArray& getResponseBinary() const;
46 
48  OPENMS_DLLAPI bool hasError() const;
49 
51  OPENMS_DLLAPI QString getErrorString() const;
52 
53  protected:
54 
55  public slots:
56 
57  OPENMS_DLLAPI void run();
58 
59  OPENMS_DLLAPI void timeOut();
60 
61  private slots:
62 
63  OPENMS_DLLAPI void replyFinished(QNetworkReply*);
64 
65  signals:
66 
67  OPENMS_DLLAPI void done();
68 
69  private:
71  OPENMS_DLLAPI NetworkGetRequest& operator=(const NetworkGetRequest& rhs);
73  OPENMS_DLLAPI NetworkGetRequest(const NetworkGetRequest& rhs);
74 
75  QByteArray response_bytes_;
76  QUrl url_;
77  QNetworkAccessManager* manager_;
78  QNetworkReply* reply_;
79  QNetworkReply::NetworkError error_;
80  QString error_string_;
81  };
82 }
83 
Definition: NetworkGetRequest.h:23
QNetworkAccessManager * manager_
Definition: NetworkGetRequest.h:77
QString getErrorString() const
returns the error message, if hasError can be used to check whether an error has occurred
QNetworkReply * reply_
Definition: NetworkGetRequest.h:78
QByteArray response_bytes_
Definition: NetworkGetRequest.h:75
NetworkGetRequest(const NetworkGetRequest &rhs)
copy constructor
bool hasError() const
returns true if an error occurred during the query
NetworkGetRequest(QObject *parent=nullptr)
default constructor
QNetworkReply::NetworkError error_
Definition: NetworkGetRequest.h:79
void setUrl(const QUrl &url)
const QByteArray & getResponseBinary() const
returns the response
QUrl url_
Definition: NetworkGetRequest.h:76
NetworkGetRequest & operator=(const NetworkGetRequest &rhs)
assignment operator
QString getResponse() const
returns the response
void replyFinished(QNetworkReply *)
~NetworkGetRequest() override
destructor
QString error_string_
Definition: NetworkGetRequest.h:80
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19