KDEGames

kgamepropertyhandler.h
1 /*
2  This file is part of the KDE games library
3  Copyright (C) 2001 Andreas Beckermann ([email protected])
4  Copyright (C) 2001 Martin Heni (kde at heni-online.de)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef __KGAMEPROPERTYHANDLER_H_
22 #define __KGAMEPROPERTYHANDLER_H_
23 
24 #include <QObject>
25 #include <QMultiHash>
26 
27 #include "kgameproperty.h"
28 #include "libkdegamesprivate_export.h"
29 
30 class QDataStream;
31 class KGame;
32 //class KGamePropertyBase;
33 
34 class KGamePropertyHandlerPrivate; // wow - what a name ;-)
35 
73 class KDEGAMESPRIVATE_EXPORT KGamePropertyHandler : public QObject
74 {
75  Q_OBJECT
76 
77 public:
84  explicit KGamePropertyHandler(QObject* parent = nullptr);
85 
91  KGamePropertyHandler(int id, const QObject* receiver, const char* sendf, const char* emitf, QObject* parent = nullptr);
93 
105  void registerHandler(int id, const QObject *receiver, const char * send, const char *emit);
106 
122  bool processMessage(QDataStream &stream, int id, bool isSender );
123 
127  int id() const;
128 
136  bool addProperty(KGamePropertyBase *data, const QString& name=QString());
137 
143  bool removeProperty(KGamePropertyBase *data);
144 
151  int uniquePropertyId();
152 
153 
160  virtual bool load(QDataStream &stream);
161 
168  virtual bool save(QDataStream &stream);
169 
175  bool sendProperty(QDataStream &s);
176 
177  void sendLocked(bool l);
178 
184  void emitSignal(KGamePropertyBase *data);
185 
192  QString propertyName(int id) const;
193 
198  KGamePropertyBase *find(int id);
199 
213  void clear();
214 
219  void setId(int id);//AB: TODO: make this protected in KGamePropertyHandler!!
220 
225  void unlockProperties();
226 
235  void setPolicy(KGamePropertyBase::PropertyPolicy p, bool userspace=true);
236 
247  void lockDirectEmit();
248 
253  void unlockDirectEmit();
254 
260 
270  void lockProperties();
271 
276  void flush();
277 
282 
294  QString propertyValue(KGamePropertyBase* property);
295 
296 
300  void Debug();
301 
302 
303 Q_SIGNALS:
314  void signalPropertyChanged(KGamePropertyBase *);
315 
323  void signalSendMessage(int msgid, QDataStream &, bool* sent); // AB shall we change bool* into bool& again?
324 
344  void signalRequestValue(KGamePropertyBase* property, QString& value);
345 
346 private:
347  friend class KGamePropertyHandlerPrivate;
348  KGamePropertyHandlerPrivate *const d;
349 
351 };
352 
353 #endif
A collection class for KGameProperty objects.
PropertyPolicy
The policy of the property.
Base class of KGameProperty.
Definition: kgameproperty.h:45
Q_DISABLE_COPY(Class)
The main KDE game object.
Definition: kgame.h:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Nov 26 2020 22:36:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.