diff options
author | Kevin Funk <kevin.funk.ford@kdab.com> | 2014-11-12 14:16:21 +0100 |
---|---|---|
committer | Kevin Funk <kevin.funk@kdab.com> | 2014-11-20 17:59:55 +0100 |
commit | f4b78bd7dc409ecdf6b4e7014bb376e60eb958a7 (patch) | |
tree | f85af0a28847d7130277a9cdd46efd5a14f25f67 /src/remoteobjects/qremoteobjectreplica_p.h | |
parent | ad4612ff9885dc5a790fc31b6f6f5bd0ab958e15 (diff) |
Implement QRemoteObjectPending{Call, Reply}
This patch introduces the following classes in QTRO:
* QRemoteObjectPendingCall (let's call it ROPC)
* template<typename T> QRemoteObjectPendingReply (based on ROPC)
* QRemoteObjectPendingCallWatcher (QObject, based on ROPC)
This works for both in-process and connected versions replicas.
Also works with dynamic replicas.
Note that these classes' design is loosely copied from QtDBus's API.
(They also have a 'pending call', and watchers.)
Usage:
QRemoteObjectPendingReply<bool> reply = engine_r->start();
QCOMPARE(reply.error(), QRemoteObjectPendingCall::InvalidMessage);
reply.waitForFinished();
QVERIFY(reply.isFinished());
QCOMPARE(reply.returnValue(), true);
TODO:
* Error handling (i.e. what to do with invocations where we never get a
reply for?)
Change-Id: I9d2556b3fcd47a3804c1ada5db526b78c311c0a1
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Reviewed-by: Björn Breitmeyer <bjoern.breitmeyer@kdab.com>
Diffstat (limited to 'src/remoteobjects/qremoteobjectreplica_p.h')
-rw-r--r-- | src/remoteobjects/qremoteobjectreplica_p.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/remoteobjects/qremoteobjectreplica_p.h b/src/remoteobjects/qremoteobjectreplica_p.h index f2451e3..32bdb7e 100644 --- a/src/remoteobjects/qremoteobjectreplica_p.h +++ b/src/remoteobjects/qremoteobjectreplica_p.h @@ -43,10 +43,12 @@ #define QREMOTEOBJECTREPLICA_P_H #include "qremoteobjectreplica.h" + +#include "qremoteobjectpendingcall.h" + #include <QPointer> #include <QVector> #include <qcompilerdetection.h> -#include "qtremoteobjectglobal.h" QT_BEGIN_NAMESPACE @@ -71,11 +73,14 @@ public: virtual bool isInitialized() const { return true; } virtual bool isReplicaValid() const { return true; } virtual bool waitForSource(int) { return true; } + virtual bool waitForFinished(const QRemoteObjectPendingCall &, int) { return true; } + virtual void notifyAboutReply(const QRemoteObjectPackets::QInvokeReplyPacket *) {}; virtual void configurePrivate(QRemoteObjectReplica *); void emitValidChanged(); void emitInitialized(); virtual void _q_send(QMetaObject::Call call, int index, const QVariantList &args) = 0; + virtual QRemoteObjectPendingCall _q_sendWithReply(QMetaObject::Call call, int index, const QVariantList &args) = 0; //Dynamic replica functions virtual void initializeMetaObject(const QInitDynamicPacket *packet); @@ -84,6 +89,7 @@ public: const QMetaObject *m_metaObject; //Dynamic Replica data + QVector<bool> m_methodReturnTypeIsVoid; QVector<QVector<int> > m_methodArgumentTypes; QVector<int> m_remoteObjectMethodTypes; int m_methodOffset, m_propertyOffset; @@ -104,15 +110,25 @@ public: void initialize(const QByteArray &); void configurePrivate(QRemoteObjectReplica *) Q_DECL_OVERRIDE; void requestRemoteObjectSource(); - void sendCommand(const QRemoteObjectPackets::QRemoteObjectPacket *packet); + bool sendCommand(const QRemoteObjectPackets::QRemoteObjectPacket *packet); + QRemoteObjectPendingCall sendCommandWithReply(QRemoteObjectPackets::QInvokePacket* packet); + bool waitForFinished(const QRemoteObjectPendingCall &call, int timeout); + void notifyAboutReply(const QInvokeReplyPacket* replyPacket); void setConnection(ClientIoDevice *conn); void setDisconnected(); + void _q_send(QMetaObject::Call call, int index, const QVariantList &args) Q_DECL_OVERRIDE; + QRemoteObjectPendingCall _q_sendWithReply(QMetaObject::Call call, int index, const QVariantList& args) Q_DECL_OVERRIDE; + void initializeMetaObject(const QInitDynamicPacket *packet) Q_DECL_OVERRIDE; QAtomicInt isSet; QVector<QRemoteObjectReplica *> m_parentsNeedingConnect; QVariantList m_propertyStorage; QPointer<ClientIoDevice> connectionToSource; + + // pending call data + int m_curSerialId; + QHash<int, QRemoteObjectPendingCall> m_pendingCalls; }; class QInProcessReplicaPrivate : public QRemoteObjectReplicaPrivate @@ -126,7 +142,9 @@ public: void setProperty(int i, const QVariant &) Q_DECL_OVERRIDE; bool isShortCircuit() const Q_DECL_OVERRIDE { return true; } - virtual void _q_send(QMetaObject::Call call, int index, const QVariantList &args); + void _q_send(QMetaObject::Call call, int index, const QVariantList &args) Q_DECL_OVERRIDE; + QRemoteObjectPendingCall _q_sendWithReply(QMetaObject::Call call, int index, const QVariantList& args) Q_DECL_OVERRIDE; + QPointer<QRemoteObjectSourcePrivate> connectionToSource; }; |