Logo Search packages:      
Sourcecode: kdegames version File versions

KGamePropertyHandler Class Reference

#include <kgamepropertyhandler.h>

List of all members.

Detailed Description

A collection class for KGameProperty objects.

The KGamePropertyHandler class is some kind of a collection class for KGameProperty. You usually don't have to create one yourself, as both KPlayer and KGame provide a handler. In most cases you do not even have to care about the KGamePropertHandler. KGame and KPlayer implement all features of KGamePropertyHandler so you will rather use it there.

You have to use the KGamePropertyHandler as parent for all KGameProperty objects but you can also use KPlayer or KGame as parent - then KPlayer::dataHandler or KGame::dataHandler will be used.

Every KGamePropertyHandler must have - just like every KGameProperty - a unique ID. This ID is provided either in the constructor or in registerHandler. The ID is used to assign an incoming message (e.g. a changed property) to the correct handler. Inside the handler the property ID is used to change the correct property.

The constructor or registerHandler takes 3 addittional arguments: a receiver and two slots. The first slot is connected to signalSendMessage, the second to signalPropertyChanged. You must provide these in order to use the KGamePropertyHandler.

The most important function of KGamePropertyHandler is processMessage which assigns an incoming value to the correct property.

A KGamePropertyHandler is also used - indirectly using emitSignal - to emit a signal when the value of a property changes. This is done this way because a KGameProperty does not inherit QObject because of memory advantages. Many games can have dozens or even hundreds of KGameProperty objects so every additional variable in KGameProperty would be multiplied.

Definition at line 71 of file kgamepropertyhandler.h.


void signalPropertyChanged (KGamePropertyBase *)
void signalRequestValue (KGamePropertyBase *property, QString &value)
void signalSendMessage (int msgid, QDataStream &, bool *sent)

Public Member Functions

bool addProperty (KGamePropertyBase *data, QString name=0)
void clear ()
void Debug ()
QIntDict< KGamePropertyBase > & dict () const
void emitSignal (KGamePropertyBase *data)
KGamePropertyBasefind (int id)
void flush ()
int id () const
 KGamePropertyHandler (int id, const QObject *receiver, const char *sendf, const char *emitf, QObject *parent=0)
 KGamePropertyHandler (QObject *parent=0)
virtual bool load (QDataStream &stream)
void lockDirectEmit ()
void lockProperties ()
KGamePropertyBase::PropertyPolicy policy ()
bool processMessage (QDataStream &stream, int id, bool isSender)
QString propertyName (int id) const
QString propertyValue (KGamePropertyBase *property)
void registerHandler (int id, const QObject *receiver, const char *send, const char *emit)
bool removeProperty (KGamePropertyBase *data)
virtual bool save (QDataStream &stream)
void sendLocked (bool l)
bool sendProperty (QDataStream &s)
void setId (int id)
void setPolicy (KGamePropertyBase::PropertyPolicy p, bool userspace=true)
int uniquePropertyId ()
void unlockDirectEmit ()
void unlockProperties ()

Private Member Functions

void init ()

Private Attributes

KGamePropertyHandlerPrivate * d

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index