QtProtobuf  0.6
Protobuf plugin to generate Qt classes
qabstractgrpcchannel.h
1 /*
2  * MIT License
3  *
4  * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
5  *
6  * This file is part of QtProtobuf project https://git.semlanik.org/semlanik/qtprotobuf
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy of this
9  * software and associated documentation files (the "Software"), to deal in the Software
10  * without restriction, including without limitation the rights to use, copy, modify,
11  * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
12  * to permit persons to whom the Software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in all copies
16  * or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21  * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  */
25 
26 #pragma once //QAbstractGrpcChannel
27 
28 #include <QString>
29 #include <QByteArray>
30 #include <functional>
31 #include <memory>
32 
33 #include "qgrpcstatus.h"
34 #include "qgrpccredentials.h"
35 #include "qtgrpcglobal.h"
36 
37 class QThread;
38 
39 namespace QtProtobuf {
40 
41 class QGrpcAsyncReply;
42 class QGrpcSubscription;
43 class QAbstractGrpcClient;
44 class QAbstractProtobufSerializer;
45 struct QAbstractGrpcChannelPrivate;
51 class Q_GRPC_EXPORT QAbstractGrpcChannel
52 {
53 public:
65  virtual QGrpcStatus call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret) = 0;
66 
78  virtual void call(const QString &method, const QString &service, const QByteArray &args, QtProtobuf::QGrpcAsyncReply *ret) = 0;
79 
88  virtual void subscribe(QGrpcSubscription *subscription, const QString &service, QAbstractGrpcClient *client) = 0;
89 
90  virtual std::shared_ptr<QAbstractProtobufSerializer> serializer() const = 0;
91 
92  const QThread *thread() const;
93 
94 protected:
98  virtual ~QAbstractGrpcChannel();
99 
105  virtual void abort(QGrpcAsyncReply *reply);
106 
112  virtual void cancel(QGrpcSubscription *subscription);
113 
114  friend class QGrpcAsyncReply;
115  friend class QGrpcSubscription;
116 private:
117  Q_DISABLE_COPY(QAbstractGrpcChannel)
118  std::unique_ptr<QAbstractGrpcChannelPrivate> dPtr;
119 };
120 }
The QAbstractGrpcChannel class is interface that represents common gRPC channel functionality.
Definition: qabstractgrpcchannel.h:52
virtual void subscribe(QGrpcSubscription *subscription, const QString &service, QAbstractGrpcClient *client)=0
Subscribes to server-side stream to receive updates for given method.
virtual void call(const QString &method, const QString &service, const QByteArray &args, QtProtobuf::QGrpcAsyncReply *ret)=0
Calls method asynchronously with given serialized messge args.
virtual QGrpcStatus call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret)=0
Calls method synchronously with given serialized message args and write result of call to ret.
The QAbstractGrpcClient class is bridge between gRPC clients and channels.
Definition: qabstractgrpcclient.h:67
The QGrpcAsyncReply class contains data for asynchronous call of gRPC client API.
Definition: qgrpcasyncreply.h:47
The QGrpcStatus class contains information about last gRPC operation.
Definition: qgrpcstatus.h:58
The QGrpcSubscription class.
Definition: qgrpcsubscription.h:47