1// Copyright (C) 2022 The Qt Company Ltd.
2// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5#ifndef QGRPCCALLREPLY_H
6#define QGRPCCALLREPLY_H
7
8#include <QtGrpc/qgrpcoperation.h>
9#include <QtGrpc/qtgrpcglobal.h>
10
11QT_BEGIN_NAMESPACE
12
13class Q_GRPC_EXPORT QGrpcCallReply final : public QGrpcOperation
14{
15 Q_OBJECT
16
17public:
18 explicit QGrpcCallReply(std::shared_ptr<QAbstractProtobufSerializer> serializer);
19 ~QGrpcCallReply() override;
20
21 void abort() override;
22
23 template<typename Func1, typename Func2>
24 void subscribe(QObject *receiver, Func1 &&finishCallback, Func2 &&errorCallback,
25 Qt::ConnectionType type = Qt::AutoConnection)
26 {
27 QObject::connect(this, &QGrpcCallReply::finished, receiver,
28 std::forward<Func1>(finishCallback), type);
29 QObject::connect(this, &QGrpcCallReply::errorOccurred, receiver,
30 std::forward<Func2>(errorCallback), type);
31 }
32
33 template<typename Func1>
34 void subscribe(QObject *receiver, Func1 &&finishCallback,
35 Qt::ConnectionType type = Qt::AutoConnection)
36 {
37 QObject::connect(this, &QGrpcCallReply::finished, receiver,
38 std::forward<Func1>(finishCallback), type);
39 }
40
41private:
42 QGrpcCallReply();
43 Q_DISABLE_COPY_MOVE(QGrpcCallReply)
44};
45
46QT_END_NAMESPACE
47
48#endif // QGRPCCALLREPLY_H
49

source code of qtgrpc/src/grpc/qgrpccallreply.h