summaryrefslogtreecommitdiffstats
path: root/src/grpc/qgrpcstream.h
blob: 05a55cca470fcabd813736555b472399c007fba0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (C) 2022 The Qt Company Ltd.
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QGRPCSTREAM_H
#define QGRPCSTREAM_H

#include <QtGrpc/qgrpcoperation.h>
#include <QtGrpc/qtgrpcglobal.h>

#include <memory>

QT_BEGIN_NAMESPACE

class Q_GRPC_EXPORT QGrpcServerStream final : public QGrpcOperation
{
    Q_OBJECT
    QT_DEFINE_TAG_STRUCT(PrivateConstructor);

public:
    explicit QGrpcServerStream(const QLatin1StringView service, const QLatin1StringView method,
                               const QGrpcCallOptions &options,
                               const std::weak_ptr<QAbstractGrpcChannel> &channel,
                               PrivateConstructor);
    ~QGrpcServerStream() override;

Q_SIGNALS:
    void messageReceived();

private:
    Q_DISABLE_COPY_MOVE(QGrpcServerStream)
    friend class QGrpcClientBasePrivate;

public:
    bool event(QEvent *event) override;
};

class Q_GRPC_EXPORT QGrpcClientStream final : public QGrpcOperation
{
    Q_OBJECT
    QT_DEFINE_TAG_STRUCT(PrivateConstructor);

public:
    explicit QGrpcClientStream(const QLatin1StringView service, const QLatin1StringView method,
                               const QGrpcCallOptions &options,
                               const std::weak_ptr<QAbstractGrpcChannel> &channel,
                               PrivateConstructor);
    ~QGrpcClientStream() override;

    void writeMessage(const QProtobufMessage &message);
    void writesDone();

private:
    Q_DISABLE_COPY_MOVE(QGrpcClientStream)
    friend class QGrpcClientBasePrivate;

public:
    bool event(QEvent *event) override;
};

class Q_GRPC_EXPORT QGrpcBidiStream final : public QGrpcOperation
{
    Q_OBJECT
    QT_DEFINE_TAG_STRUCT(PrivateConstructor);

public:
    explicit QGrpcBidiStream(const QLatin1StringView service, const QLatin1StringView method,
                             const QGrpcCallOptions &options,
                             const std::weak_ptr<QAbstractGrpcChannel> &channel,
                             PrivateConstructor);
    ~QGrpcBidiStream() override;

    void writeMessage(const QProtobufMessage &message);
    void writesDone();

Q_SIGNALS:
    void messageReceived();

private:
    Q_DISABLE_COPY_MOVE(QGrpcBidiStream)
    friend class QGrpcClientBasePrivate;

public:
    bool event(QEvent *event) override;
};

QT_END_NAMESPACE

#endif // QGRPCSTREAM_H