GizmoDistribution

gzDistDebug.h

00001 //*****************************************************************************
00002 // File         : gzDistDebug.h
00003 // Module       : gzDistribution
00004 // Description  : Definition of gzDistDebugClient
00005 // Author       : Christian Andersson
00006 // Product      : GizmoDistribution 2.1.1
00007 //      
00008 // Copyright © 2004 - Saab Training Systems AB, Sweden
00009 //          
00010 // NOTE:    GizmoDistribution is a toolkit used for implementing distributed 
00011 //          objects and events in C++
00012 //
00013 //
00014 // Revision History...
00015 //
00016 // Who  Date    Description
00017 //
00018 // CAN  040610  Created file
00019 //
00020 //*****************************************************************************
00021 #ifndef __GZ_DIST_DEBUG_H__
00022 #define __GZ_DIST_DEBUG_H__
00023 
00024 // Includes
00025 #include "gzDistBase.h"
00026 #include "gzDistClient.h"
00027 
00028 // Constants
00029 const gzULong GZ_DIST_DEBUG_BUFFER_SIZE = 0x4000; // 16 KB
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,                          // Initialized clients.
00040     GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_CLIENT,                      // Clients that do uninitialize.
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,                  // Joined clients.
00044     GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_SESSION_CLIENT,              // Clients that do resign session.
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,                           // 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,              // Clients that subscribes new/removed sessions.
00052     GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_SESSION_SUBSCRIBER,          // Clients that unsubscribes new/removed sessions.
00053     GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_EVENT_TYPE_SUBSCRIBER,           // Class type subscription.
00054     GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_EVENT_TYPE_SUBSCRIBER,       // Class type subscription.
00055     GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_OBJECT_TYPE_SUBSCRIBER,          // Class type subscription.
00056     GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_OBJECT_TYPE_SUBSCRIBER,      // Class type subscription.
00057     GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_ATTRIBUTE_SUBSCRIBER,            // Subscription on new/removed attributes in objects.
00058     GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_ATTRIBUTE_SUBSCRIBER,        // Subscription on new/removed attributes in objects.
00059     GZ_DIST_DEBUG_MESSAGE_TYPE_NEW_ATTRIBUTE_VALUE_SUBSCRIBER,      // Subscription on attribute value.
00060     GZ_DIST_DEBUG_MESSAGE_TYPE_REMOVED_ATTRIBUTE_VALUE_SUBSCRIBER,  // Subscription on attribute value.
00061     GZ_DIST_DEBUG_MESSAGE_TYPE_UNIQUE_STRINGS                       // Unique gzStrings with Ids.
00062 };
00063 
00064 //-------------------------- gzDistDebugManagerClient ---------------------------
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 //-------------------------- gzDistDebugOwnerData ---------------------------
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 //-------------------------- gzDistDebugClient ---------------------------
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         //----- notification callbacks -----
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     // Members:
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 //-------------------------- gzDistDebugNotification ---------------------------
00154 
00155 class gzDistDebugNotification : public gzDistNotification
00156 {
00157     public:
00158         // Constructor
00159         gzDistDebugNotification();
00160 
00161         // Destructor
00162         virtual ~gzDistDebugNotification();
00163 
00164         // Set m_debugMessageType
00165         gzVoid setDebugMessageType(gzDistDebugMessageType debugMessageType);
00166 
00167         // Get m_debugMessageType
00168         gzDistDebugMessageType getDebugMessageType();
00169 
00170         // Set class type.
00171         gzVoid setDebugClassType(gzType* classType);
00172 
00173         // Get class type.
00174         gzType* getDebugClassType();
00175 
00176         // Set m_stringData1.
00177         gzVoid setDebugSessionName(const gzString& name);
00178 
00179         // Set m_stringData2.
00180         gzVoid setDebugObjectName(const gzString& name);
00181 
00182         // Set m_stringData3.
00183         gzVoid setDebugAttributeName(const gzString& name);
00184 
00185         // Set threaad pool id.
00186         gzVoid setDebugPoolId(gzULong poolId);
00187 
00188         // Get m_stringData1.
00189         const gzString& getDebugObjectName() const;
00190 
00191         // Get m_stringData2.
00192         const gzString& getDebugSessionName() const;
00193 
00194         // Get m_stringData3.
00195         const gzString& getDebugAttributeName() const;
00196 
00197         // Set additional clients i.e. ownership data.
00198         gzVoid setDebugClients(gzRefList<gzRefData<gzDistClientID> >* clients);
00199 
00200         // Get ownership data.
00201         gzRefList<gzRefData<gzDistClientID> >* getDebugClients();
00202 
00203         // Get threaad pool id.
00204         gzULong getDebugPoolId();
00205 
00206     private:
00207 
00208         // Debug message type.
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

Documentation for GizmoDistribution generated at Wed Feb 20 11:59:21 2008 by   Saab Training Systems AB, ¸ (c) 2003-and beyond