kgamepropertyhandler.h
00001 /* 00002 This file is part of the KDE games library 00003 Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de) 00004 Copyright (C) 2001 Martin Heni (martin@heni-online.de) 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __KGAMEPROPERTYHANDLER_H_ 00022 #define __KGAMEPROPERTYHANDLER_H_ 00023 00024 #include <tqobject.h> 00025 #include <tqintdict.h> 00026 00027 #include "kgameproperty.h" 00028 #include <kdemacros.h> 00029 00030 class TQDataStream; 00031 class KGame; 00032 class KPlayer; 00033 //class KGamePropertyBase; 00034 00035 class KGamePropertyHandlerPrivate; // wow - what a name ;-) 00036 00072 class KDE_EXPORT KGamePropertyHandler : public TQObject 00073 { 00074 Q_OBJECT 00075 TQ_OBJECT 00076 00077 public: 00084 KGamePropertyHandler(TQObject* parent = 0); 00085 00091 KGamePropertyHandler(int id, const TQObject* receiver, const char* sendf, const char* emitf, TQObject* parent = 0); 00092 ~KGamePropertyHandler(); 00093 00105 void registerHandler(int id, const TQObject *receiver, const char * send, const char *emit); 00106 00122 bool processMessage(TQDataStream &stream, int id, bool isSender ); 00123 00127 int id() const; 00128 00136 bool addProperty(KGamePropertyBase *data, TQString name=0); 00137 00143 bool removeProperty(KGamePropertyBase *data); 00144 00151 int uniquePropertyId(); 00152 00153 00160 virtual bool load(TQDataStream &stream); 00161 00168 virtual bool save(TQDataStream &stream); 00169 00175 bool sendProperty(TQDataStream &s); 00176 00177 void sendLocked(bool l); 00178 00184 void emitSignal(KGamePropertyBase *data); 00185 00192 TQString propertyName(int id) const; 00193 00198 KGamePropertyBase *find(int id); 00199 00213 void clear(); 00214 00219 void setId(int id);//AB: TODO: make this protected in KGamePropertyHandler!! 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 TQIntDict<KGamePropertyBase> &dict() const; 00282 00295 TQString propertyValue(KGamePropertyBase* property); 00296 00297 00301 void Debug(); 00302 00303 00304 signals: 00315 void signalPropertyChanged(KGamePropertyBase *); 00316 00324 void signalSendMessage(int msgid, TQDataStream &, bool* sent); // AB shall we change bool* into bool& again? 00325 00345 void signalRequestValue(KGamePropertyBase* property, TQString& value); 00346 00347 private: 00348 void init(); 00349 00350 private: 00351 KGamePropertyHandlerPrivate* d; 00352 }; 00353 00354 #endif