+ class ExtendedMetaObject;
+ ExtendedMetaObject *extendedMetaObject(const QMetaObject *meta) const;
+ ExtendedMetaObject *createExtendedMetaObject(const QMetaObject *meta, bool checkConflicts = false);
+ inline ExtendedMetaObject *extendedMetaObject(const QObject *obj) const { return extendedMetaObject(metaObject(obj)); }
+ inline ExtendedMetaObject *createExtendedMetaObject(const QObject *obj, bool checkConflicts = false) { return createExtendedMetaObject(metaObject(obj), checkConflicts); }
+
+ bool isSecure() const { return _secure; }
+ void dumpProxyStats();
+ void dumpSyncMap(SyncableObject *object);
+
+ static SignalProxy *current() {
+ return _current;
+ }
+
+ /**@{*/
+ /**
+ * This method allows to send a signal only to a limited set of peers
+ * @param peers A list of peers that should receive it
+ * @param closure Code you want to execute within of that restricted environment
+ */
+ void restrictTargetPeers(QSet<Peer*> peers, std::function<void()> closure);
+ void restrictTargetPeers(Peer *peer, std::function<void()> closure) {
+ QSet<Peer*> set;
+ set.insert(peer);
+ restrictTargetPeers(set, std::move(closure));
+ }
+
+ //A better version, but only implemented on Qt5 if Initializer Lists exist
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#ifdef Q_COMPILER_INITIALIZER_LISTS
+ void restrictTargetPeers(std::initializer_list<Peer*> peers, std::function<void()> closure) {
+ restrictTargetPeers(QSet<Peer*>(peers), std::move(closure));
+ }
+#endif
+#endif
+ /**}@*/
+
+ inline int peerCount() const { return _peerMap.size(); }
+ QVariantList peerData();
+
+ Peer *peerById(int peerId);
+
+ /**
+ * @return If handling a signal, the Peer from which the current signal originates
+ */
+ Peer *sourcePeer();
+ void setSourcePeer(Peer *sourcePeer);
+
+ /**
+ * @return If sending a signal, the Peer to which the current signal is directed
+ */
+ Peer *targetPeer();
+ void setTargetPeer(Peer *targetPeer);
+
+public slots:
+ void detachObject(QObject *obj);
+ void detachSignals(QObject *sender);
+ void detachSlots(QObject *receiver);
+
+protected:
+ void customEvent(QEvent *event);
+ void sync_call__(const SyncableObject *obj, ProxyMode modeType, const char *funcname, va_list ap);
+ void renameObject(const SyncableObject *obj, const QString &newname, const QString &oldname);
+
+private slots:
+ void removePeerBySender();
+ void objectRenamed(const QByteArray &classname, const QString &newname, const QString &oldname);
+ void updateSecureState();
+
+signals:
+ void peerRemoved(Peer *peer);
+ void connected();
+ void disconnected();
+ void objectInitialized(SyncableObject *);
+ void heartBeatIntervalChanged(int secs);
+ void maxHeartBeatCountChanged(int max);
+ void lagUpdated(int lag);
+ void secureStateChanged(bool);
+
+private:
+ template<class T>
+ class PeerMessageEvent;
+
+ void init();
+ void initServer();
+ void initClient();
+
+ static const QMetaObject *metaObject(const QObject *obj);
+
+ void removePeer(Peer *peer);
+ void removeAllPeers();
+
+ int nextPeerId() {
+ return _lastPeerId++;
+ }
+
+ template<class T>
+ void dispatch(const T &protoMessage);
+ template<class T>
+ void dispatch(Peer *peer, const T &protoMessage);
+
+ void handle(Peer *peer, const Protocol::SyncMessage &syncMessage);
+ void handle(Peer *peer, const Protocol::RpcCall &rpcCall);
+ void handle(Peer *peer, const Protocol::InitRequest &initRequest);
+ void handle(Peer *peer, const Protocol::InitData &initData);
+
+ template<class T>
+ void handle(Peer *, T) { Q_ASSERT(0); }
+
+ bool invokeSlot(QObject *receiver, int methodId, const QVariantList ¶ms, QVariant &returnValue, Peer *peer = 0);
+ bool invokeSlot(QObject *receiver, int methodId, const QVariantList ¶ms = QVariantList(), Peer *peer = 0);