29 #ifndef GAMMARAY_ENDPOINT_H
30 #define GAMMARAY_ENDPOINT_H
32 #include "gammaray_common_export.h"
52 class GAMMARAY_COMMON_EXPORT
Endpoint :
public QObject
59 static void send(
const Message &msg);
62 static bool isConnected();
64 static quint16 defaultPort();
65 static quint16 broadcastPort();
68 Protocol::ObjectAddress objectAddress(
const QString &objectName)
const;
76 virtual Protocol::ObjectAddress registerObject(
const QString &name, QObject *
object);
87 virtual void invokeObject(
const QString &objectName,
const char *method,
const QVariantList &args = QVariantList())
const;
94 void waitForMessagesWritten();
99 QString label()
const;
104 void setLabel(
const QString &label);
109 virtual bool isRemoteClient()
const = 0;
115 virtual QUrl serverAddress()
const = 0;
119 void sendMessage(
const GammaRay::Message &msg);
126 void objectRegistered(
const QString &objectName, Protocol::ObjectAddress objectAddress);
127 void objectUnregistered(
const QString &objectName, Protocol::ObjectAddress objectAddress);
132 void setDevice(QIODevice* device);
135 Protocol::ObjectAddress endpointAddress()
const;
140 virtual void messageReceived(
const Message &msg) = 0;
143 void registerObjectInternal(
const QString &objectName, Protocol::ObjectAddress objectAddress);
145 void unregisterObjectInternal(
const QString& objectName);
150 void registerMessageHandlerInternal(Protocol::ObjectAddress objectAddress, QObject *receiver,
const char* messageHandlerName);
153 void unregisterMessageHandlerInternal(Protocol::ObjectAddress objectAddress);
156 virtual void handlerDestroyed(Protocol::ObjectAddress objectAddress,
const QString &objectName) = 0;
159 virtual void objectDestroyed(Protocol::ObjectAddress objectAddress,
const QString &objectName, QObject *
object) = 0;
162 void dispatchMessage(
const GammaRay::Message& msg);
165 QVector<QPair<Protocol::ObjectAddress, QString> > objectAddresses()
const;
175 void invokeObjectLocal(QObject *
object,
const char *method,
const QVariantList &args)
const;
177 PropertySyncer *m_propertySyncer;
181 void connectionClosed();
182 void handlerDestroyed(QObject* obj);
183 void objectDestroyed(QObject* obj);
189 : address(Protocol::InvalidObjectAddress)
195 Protocol::ObjectAddress address;
202 QByteArray messageHandler;
206 void insertObjectInfo(ObjectInfo *oi);
208 void removeObjectInfo(ObjectInfo *oi);
210 QHash<QString, ObjectInfo*> m_nameMap;
211 QHash<Protocol::ObjectAddress, ObjectInfo*> m_addressMap;
212 QHash<QObject*, ObjectInfo*> m_objectMap;
213 QMultiHash<QObject*, ObjectInfo*> m_handlerMap;
215 QPointer<QIODevice> m_socket;
216 Protocol::ObjectAddress m_myAddress;
223 #endif // GAMMARAY_ENDPOINT_H
static Endpoint * s_instance
Definition: endpoint.h:168
Definition: endpoint.h:41
Network protocol endpoint.
Definition: endpoint.h:52