GizmoDistribution

gzDistNotification.h

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File         : gzDistNotification.h
00003 // Module       : gzDistribution
00004 // Description  : Declaration of gzDistNotification and gzDistNotificationData
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  040121  Created file
00019 //
00020 //*****************************************************************************
00021 #ifndef __GZ_DIST_NOTIFICATION_H__
00022 #define __GZ_DIST_NOTIFICATION_H__
00023 
00028 // Includes
00029 #include "gzDistBase.h"
00030 
00031 
00032 //--------------------------- gzDistNotificationData --------------------------
00033 
00034 GZ_DIST_DECLARE_MEMBASE_EXPORT(gzDistNotificationData, GZ_DIST_EXPORT);
00035 
00037 
00040 class gzDistNotificationData : public gzDistThreadSafeReference GZ_DIST_MEMBASE(gzDistNotificationData)
00041 {
00042     friend class gzDistSession;
00043 
00044     public:
00045 
00046         GZ_DIST_MEMBASE_IMP(gzDistNotificationData);
00047 
00048         GZ_DIST_MEMBASE_CALL(gzDistNotificationData);
00049 
00051         GZ_DIST_EXPORT gzDistNotificationData(const gzString& name, const gzDynamicType& data);
00052     
00054         GZ_DIST_EXPORT gzDistNotificationData(const class gzDistAttribute* attribute);
00055     
00057         GZ_DIST_EXPORT virtual ~gzDistNotificationData();
00058         
00059         
00061         GZ_DIST_EXPORT const gzString& getAttributeName() const;
00062 
00064         GZ_DIST_EXPORT const gzDynamicType& getAttributeValue() const;
00065 
00067         GZ_DIST_EXPORT const gzString& getAttributeType() const;
00068 
00070         GZ_DIST_EXPORT gzDouble getAttributeNumber() const;
00071 
00073         GZ_DIST_EXPORT gzString getAttributeString() const;
00074 
00076         GZ_DIST_EXPORT gzGUID getAttributeGuid() const;
00077 
00078     private:
00079 
00080         // The name of the attribute
00081         const gzString m_attributeName;
00082 
00083         // The attribute data.
00084         const gzDynamicType m_attributeValue;
00085 };
00086 
00087 //--------------------------- gzDistNotificationSet ------------------------------
00088 
00090 
00093 class gzDistNotificationSet
00094 {
00095     friend class gzDistNotificationSetIterator;
00096     friend class gzDistSession;
00097     friend class gzDistClientInterface;
00098 
00099     public:
00100         GZ_DIST_EXPORT gzDistNotificationSet();
00101 
00102         GZ_DIST_EXPORT ~gzDistNotificationSet();
00103 
00105         GZ_DIST_EXPORT gzULong entries() const;
00106 
00110         GZ_DIST_EXPORT gzDistNotificationData* find(const gzString& attributeName) const;
00111 
00116         GZ_DIST_EXPORT gzBool getAttributeNumber(const gzString& attributeName, gzDouble& number) const;
00117 
00122         GZ_DIST_EXPORT gzBool getAttributeString(const gzString& attributeName, gzString& string) const;
00123 
00128         GZ_DIST_EXPORT gzBool getAttributeValue(const gzString& attributeName, gzDynamicType& value) const;
00129     
00130     private:
00131 
00132         gzVoid insert(gzDistNotificationData* data);
00133         gzDistNotificationData* first() const;
00134 
00135         gzRefList<gzDistNotificationData> m_data;
00136 };
00137 
00138 //--------------------------- gzDistNotificationSetIterator ------------------------------
00140 class gzDistNotificationSetIterator
00141 {
00142     public:
00144 
00145         GZ_DIST_EXPORT gzDistNotificationSetIterator(const gzDistNotificationSet& list);
00146 
00148         GZ_DIST_EXPORT ~gzDistNotificationSetIterator();
00149 
00151 
00153         GZ_DIST_EXPORT gzDistNotificationData* operator()();
00154 
00156         /*  \return A pointer to the gzDistNotificationData at current iterator position*/
00157         GZ_DIST_EXPORT gzDistNotificationData* current() const;
00158     
00159     private:
00160 
00161         gzListConstIterator<gzDistNotificationData> m_iterator;
00162 };
00163 
00164 //--------------------------- gzDistNotification ------------------------------
00165 
00166 // Notification types
00167 enum gzDistNotificationType
00168 {
00169     GZ_DIST_NOTIFICATION_TYPE_UNDEFINED = 0,
00170     GZ_DIST_NOTIFICATION_TYPE_EVENT,
00171     GZ_DIST_NOTIFICATION_TYPE_NEW_OBJECT,
00172     GZ_DIST_NOTIFICATION_TYPE_REMOVE_OBJECT,
00173     GZ_DIST_NOTIFICATION_TYPE_UPDATE_OBJECT,
00174     GZ_DIST_NOTIFICATION_TYPE_NEW_ATTRIBUTES,
00175     GZ_DIST_NOTIFICATION_TYPE_REMOVE_ATTRIBUTES,
00176     GZ_DIST_NOTIFICATION_TYPE_REQUEST_OWNERSHIP,
00177     GZ_DIST_NOTIFICATION_TYPE_GRANT_OWNERSHIP,
00178     GZ_DIST_NOTIFICATION_TYPE_DROP_OWNERSHIP,
00179     GZ_DIST_NOTIFICATION_TYPE_NEW_SESSION,
00180     GZ_DIST_NOTIFICATION_TYPE_REMOVE_SESSION,
00181     GZ_DIST_NOTIFICATION_TYPE_UNINITIALIZE_CLIENT,
00182     GZ_DIST_NOTIFICATION_TYPE_DEBUG,                // Used for debugging only (gzDistMonitor).
00183     GZ_DIST_NOTIFICATION_TYPE_INVOKE
00184 };
00185 
00186 GZ_DIST_DECLARE_MEMBASE(gzDistNotification);
00187 
00188 // This is the internal class all clients are notified with from the kernel.
00189 class gzDistNotification : public gzDistThreadSafeReference GZ_DIST_MEMBASE(gzDistNotification)
00190 {
00191     public:
00192         GZ_DIST_MEMBASE_IMP(gzDistNotification);
00193 
00194         GZ_DIST_MEMBASE_CALL(gzDistNotification);
00195 
00196         // Default constructor.
00197         gzDistNotification();
00198 
00199         // Constructor.
00200         gzDistNotification(gzDistNotificationType type, gzDistThreadSafeReference* reference);
00201 
00202         // Destructor.
00203         virtual ~gzDistNotification();
00204 
00205         // Set ID in notification.
00206         gzVoid setClientID(const gzDistClientID& clientId);
00207 
00208         // Get ID from notificaion.
00209         gzDistClientID* getClientID() const;
00210 
00211         // Set object to notification.
00212         gzVoid setObject(gzDistObject* object);
00213 
00214         // Get object from notification.
00215         gzDistObject* getObject() const;
00216 
00217         // Set session to notification.
00218         gzVoid setSession(gzDistSession* session);
00219 
00220         // Get session from notification.
00221         gzDistSession* getSession() const;
00222 
00223         // Set event to notification.
00224         gzVoid setEvent(gzDistEvent* event);
00225 
00226         // Get event from notification.
00227         gzDistEvent* getEvent() const;
00228 
00229         // Set notification type.
00230         gzVoid setNotificationType(gzDistNotificationType type);
00231 
00232         // Get notification type.
00233         gzDistNotificationType getNotificationType() const;
00234 
00235         // The attributes and its data the notification concern. This is used only in a transaction.
00236         gzDistNotificationSet* m_notification_data;
00237 
00238         // Give the notification high priority.
00239         gzVoid setHighPrio();
00240 
00241         // return TRUE if the notification has high priority, otherwise FALSE.
00242         gzBool isHighPrio();
00243 
00244         // Get invoke data
00245         gzDistThreadSafeReference* getInvokeData() const;
00246 
00247     private:
00248 
00249         // The type of notification
00250         gzDistNotificationType m_type;
00251 
00252         // A reference to an object or event.
00253         gzRefPointer<gzDistThreadSafeReference> m_reference;
00254 
00255         // Additional reference to a session etc.
00256         gzRefPointer<gzDistThreadSafeReference> m_addReference;
00257 
00258         // The ID of the source.
00259         gzDistClientID* m_clientID;
00260 
00261         // High priority notification.
00262         gzBool m_highPrio;
00263 };
00264 
00265 #endif

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