Mercurial > projects > qtd
comparison include/qtd_core.h @ 355:08c1ca7975ab
obviated redundant virtual dispatch callbacks
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Tue, 25 May 2010 17:23:11 +0300 |
parents | 18bd68f586c6 |
children | 9784459f0750 |
comparison
equal
deleted
inserted
replaced
354:18bd68f586c6 | 355:08c1ca7975ab |
---|---|
1 /** | 1 /** |
2 * | 2 * Copyright: Copyright QtD Team, 2008-2010 |
3 * Copyright: Copyright QtD Team, 2008-2009 | 3 * License: Boost Software License 1.0 |
4 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a> | 4 */ |
5 * | |
6 * Copyright QtD Team, 2008-2009 | |
7 * Distributed under the Boost Software License, Version 1.0. | |
8 * (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 * | |
10 */ | |
11 | 5 |
12 #ifndef QTD_CORE_H | 6 #ifndef QTD_CORE_H |
13 #define QTD_CORE_H | 7 #define QTD_CORE_H |
14 | 8 |
15 #include <QAbstractItemModel> | 9 #include <QAbstractItemModel> |
32 #else | 26 #else |
33 #define QTD_EXPORT(TYPE, NAME, ARGS) \ | 27 #define QTD_EXPORT(TYPE, NAME, ARGS) \ |
34 extern "C" TYPE NAME ARGS; | 28 extern "C" TYPE NAME ARGS; |
35 #endif | 29 #endif |
36 | 30 |
31 extern uint userDataId; | |
32 | |
37 struct QModelIndexAccessor { | 33 struct QModelIndexAccessor { |
38 int row; | 34 int row; |
39 int col; | 35 int col; |
40 void *ptr; | 36 void *ptr; |
41 QAbstractItemModel *model; | 37 QAbstractItemModel *model; |
52 qNativeOwnership = 0x01, | 48 qNativeOwnership = 0x01, |
53 qDOwnership = 0x02 | 49 qDOwnership = 0x02 |
54 //gcManaged = 0x04 | 50 //gcManaged = 0x04 |
55 }; | 51 }; |
56 | 52 |
57 class QtD_Entity | 53 class DLL_PUBLIC QtdObjectLink |
58 { | 54 { |
59 public: | 55 public: |
60 void* dId; | 56 void* dId; // TODO: needs to be atomic |
61 | 57 |
62 QtD_Entity(void* id) : dId(id) | 58 QtdObjectLink(void* id) : dId(id) {} |
59 | |
60 template<typename T> | |
61 static QtdObjectLink* getLink(const T* object) | |
63 { | 62 { |
63 return dynamic_cast<QtdObjectLink*>((T*)object); | |
64 } | 64 } |
65 | |
66 template<typename T> | |
67 static void* getDId(const T* object) | |
68 { | |
69 QtdObjectLink *link = getLink((T*)object); | |
70 return link ? link->dId : NULL; | |
71 } | |
72 }; | |
73 | |
74 class DLL_PUBLIC QObjectLink : public QtdObjectLink, public QObjectUserData | |
75 { | |
76 public: | |
77 enum Flags | |
78 { | |
79 None, | |
80 CreatedByD = 0x1 | |
81 }; | |
82 | |
83 Flags flags; | |
84 | |
85 QObjectLink(QObject* qObject, void* dId); | |
86 bool createdByD(); | |
87 virtual ~QObjectLink(); | |
88 void destroyLink(QObject* qObject = NULL); | |
89 static QObjectLink* getLink(const QObject* qObject); | |
90 static void* getDId(const QObject* qObject); | |
65 }; | 91 }; |
66 | 92 |
67 #define Array DArray | 93 #define Array DArray |
68 | 94 |
69 #ifdef CPP_SHARED | 95 #ifdef CPP_SHARED |