X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsignalproxy.h;h=23dbc9f2c7ecabc5569a1df23a021eb24b088321;hb=17a902604b2631d1165fb8c7af65e064e37a49d7;hp=b787c2ad5d03e01029925abd32dfbe9f06324890;hpb=4bd0fcd5b0599f3658253353bf2bdc01b32951f7;p=quassel.git diff --git a/src/common/signalproxy.h b/src/common/signalproxy.h index b787c2ad..23dbc9f2 100644 --- a/src/common/signalproxy.h +++ b/src/common/signalproxy.h @@ -29,6 +29,8 @@ #include #include +#include + class SignalRelay; class QMetaObject; @@ -62,32 +64,41 @@ public: bool attachSlot(const QByteArray& sigName, QObject *recv, const char *slot); void synchronize(QObject *obj); - void synchronizeAsMaster(QObject *obj); - void synchronizeAsSlave(QObject *obj); void setInitialized(QObject *obj); bool initialized(QObject *obj); void requestInit(QObject *obj); - + void detachObject(QObject *obj); void detachSignals(QObject *sender); void detachSlots(QObject *receiver); - + void stopSync(QObject *obj); + + //! Writes a QVariant to a device. + /** The data item is prefixed with the resulting blocksize, + * so the corresponding function readDataFromDevice() can check if enough data is available + * at the device to reread the item. + */ static void writeDataToDevice(QIODevice *dev, const QVariant &item); + + //! Reads a data item from a device that has been written by writeDataToDevice(). + /** If not enough data bytes are available, the function returns false and the QVariant reference + * remains untouched. + */ static bool readDataFromDevice(QIODevice *dev, quint32 &blockSize, QVariant &item); static QString methodBaseName(const QMetaMethod &method); const QList &argTypes(QObject *obj, int methodId); const QByteArray &methodName(QObject *obj, int methodId); - const QHash &syncMap(QObject *obj); + const QHash &syncMap(QObject *obj); typedef QHash > ArgHash; typedef QHash MethodNameHash; struct ClassInfo { ArgHash argTypes; MethodNameHash methodNames; - QHash syncMap; + QHash syncMap; }; void dumpProxyStats(); @@ -132,9 +143,13 @@ private: void _detachSignals(QObject *sender); void _detachSlots(QObject *receiver); + void _stopSync(QObject *obj); - void dumpSyncMap(QObject *object); + void dumpSyncMap(QObject *object); + // Hash of used QIODevices + QHash _peerByteCount; + // containg a list of argtypes for fast access QHash _classInfo; @@ -150,11 +165,14 @@ private: typedef QHash ObjectId; QHash _syncSlave; - // Hash of used QIODevices - QHash _peerByteCount; ProxyMode _proxyMode; + // the slaveMutex protects both containers: + // - _syncSlaves for sync and init calls + // - _attachedSlots + QMutex slaveMutex; + friend class SignalRelay; };