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 <qobject.h>
00025 #include <qintdict.h>
00026 
00027 #include "kgameproperty.h"
00028 #include <kdemacros.h>
00029 
00030 class QDataStream;
00031 class KGame;
00032 class KPlayer;
00033 //class KGamePropertyBase;
00034 
00035 class KGamePropertyHandlerPrivate; // wow - what a name ;-)
00036 
00072 class KDE_EXPORT KGamePropertyHandler : public QObject
00073 {
00074     Q_OBJECT
00075 
00076 public:
00083     KGamePropertyHandler(QObject* parent = 0);
00084 
00090     KGamePropertyHandler(int id, const QObject* receiver, const char* sendf, const char* emitf, QObject* parent = 0);
00091     ~KGamePropertyHandler();
00092 
00104     void registerHandler(int id, const QObject *receiver, const char * send, const char *emit); 
00105 
00121     bool processMessage(QDataStream &stream, int id, bool isSender );
00122     
00126     int id() const;
00127     
00135     bool addProperty(KGamePropertyBase *data, QString name=0);
00136 
00142     bool removeProperty(KGamePropertyBase *data);
00143 
00150     int uniquePropertyId();
00151 
00152 
00159     virtual bool load(QDataStream &stream);
00160 
00167     virtual bool save(QDataStream &stream);
00168     
00174     bool sendProperty(QDataStream &s);
00175 
00176     void sendLocked(bool l);
00177 
00183     void emitSignal(KGamePropertyBase *data);
00184 
00191     QString propertyName(int id) const;
00192 
00197     KGamePropertyBase *find(int id);
00198 
00212     void clear();
00213 
00218     void setId(int id);//AB: TODO: make this protected in KGamePropertyHandler!!
00219 
00224     void unlockProperties();
00225 
00234     void setPolicy(KGamePropertyBase::PropertyPolicy p, bool userspace=true);
00235 
00246     void lockDirectEmit();
00247 
00252     void unlockDirectEmit();
00253   
00258     KGamePropertyBase::PropertyPolicy policy();
00259 
00269     void lockProperties();
00270 
00275     void flush();
00276 
00280     QIntDict<KGamePropertyBase> &dict() const;
00281 
00294     QString propertyValue(KGamePropertyBase* property);
00295 
00296 
00300     void Debug();
00301 
00302 
00303 signals:
00314     void signalPropertyChanged(KGamePropertyBase *);
00315 
00323     void signalSendMessage(int msgid, QDataStream &, bool* sent); // AB shall we change bool* into bool& again?
00324 
00344     void signalRequestValue(KGamePropertyBase* property, QString& value);
00345 
00346 private:
00347     void init();
00348 
00349 private:
00350     KGamePropertyHandlerPrivate* d;
00351 };
00352 
00353 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys