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 #ifdef CPP_SHARED
|
|
11 #define qtd_delete_d_qobject qtd_get_qtd_delete_d_qobject()
|
|
12 #endif
|
|
13
|
|
14 //TODO: user data ID must be registered with QObject::registerUserData;
|
|
15 #define userDataId 0
|
|
16
|
|
17 class QtD_QObjectEntity : public QtD_Entity, public QObjectUserData
|
1
|
18 {
|
|
19 public:
|
254
|
20
|
|
21 QtD_QObjectEntity(QObject *qObject, void *dId) : QtD_Entity(dId)
|
|
22 {
|
|
23 qObject->setUserData(userDataId, this);
|
|
24 }
|
1
|
25
|
254
|
26 virtual ~QtD_QObjectEntity()
|
|
27 {
|
|
28 if (dId)
|
|
29 destroyEntity();
|
|
30 }
|
|
31
|
|
32 inline void destroyEntity(QObject *qObject = NULL)
|
|
33 {
|
|
34 Q_ASSERT(dId);
|
|
35 qtd_delete_d_qobject(dId);
|
|
36 if (qObject)
|
|
37 {
|
|
38 qObject->setUserData(userDataId, NULL);
|
|
39 dId = NULL;
|
|
40 }
|
|
41 }
|
|
42
|
|
43 inline static QtD_QObjectEntity* getQObjectEntity(const QObject *qObject)
|
|
44 {
|
|
45 return static_cast<QtD_QObjectEntity*>(qObject->userData(userDataId));
|
|
46 }
|
1
|
47 };
|
|
48
|
|
49 #endif // QQOBJECTENTITY_H
|