00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GZ_DIST_ATTRIBUTE_H__
00022 #define __GZ_DIST_ATTRIBUTE_H__
00023
00024
00025 #include "gzDistBase.h"
00026
00027
00028 class gzDistClientInterface;
00029
00030
00031
00032 GZ_DIST_DECLARE_MEMBASE_EXPORT(gzDistAttribute, GZ_DIST_EXPORT);
00033
00035
00040 class gzDistAttribute GZ_DIST_MEMBASE_SINGLE(gzDistAttribute)
00041 {
00042 public:
00043
00044 GZ_DIST_MEMBASE_IMP(gzDistAttribute);
00045
00046 GZ_DIST_MEMBASE_CALL(gzDistAttribute);
00047
00049 GZ_DIST_EXPORT gzDistAttribute(const gzString& name);
00050
00052 GZ_DIST_EXPORT gzDistAttribute(const gzString& name, const gzDynamicType& value);
00053
00055 GZ_DIST_EXPORT gzDistAttribute(const gzDistAttribute& attribute);
00056
00058 GZ_DIST_EXPORT virtual ~gzDistAttribute();
00059
00061 GZ_DIST_EXPORT const gzString& getName() const;
00062
00064 GZ_DIST_EXPORT const gzDynamicType& getValue() const;
00065
00067 GZ_DIST_EXPORT gzBool store(gzSerializeAdapter* adapter);
00068
00070 GZ_DIST_EXPORT gzBool restore(gzSerializeAdapter* adapter);
00071
00072
00073
00074
00075 gzULong getDataSize() const;
00076
00077 gzDistAttribute(){}
00078
00079
00080 gzDynamicType value;
00081
00082
00083 gzSerializeString name;
00084 };
00085
00086
00087
00088
00089 class gzDistObjectAttribute : public gzDistThreadSafeReference
00090 {
00091 friend class gzDistObject;
00092 friend class gzDistSession;
00093
00094 public:
00095
00096
00097 GZ_DIST_EXPORT gzDistObjectAttribute(const gzString& name, gzDistObject* parent);
00098
00099
00100 GZ_DIST_EXPORT gzDistObjectAttribute(const gzString& name, const gzDynamicType& value, gzDistObject* parent);
00101
00102
00103 GZ_DIST_EXPORT gzDistObjectAttribute(const gzDistObjectAttribute& attribute);
00104
00105
00106 GZ_DIST_EXPORT virtual ~gzDistObjectAttribute();
00107
00108
00109 GZ_DIST_EXPORT virtual gzReference* clone() const;
00110
00111
00112 const gzString& getName() const;
00113
00114
00115 const gzDistAttribute& attribute() const;
00116
00117 private:
00118
00119
00120 gzDynamicType getValue() const;
00121
00122
00123 gzVoid getValue(gzDynamicType& value) const;
00124
00125
00126 const gzString& getDynamicType() const;
00127
00128
00129 gzDouble getNumber() const;
00130
00131
00132 gzGUID getGuid() const;
00133
00134
00135 gzVoid getGuid(gzGUID& guid) const;
00136
00137
00138 gzVoid getString(gzString& string) const;
00139
00140
00141 gzVoid getReference(gzRefPointer<gzReference>& reference) const;
00142
00143
00144 gzVoid* getPointer() const;
00145
00146
00147 gzBool store(gzSerializeAdapter* adapter);
00148
00149
00150 gzBool restore(gzSerializeAdapter* adapter);
00151
00152
00153 gzDistObjectAttribute(gzDistObject* parent);
00154
00155
00156 gzDistObject* getObject();
00157
00158
00159 gzBool isSubscriber(gzDistClientInterface* client) const;
00160
00161
00162 gzVoid setValue(const gzDynamicType& value);
00163
00164
00165 gzBool subscribe(gzDistClientInterface* client);
00166
00167
00168 gzBool unsubscribe(gzDistClientInterface* client);
00169
00170
00171 gzVoid removeSubscribers();
00172
00173
00174
00175 gzBool resign(gzDistClientInterface* client);
00176
00177
00178
00179 gzVoid setOwner(const gzDistClientID& owner);
00180
00181
00182 const gzDistClientID& getOwner();
00183
00184
00185 gzVoid setNextOwner();
00186
00187
00188 gzBool isOwner(const gzDistClientID& clientId) const;
00189
00190
00191 gzBool isOwnershipRequester(const gzDistClientID& clientId) const;
00192
00193
00194
00195
00196 const gzDistClientID& requestOwnership(const gzDistClientID& clientId);
00197
00198
00199 gzDistClientID* getNextOwnerRequester();
00200
00201
00202 gzBool removeOwnershipRequest(const gzDistClientID& clientId);
00203
00204
00205
00206 gzBool isAllowedToUpdate(const gzDistClientID& clientId);
00207
00208
00209 gzVoid release();
00210
00211
00212
00213 gzVoid clearOwnershipRequests(gzBool destroy = TRUE);
00214
00215
00216 gzVoid cleanUpInstance(const gzDistInstanceID& instance);
00217
00218
00219
00220
00221 gzList<gzDistClientInterface> m_subscribers;
00222
00223
00224 struct gzDistOwnerData
00225 {
00226 gzDistClientID m_owner;
00227 gzList<gzDistClientID> m_ownerRequests;
00228
00229 }* m_ownerData;
00230
00231
00232 gzDistObject* m_parent;
00233
00234
00235 gzDistAttribute m_attribute;
00236 };
00237
00238
00239
00240
00241 GZ_DIST_DECLARE_MEMBASE_EXPORT(gzDistEventAttribute, GZ_DIST_EXPORT);
00242
00243
00244 class gzDistEventAttribute GZ_DIST_MEMBASE_SINGLE(gzDistEventAttribute)
00245 {
00246 friend class gzDistEvent;
00247
00248 public:
00249
00250 GZ_DIST_MEMBASE_IMP(gzDistEventAttribute);
00251
00252 GZ_DIST_MEMBASE_CALL(gzDistEventAttribute);
00253
00254
00255 GZ_DIST_EXPORT gzDistEventAttribute(const gzString& name, const gzDynamicType& value);
00256
00257
00258 GZ_DIST_EXPORT gzDistEventAttribute(const gzDistAttribute& data);
00259
00260
00261 GZ_DIST_EXPORT gzDistEventAttribute(gzDistObjectAttribute* objectAttribute);
00262
00263
00264 GZ_DIST_EXPORT gzDistEventAttribute(const gzString& name, gzDistEventAttribute* objectAttribute);
00265
00266
00267 GZ_DIST_EXPORT gzDistEventAttribute(const gzDistEventAttribute& attribute);
00268
00269
00270 GZ_DIST_EXPORT virtual ~gzDistEventAttribute();
00271
00272
00273 const gzDistAttribute& attribute() const;
00274
00275 private:
00276
00277 gzDistEventAttribute();
00278
00279
00280 const gzString& getName() const;
00281
00282
00283 gzDouble getNumber() const;
00284
00285
00286 gzVoid getString(gzString& string) const;
00287
00288
00289 gzGUID getGuid() const;
00290
00291
00292 gzVoid getGuid(gzGUID& guid) const;
00293
00294
00295 gzString getString() const;
00296
00297
00298 const gzString& getDynamicType() const;
00299
00300
00301 gzBool store(gzSerializeAdapter* adapter);
00302
00303
00304 gzBool restore(gzSerializeAdapter* adapter);
00305
00306 gzVoid setValue(const gzDynamicType& value);
00307
00308
00309
00310 gzDistAttribute m_attribute;
00311 };
00312
00313
00314 #endif