QEverCloud  6.1.0
Unofficial Evernote Cloud API for Qt
AsyncResult.h
Go to the documentation of this file.
1 
9 #ifndef QEVERCLOUD_ASYNC_RESULT_H
10 #define QEVERCLOUD_ASYNC_RESULT_H
11 
12 #include "EverCloudException.h"
13 #include "Export.h"
14 #include "Helpers.h"
15 #include "RequestContext.h"
16 
17 #include <QNetworkRequest>
18 #include <QObject>
19 #include <QUuid>
20 
21 namespace qevercloud {
22 
23 QT_FORWARD_DECLARE_CLASS(AsyncResultPrivate)
24 QT_FORWARD_DECLARE_CLASS(DurableService)
25 
26 
53 class QEVERCLOUD_EXPORT AsyncResult: public QObject
54 {
55  Q_OBJECT
56  Q_DISABLE_COPY(AsyncResult)
57 public:
58  static QVariant asIs(QByteArray replyData);
59 
60  typedef QVariant (*ReadFunctionType)(QByteArray replyData);
61 
62  AsyncResult(QString url, QByteArray postData,
64  ReadFunctionType readFunction = AsyncResult::asIs,
65  bool autoDelete = true, QObject * parent = nullptr);
66 
67  AsyncResult(QNetworkRequest request, QByteArray postData,
69  ReadFunctionType readFunction = AsyncResult::asIs,
70  bool autoDelete = true, QObject * parent = nullptr);
71 
76  AsyncResult(QVariant result, EverCloudExceptionDataPtr error,
77  IRequestContextPtr ctx, bool autoDelete = true,
78  QObject * parent = nullptr);
79 
81 
88  bool waitForFinished(int timeout = -1);
89 
90 Q_SIGNALS:
102  void finished(
103  QVariant result,
105  IRequestContextPtr ctx);
106 
107 private:
108  friend class DurableService;
109 
110 private:
111  AsyncResultPrivate * const d_ptr;
112  Q_DECLARE_PRIVATE(AsyncResult)
113 };
114 
115 } // namespace qevercloud
116 
117 #endif // QEVERCLOUD_ASYNC_RESULT_H
Export.h
qevercloud::AsyncResult::AsyncResult
AsyncResult(QString url, QByteArray postData, IRequestContextPtr ctx, ReadFunctionType readFunction=AsyncResult::asIs, bool autoDelete=true, QObject *parent=nullptr)
qevercloud::AsyncResult::AsyncResult
AsyncResult(QVariant result, EverCloudExceptionDataPtr error, IRequestContextPtr ctx, bool autoDelete=true, QObject *parent=nullptr)
qevercloud::AsyncResult::finished
void finished(QVariant result, EverCloudExceptionDataPtr error, IRequestContextPtr ctx)
Emitted upon asynchronous call completition.
EverCloudException.h
qevercloud
Definition: AsyncResult.h:21
qevercloud::AsyncResult
Returned by asynchonous versions of functions.
Definition: AsyncResult.h:54
Helpers.h
RequestContext.h
qevercloud::AsyncResult::asIs
static QVariant asIs(QByteArray replyData)
qevercloud::AsyncResult::~AsyncResult
~AsyncResult()
qevercloud::IRequestContextPtr
std::shared_ptr< IRequestContext > IRequestContextPtr
Definition: RequestContext.h:81
QEVERCLOUD_EXPORT
#define QEVERCLOUD_EXPORT
Definition: Export.h:19
qevercloud::EverCloudExceptionDataPtr
std::shared_ptr< EverCloudExceptionData > EverCloudExceptionDataPtr
Definition: EverCloudException.h:149
qevercloud::AsyncResult::waitForFinished
bool waitForFinished(int timeout=-1)
Wait for asynchronous operation to complete.
qevercloud::AsyncResult::AsyncResult
AsyncResult(QNetworkRequest request, QByteArray postData, IRequestContextPtr ctx, ReadFunctionType readFunction=AsyncResult::asIs, bool autoDelete=true, QObject *parent=nullptr)