
00001 //***************************************************************************** 00002 // File : gzDistEvent.h 00003 // Module : gzDistribution 00004 // Description : Definition of a gzDistEvent 00005 // Author : Christian Andersson, Anders Sandblad 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 031021 Created file 00019 // 00020 //****************************************************************************** 00021 #ifndef __GZ_DIST_EVENT_H__ 00022 #define __GZ_DIST_EVENT_H__ 00023 00028 // Includes 00029 #include "gzDistBase.h" 00030 #include "gzDistAttribute.h" 00031 00032 //****************************************************************************** 00033 // Class : gzDistEvent 00034 // 00035 // Purpose : The base definition class of a distribution event. 00036 // 00037 // Notes : - 00038 // 00039 // Revision History... 00040 // 00041 // Who Date Description 00042 // 00043 // CAN 031021 Created 00044 // 00045 //****************************************************************************** 00046 00047 GZ_DIST_DECLARE_MEMBASE_EXPORT(gzDistEvent, GZ_DIST_EXPORT); 00048 00050 00066 class gzDistEvent : public gzDistThreadSafeReference 00067 { 00068 friend class gzDistSession; 00069 friend class gzDistEventAttributeIterator; 00070 00071 public: 00072 00073 GZ_DECLARE_TYPE_INTERFACE_EXPORT(GZ_DIST_EXPORT); 00074 00076 GZ_DIST_EXPORT gzDistEvent(); 00077 00079 /* \param event The event that will be copied.*/ 00080 GZ_DIST_EXPORT gzDistEvent(const gzDistEvent& event); 00081 00083 GZ_DIST_EXPORT virtual ~gzDistEvent(); 00084 00086 00088 GZ_DIST_EXPORT gzDouble getAttributeNumber(const gzString& attributeName) const; 00089 00091 00096 GZ_DIST_EXPORT gzBool getAttributeNumber(const gzString& attributeName, gzDouble& number) const; 00097 00099 00101 GZ_DIST_EXPORT gzString getAttributeString(const gzString& attributeName) const; 00102 00104 00109 GZ_DIST_EXPORT gzBool getAttributeString(const gzString& attributeName, gzString& string) const; 00110 00112 00115 GZ_DIST_EXPORT gzGUID getAttributeGuid(const gzString& attributeName) const; 00116 00118 00123 GZ_DIST_EXPORT gzBool getAttributeGuid(const gzString& attributeName, gzGUID& guid) const; 00124 00126 00128 GZ_DIST_EXPORT const gzDynamicType& getAttributeValue(const gzString& attributeName) const; 00129 00131 00134 GZ_DIST_EXPORT gzBool getAttributeValue(const gzString& attributeName, gzDynamicType& value) const; 00135 00137 00141 GZ_DIST_EXPORT gzVoid setAttributeValue(const gzString& attributeName, const gzDynamicType& value); 00142 00144 00146 GZ_DIST_EXPORT gzBool hasAttribute(const gzString& attributeName) const; 00147 00149 00153 GZ_DIST_EXPORT gzBool removeAttribute(const gzString& attributeName); 00154 00156 00159 GZ_DIST_EXPORT gzDistSession* getSession() const; 00160 00162 00164 GZ_DIST_EXPORT virtual gzReference* clone() const; 00165 00167 00170 GZ_DIST_EXPORT gzBool store(gzSerializeAdapter* adapter); 00171 00173 00178 GZ_DIST_EXPORT gzBool restore(gzSerializeAdapter* adapter); 00179 00181 00185 GZ_DIST_EXPORT gzVoid setHighPriority(); 00186 00188 00190 GZ_DIST_EXPORT gzBool isHighPriority() const; 00191 00193 00194 GZ_DIST_EXPORT gzVoid clear(); 00195 00197 00201 GZ_DIST_EXPORT gzVoid setDestination(const gzDistInstanceID& destination); 00202 00204 00206 GZ_DIST_EXPORT const gzDistInstanceID& getDestination() const; 00207 00209 00211 GZ_DIST_EXPORT gzUInt getDataSize() const; 00212 00213 private: 00214 00215 gzVoid setSession(gzDistSession* session); 00216 00217 gzVoid setAttribute(gzDistEventAttribute* attribute); 00218 00219 // Members: 00220 00221 // For directed events 00222 gzDistInstanceID m_destination; 00223 00224 mutable gzDict<gzString, gzDistEventAttribute> m_attributes; 00225 00226 gzDistSession* m_session; 00227 00228 gzBool m_highPrio; 00229 }; 00230 00231 00232 //-------------------------- gzDistEventAttributeIterator -------------------- 00233 00234 //***************************************************************************** 00235 // Class : gzDistEventAttributeIterator 00236 // 00237 // Purpose : Iterator for event attributes 00238 // 00239 // Notes : - 00240 // 00241 // Revision History... 00242 // 00243 // Who Date Description 00244 // 00245 // CAN 031021 Created 00246 // 00247 //***************************************************************************** 00249 class gzDistEventAttributeIterator 00250 { 00251 public: 00252 00254 00256 GZ_DIST_EXPORT gzDistEventAttributeIterator(const gzDistEventPtr& object); 00257 00259 GZ_DIST_EXPORT ~gzDistEventAttributeIterator(); 00260 00262 00264 GZ_DIST_EXPORT gzBool operator()(); 00265 00267 GZ_DIST_EXPORT const gzDistAttribute& current() const; 00268 00270 GZ_DIST_EXPORT const gzDistAttribute* operator->() const; 00271 00273 GZ_DIST_EXPORT gzVoid reset(); 00274 00275 private: 00276 00277 const gzDistEventPtr m_event; 00278 gzDictIterator<gzString, gzDistEventAttribute> m_iterator; 00279 gzDictEntry<gzString, gzDistEventAttribute>* m_entry; 00280 }; 00281 00282 #endif