X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fsignalproxy.h;h=23dbc9f2c7ecabc5569a1df23a021eb24b088321;hp=50010607604019fcd214890ee75dc5a6f33de128;hb=17a902604b2631d1165fb8c7af65e064e37a49d7;hpb=a7f5d6a23f7214b11f6db85346a67fd7d02767da diff --git a/src/common/signalproxy.h b/src/common/signalproxy.h index 50010607..23dbc9f2 100644 --- a/src/common/signalproxy.h +++ b/src/common/signalproxy.h @@ -5,7 +5,7 @@ * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -16,16 +16,6 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - *************************************************************************** - * SignalProxy has been inspired by QxtRPCPeer, part of libqxt, * - * the Qt eXTension Library . We would like to * - * thank Arvid "aep" Picciani and Adam "ahigerd" Higerd for providing * - * QxtRPCPeer, valuable input and the genius idea to (ab)use Qt's * - * Meta Object System for transmitting signals over the network. * - * * - * To make contribution back into libqxt possible, redistribution and * - * modification of this file is additionally allowed under the terms of * - * the Common Public License, version 1.0, as published by IBM. * ***************************************************************************/ #ifndef _SIGNALPROXY_H_ @@ -39,6 +29,8 @@ #include #include +#include + class SignalRelay; class QMetaObject; @@ -72,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(); @@ -142,6 +143,12 @@ private: void _detachSignals(QObject *sender); void _detachSlots(QObject *receiver); + void _stopSync(QObject *obj); + + void dumpSyncMap(QObject *object); + + // Hash of used QIODevices + QHash _peerByteCount; // containg a list of argtypes for fast access QHash _classInfo; @@ -158,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; };