Mercurial > projects > qtd
annotate include/QObjectEntity.h @ 354:18bd68f586c6
removed superfluous destructors
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Mon, 24 May 2010 23:43:30 +0300 |
parents | 34a37904ff77 |
children |
rev | line source |
---|---|
1 | 1 #ifndef QQOBJECTENTITY_H |
2 #define QQOBJECTENTITY_H | |
3 | |
254 | 4 #include "qtd_core.h" |
5 #include <qobject.h> | |
6 #include <iostream> | |
7 | |
8 QTD_EXPORT(void, qtd_delete_d_qobject, (void* dPtr)) | |
1 | 9 |
254 | 10 //TODO: user data ID must be registered with QObject::registerUserData; |
11 #define userDataId 0 | |
12 | |
13 class QtD_QObjectEntity : public QtD_Entity, public QObjectUserData | |
1 | 14 { |
15 public: | |
254 | 16 |
17 QtD_QObjectEntity(QObject *qObject, void *dId) : QtD_Entity(dId) | |
18 { | |
19 qObject->setUserData(userDataId, this); | |
20 } | |
1 | 21 |
254 | 22 virtual ~QtD_QObjectEntity() |
23 { | |
24 if (dId) | |
25 destroyEntity(); | |
26 } | |
27 | |
28 inline void destroyEntity(QObject *qObject = NULL) | |
29 { | |
30 Q_ASSERT(dId); | |
354
18bd68f586c6
removed superfluous destructors
Max Samukha <maxter@spambox.com>
parents:
254
diff
changeset
|
31 qtd_QtdObject_delete(dId); |
254 | 32 if (qObject) |
33 { | |
34 qObject->setUserData(userDataId, NULL); | |
35 dId = NULL; | |
36 } | |
37 } | |
38 | |
39 inline static QtD_QObjectEntity* getQObjectEntity(const QObject *qObject) | |
40 { | |
41 return static_cast<QtD_QObjectEntity*>(qObject->userData(userDataId)); | |
42 } | |
1 | 43 }; |
44 | |
45 #endif // QQOBJECTENTITY_H |