libkdegames/kgame
kgamepropertyhandler.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __KGAMEPROPERTYHANDLER_H_
00022 #define __KGAMEPROPERTYHANDLER_H_
00023
00024 #include <QtCore/QObject>
00025 #include <QtCore/QMultiHash>
00026
00027 #include "kgameproperty.h"
00028 #include <libkdegames_export.h>
00029
00030 class QDataStream;
00031 class KGame;
00032
00033
00034 class KGamePropertyHandlerPrivate;
00035
00073 class KDEGAMES_EXPORT KGamePropertyHandler : public QObject
00074 {
00075 Q_OBJECT
00076
00077 public:
00084 KGamePropertyHandler(QObject* parent = 0);
00085
00091 KGamePropertyHandler(int id, const QObject* receiver, const char* sendf, const char* emitf, QObject* parent = 0);
00092 ~KGamePropertyHandler();
00093
00105 void registerHandler(int id, const QObject *receiver, const char * send, const char *emit);
00106
00122 bool processMessage(QDataStream &stream, int id, bool isSender );
00123
00127 int id() const;
00128
00136 bool addProperty(KGamePropertyBase *data, const QString& name=QString());
00137
00143 bool removeProperty(KGamePropertyBase *data);
00144
00151 int uniquePropertyId();
00152
00153
00160 virtual bool load(QDataStream &stream);
00161
00168 virtual bool save(QDataStream &stream);
00169
00175 bool sendProperty(QDataStream &s);
00176
00177 void sendLocked(bool l);
00178
00184 void emitSignal(KGamePropertyBase *data);
00185
00192 QString propertyName(int id) const;
00193
00198 KGamePropertyBase *find(int id);
00199
00213 void clear();
00214
00219 void setId(int id);
00220
00225 void unlockProperties();
00226
00235 void setPolicy(KGamePropertyBase::PropertyPolicy p, bool userspace=true);
00236
00247 void lockDirectEmit();
00248
00253 void unlockDirectEmit();
00254
00259 KGamePropertyBase::PropertyPolicy policy();
00260
00270 void lockProperties();
00271
00276 void flush();
00277
00281 QMultiHash<int, KGamePropertyBase*> &dict() const;
00282
00295 QString propertyValue(KGamePropertyBase* property);
00296
00297
00301 void Debug();
00302
00303
00304 Q_SIGNALS:
00315 void signalPropertyChanged(KGamePropertyBase *);
00316
00324 void signalSendMessage(int msgid, QDataStream &, bool* sent);
00325
00345 void signalRequestValue(KGamePropertyBase* property, QString& value);
00346
00347 private:
00348 friend class KGamePropertyHandlerPrivate;
00349 KGamePropertyHandlerPrivate *const d;
00350
00351 Q_DISABLE_COPY(KGamePropertyHandler)
00352 };
00353
00354 #endif