00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GZ_DIST_DEBUG_H__
00022 #define __GZ_DIST_DEBUG_H__
00023
00024
00025 #include "gzDistBase.h"
00026 #include "gzDistClient.h"
00027
00028
00029 const gzULong GZ_DIST_DEBUG_BUFFER_SIZE = 0x4000;
00030 const gzULong GZ_DIST_DEBUG_MESSAGE_HEADER_SIZE = 5;
00031 const gzString GZ_DIST_DEBUG_PIPE_NAME = "gz_dist_dbg";
00032 const gzString GZ_DIST_DEBUG_CLIENT_NAME = gzUniqueString("DebugClient", 75);
00033
00034 enum gzDistDebugMessageType
00035 {
00036 GZ_DIST_DEBUG_MESSAGE_TYPE_ID,
00037 GZ_DIST_DEBUG_MESSAGE_TYPE_START,
00038 GZ_DIST_DEBUG_MESSAGE_TYPE_STOP,
00039 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_CLIENT,
00040 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_CLIENT,
00041 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_SESSION,
00042 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_SESSION,
00043 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_SESSION_CLIENT,
00044 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_SESSION_CLIENT,
00045 GZ_DIST_DEBUG_MESSAGE_TYPE_EVENT,
00046 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_OBJECT,
00047 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_OBJECT,
00048 GZ_DIST_DEBUG_MESSAGE_TYPE_OWNERSHIP,
00049 GZ_DIST_DEBUG_MESSAGE_TYPE_UPDATE_ATTRIBUTES,
00050 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_ATTRIBUTES,
00051 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_SESSION_SUBSCRIBER,
00052 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_SESSION_SUBSCRIBER,
00053 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_EVENT_TYPE_SUBSCRIBER,
00054 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_EVENT_TYPE_SUBSCRIBER,
00055 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_OBJECT_TYPE_SUBSCRIBER,
00056 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_OBJECT_TYPE_SUBSCRIBER,
00057 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_ATTRIBUTE_SUBSCRIBER,
00058 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_ATTRIBUTE_SUBSCRIBER,
00059 GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_ATTRIBUTE_VALUE_SUBSCRIBER,
00060 GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_ATTRIBUTE_VALUE_SUBSCRIBER,
00061 GZ_DIST_DEBUG_MESSAGE_TYPE_UNIQUE_STRINGS
00062 };
00063
00064
00065
00066 class gzDistDebugManagerClient : public gzReference
00067 {
00068 public:
00069 gzDistDebugManagerClient(const gzDistClientID& id, gzInt poolId) : clientId(id), poolId(poolId) {}
00070 virtual ~gzDistDebugManagerClient() {}
00071
00072 gzDistClientID clientId;
00073 gzInt poolId;
00074 };
00075
00076
00077
00078
00079 class gzDistDebugOwnerData : public gzReference
00080 {
00081 public:
00082 gzDistDebugOwnerData();
00083 virtual ~gzDistDebugOwnerData();
00084
00085 gzString sessionName;
00086 gzString objectName;
00087 gzString attributeName;
00088 gzRefList<gzRefData<gzDistClientID> > ownerData;
00089 };
00090
00091
00092
00093
00094 class gzDistDebugClient : public gzDistClientInterface
00095 {
00096 public:
00097 gzDistDebugClient();
00098 virtual ~gzDistDebugClient();
00099
00100 gzVoid run();
00101
00102 protected:
00103
00104 gzVoid onClientTick();
00105
00106
00107
00108 gzVoid onEvent(gzDistEvent* event);
00109 gzVoid onNewObject(gzDistObject* object, gzDistSession* session);
00110 gzVoid onRemoveObject(gzDistObject* object, gzDistSession* session);
00111 gzVoid onUpdateAttributes(const gzDistNotificationSet& attributes, gzDistObject* object, gzDistSession* session);
00112 gzVoid onNewAttributes(const gzDistNotificationSet& attributes, gzDistObject* object, gzDistSession* session);
00113 gzVoid onRemoveAttributes(const gzDistNotificationSet& attributes, gzDistObject* object, gzDistSession* session);
00114 gzVoid onNewSession(gzDistSession* session);
00115 gzVoid onRemoveSession(gzDistSession* session);
00116 gzVoid onSystemShutdown();
00117 gzVoid onDebugMessage(gzDistDebugNotification* notification);
00118
00119 private:
00120
00121 gzVoid processDebugMessages();
00122
00123 gzVoid sendData(gzUByte messageType);
00124
00125 gzVoid initAdapter();
00126
00127 gzVoid writeClientId(const gzDistClientID* id);
00128
00129 gzVoid sendIdentification();
00130
00131 gzVoid sendManagerClients();
00132
00133 gzVoid sendUniqueStrings();
00134
00135
00136
00137 gzPipe m_pipe;
00138 gzBool m_active;
00139 gzBool m_run;
00140 gzSerializeAdapterMemory m_adapter;
00141 gzUByte* m_memory;
00142
00143 gzSerializeString m_string;
00144 gzSerializeBinary<gzBool> m_bool;
00145 gzSerializeBinary<gzUByte> m_byte;
00146 gzSerializeBinary<gzUShort> m_ushort;
00147 gzSerializeBinary<gzULong> m_ulong;
00148 gzSerializeBinary<gzULong> m_pid;
00149
00150 gzRefList<gzDistDebugManagerClient> m_managerClients;
00151 };
00152
00153
00154
00155 class gzDistDebugNotification : public gzDistNotification
00156 {
00157 public:
00158
00159 gzDistDebugNotification();
00160
00161
00162 virtual ~gzDistDebugNotification();
00163
00164
00165 gzVoid setDebugMessageType(gzDistDebugMessageType debugMessageType);
00166
00167
00168 gzDistDebugMessageType getDebugMessageType();
00169
00170
00171 gzVoid setDebugClassType(gzType* classType);
00172
00173
00174 gzType* getDebugClassType();
00175
00176
00177 gzVoid setDebugSessionName(const gzString& name);
00178
00179
00180 gzVoid setDebugObjectName(const gzString& name);
00181
00182
00183 gzVoid setDebugAttributeName(const gzString& name);
00184
00185
00186 gzVoid setDebugPoolId(gzULong poolId);
00187
00188
00189 const gzString& getDebugObjectName() const;
00190
00191
00192 const gzString& getDebugSessionName() const;
00193
00194
00195 const gzString& getDebugAttributeName() const;
00196
00197
00198 gzVoid setDebugClients(gzRefList<gzRefData<gzDistClientID> >* clients);
00199
00200
00201 gzRefList<gzRefData<gzDistClientID> >* getDebugClients();
00202
00203
00204 gzULong getDebugPoolId();
00205
00206 private:
00207
00208
00209 gzDistDebugMessageType m_debugMessageType;
00210
00211 gzString m_stringData1;
00212
00213 gzString m_stringData2;
00214
00215 gzString m_stringData3;
00216
00217 gzType* m_classType;
00218
00219 gzRefList<gzRefData<gzDistClientID> >* m_clientIds;
00220
00221 gzULong m_poolId;
00222 };
00223
00224 #endif