1// Copyright (C) 2017 Ford Motor Company
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQREMOTEOBJECTREPLICA_H
6#define QQREMOTEOBJECTREPLICA_H
7
8#include <QtRemoteObjects/qtremoteobjectglobal.h>
9
10#include <QtCore/qobject.h>
11#include <QtCore/qsharedpointer.h>
12
13Q_MOC_INCLUDE(<QtRemoteObjects/qremoteobjectnode.h>)
14
15QT_BEGIN_NAMESPACE
16
17class QObjectPrivate;
18class QRemoteObjectPendingCall;
19class QRemoteObjectReplicaImplementation;
20class QReplicaImplementationInterface;
21class QRemoteObjectNode;
22
23class Q_REMOTEOBJECTS_EXPORT QRemoteObjectReplica : public QObject
24{
25 Q_OBJECT
26 Q_PROPERTY(QRemoteObjectNode *node READ node WRITE setNode)
27 Q_PROPERTY(State state READ state NOTIFY stateChanged)
28public:
29 enum State {
30 Uninitialized,
31 Default,
32 Valid,
33 Suspect,
34 SignatureMismatch
35 };
36 Q_ENUM(State)
37
38public:
39 ~QRemoteObjectReplica() override;
40
41 bool isReplicaValid() const;
42 bool waitForSource(int timeout = 30000);
43 bool isInitialized() const;
44 State state() const;
45 QRemoteObjectNode *node() const;
46 virtual void setNode(QRemoteObjectNode *node);
47
48Q_SIGNALS:
49 void initialized();
50 void notified();
51 void stateChanged(State state, State oldState);
52
53protected:
54 enum ConstructorType {DefaultConstructor, ConstructWithNode};
55 explicit QRemoteObjectReplica(ConstructorType t = DefaultConstructor);
56 QRemoteObjectReplica(QObjectPrivate &dptr, QObject *parent);
57
58 virtual void initialize();
59 void send(QMetaObject::Call call, int index, const QVariantList &args);
60 QRemoteObjectPendingCall sendWithReply(QMetaObject::Call call, int index, const QVariantList &args);
61
62protected:
63 void setProperties(QVariantList &&);
64 void setChild(int i, const QVariant &);
65 const QVariant propAsVariant(int i) const;
66 void persistProperties(const QString &repName, const QByteArray &repSig, const QVariantList &props) const;
67 QVariantList retrieveProperties(const QString &repName, const QByteArray &repSig) const;
68 void initializeNode(QRemoteObjectNode *node, const QString &name = QString());
69 QSharedPointer<QReplicaImplementationInterface> d_impl;
70private:
71 friend class QRemoteObjectNodePrivate;
72 friend class QConnectedReplicaImplementation;
73};
74
75QT_END_NAMESPACE
76
77#endif
78

source code of qtremoteobjects/src/remoteobjects/qremoteobjectreplica.h