1 | // Copyright (C) 2017 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QMQTTMESSAGE_H |
5 | #define QMQTTMESSAGE_H |
6 | |
7 | #include <QtMqtt/qmqttglobal.h> |
8 | #include <QtMqtt/qmqttpublishproperties.h> |
9 | #include <QtMqtt/qmqtttopicname.h> |
10 | |
11 | #include <QtCore/QObject> |
12 | #include <QtCore/QSharedDataPointer> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | class QMqttMessagePrivate; |
17 | |
18 | class Q_MQTT_EXPORT QMqttMessage |
19 | { |
20 | Q_GADGET |
21 | Q_PROPERTY(QMqttTopicName topic READ topic CONSTANT) |
22 | Q_PROPERTY(QByteArray payload READ payload CONSTANT) |
23 | Q_PROPERTY(quint16 id READ id CONSTANT) |
24 | Q_PROPERTY(quint8 qos READ qos CONSTANT) |
25 | Q_PROPERTY(bool duplicate READ duplicate CONSTANT) |
26 | Q_PROPERTY(bool retain READ retain CONSTANT) |
27 | |
28 | public: |
29 | QMqttMessage(); |
30 | QMqttMessage(const QMqttMessage& other); |
31 | ~QMqttMessage(); |
32 | |
33 | QMqttMessage& operator=(const QMqttMessage &other); |
34 | bool operator==(const QMqttMessage &other) const; |
35 | inline bool operator!=(const QMqttMessage &other) const; |
36 | |
37 | const QByteArray &payload() const; |
38 | quint8 qos() const; |
39 | quint16 id() const; |
40 | QMqttTopicName topic() const; |
41 | bool duplicate() const; |
42 | bool retain() const; |
43 | |
44 | QMqttPublishProperties publishProperties() const; |
45 | private: |
46 | friend class QMqttConnection; |
47 | QMqttMessage(const QMqttTopicName &topic, const QByteArray &payload, |
48 | quint16 id, quint8 qos, |
49 | bool dup, bool retain); |
50 | QExplicitlySharedDataPointer<QMqttMessagePrivate> d; |
51 | }; |
52 | |
53 | QT_END_NAMESPACE |
54 | |
55 | Q_DECLARE_METATYPE(QMqttMessage) |
56 | |
57 | #endif // QMQTTMESSAGE_H |
58 |