libkdegames Library API Documentation

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., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, 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 
00029 class QDataStream;
00030 class KGame;
00031 class KPlayer;
00032 //class KGamePropertyBase;
00033 
00034 class KGamePropertyHandlerPrivate; // wow - what a name ;-)
00035 
00071 class KGamePropertyHandler : public QObject
00072 {
00073     Q_OBJECT
00074 
00075 public:
00082     KGamePropertyHandler(QObject* parent = 0);
00083 
00089     KGamePropertyHandler(int id, const QObject* receiver, const char* sendf, const char* emitf, QObject* parent = 0);
00090     ~KGamePropertyHandler();
00091 
00103     void registerHandler(int id, const QObject *receiver, const char * send, const char *emit); 
00104 
00120     bool processMessage(QDataStream &stream, int id, bool isSender );
00121     
00125     int id() const;
00126     
00134     bool addProperty(KGamePropertyBase *data, QString name=0);
00135 
00141     bool removeProperty(KGamePropertyBase *data);
00142 
00149     int uniquePropertyId();
00150 
00151 
00158     virtual bool load(QDataStream &stream);
00159 
00166     virtual bool save(QDataStream &stream);
00167     
00173     bool sendProperty(QDataStream &s);
00174 
00175     void sendLocked(bool l);
00176 
00182     void emitSignal(KGamePropertyBase *data);
00183 
00190     QString propertyName(int id) const;
00191 
00196     KGamePropertyBase *find(int id);
00197 
00211     void clear();
00212 
00217     void setId(int id);//AB: TODO: make this protected in KGamePropertyHandler!!
00218 
00223     void unlockProperties();
00224 
00233     void setPolicy(KGamePropertyBase::PropertyPolicy p, bool userspace=true);
00234 
00245     void lockDirectEmit();
00246 
00251     void unlockDirectEmit();
00252   
00257     KGamePropertyBase::PropertyPolicy policy();
00258 
00268     void lockProperties();
00269 
00274     void flush();
00275 
00279     QIntDict<KGamePropertyBase> &dict() const;
00280 
00293     QString propertyValue(KGamePropertyBase* property);
00294 
00295 
00299     void Debug();
00300 
00301 
00302 signals:
00313     void signalPropertyChanged(KGamePropertyBase *);
00314 
00322     void signalSendMessage(int msgid, QDataStream &, bool* sent); // AB shall we change bool* into bool& again?
00323 
00343     void signalRequestValue(KGamePropertyBase* property, QString& value);
00344 
00345 private:
00346     void init();
00347 
00348 private:
00349     KGamePropertyHandlerPrivate* d;
00350 };
00351 
00352 #endif
KDE Logo
This file is part of the documentation for libkdegames Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 12 22:53:43 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003