24 #ifndef GAMMARAY_ENDPOINT_H
25 #define GAMMARAY_ENDPOINT_H
27 #include "gammaray_common_export.h"
45 class GAMMARAY_COMMON_EXPORT
Endpoint :
public QObject
52 static void send(
const Message &msg);
55 static bool isConnected();
57 static quint16 defaultPort();
58 static quint16 broadcastPort();
61 Protocol::ObjectAddress objectAddress(
const QString &objectName)
const;
69 virtual Protocol::ObjectAddress registerObject(
const QString &name, QObject *
object);
80 virtual void invokeObject(
const QString &objectName,
const char *method,
const QVariantList &args = QVariantList())
const;
87 void waitForMessagesWritten();
92 QString label()
const;
97 void setLabel(
const QString &label);
102 virtual bool isRemoteClient()
const = 0;
108 virtual QString serverAddress()
const = 0;
115 void objectRegistered(
const QString &objectName, Protocol::ObjectAddress objectAddress);
116 void objectUnregistered(
const QString &objectName, Protocol::ObjectAddress objectAddress);
121 void setDevice(QIODevice* device);
124 Protocol::ObjectAddress endpointAddress()
const;
129 virtual void messageReceived(
const Message &msg) = 0;
132 void registerObjectInternal(
const QString &objectName, Protocol::ObjectAddress objectAddress);
134 void unregisterObjectInternal(
const QString& objectName);
139 void registerMessageHandlerInternal(Protocol::ObjectAddress objectAddress, QObject *receiver,
const char* messageHandlerName);
142 void unregisterMessageHandlerInternal(Protocol::ObjectAddress objectAddress);
145 virtual void handlerDestroyed(Protocol::ObjectAddress objectAddress,
const QString &objectName) = 0;
148 virtual void objectDestroyed(Protocol::ObjectAddress objectAddress,
const QString &objectName, QObject *
object) = 0;
151 void dispatchMessage(
const GammaRay::Message& msg);
154 QVector<QPair<Protocol::ObjectAddress, QString> > objectAddresses()
const;
164 void invokeObjectLocal(QObject *
object,
const char *method,
const QVariantList &args)
const;
168 void connectionClosed();
169 void handlerDestroyed(QObject* obj);
170 void objectDestroyed(QObject* obj);
176 : address(Protocol::InvalidObjectAddress)
182 Protocol::ObjectAddress address;
189 QByteArray messageHandler;
193 void insertObjectInfo(ObjectInfo *oi);
195 void removeObjectInfo(ObjectInfo *oi);
197 QHash<QString, ObjectInfo*> m_nameMap;
198 QHash<Protocol::ObjectAddress, ObjectInfo*> m_addressMap;
199 QHash<QObject*, ObjectInfo*> m_objectMap;
200 QMultiHash<QObject*, ObjectInfo*> m_handlerMap;
202 QPointer<QIODevice> m_socket;
203 Protocol::ObjectAddress m_myAddress;
210 #endif // GAMMARAY_ENDPOINT_H