Mercurial > projects > qtd
annotate generator/parser/codemodel_pointer.h @ 303:98b211f3ee34 signals
fix for #19
author | eldar_ins@eldar-laptop |
---|---|
date | Sat, 12 Dec 2009 16:01:55 +0500 |
parents | 09a0f1d048f2 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
3 ** Copyright (C) 1992-2009 Nokia. All rights reserved. |
1 | 4 ** Copyright (C) 2006 Roberto Raggi <roberto@kdevelop.org> |
5 ** | |
6 ** This file is part of Qt Jambi. | |
7 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
8 ** Commercial Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
9 Licensees holding valid Qt Commercial licenses may use this file in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
10 accordance with the Qt Commercial License Agreement provided with the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
11 Software or, alternatively, in accordance with the terms contained in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
12 a written agreement between you and Nokia. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
13 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
14 GNU Lesser General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
15 Alternatively, this file may be used under the terms of the GNU Lesser |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
16 General Public License version 2.1 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
17 Foundation and appearing in the file LICENSE.LGPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
18 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
19 ensure the GNU Lesser General Public License version 2.1 requirements |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
20 will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
21 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
22 In addition, as a special exception, Nokia gives you certain |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
23 additional rights. These rights are described in the Nokia Qt LGPL |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
24 Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
25 package. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
26 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
27 GNU General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
28 Alternatively, this file may be used under the terms of the GNU |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
29 General Public License version 3.0 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
30 Foundation and appearing in the file LICENSE.GPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
31 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
32 ensure the GNU General Public License version 3.0 requirements will be |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
33 met: http://www.gnu.org/copyleft/gpl.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
34 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
35 If you are unsure which license is appropriate for your use, please |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
36 contact the sales department at qt-sales@nokia.com. |
1 | 37 |
38 ** | |
39 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
40 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
41 ** | |
42 ****************************************************************************/ | |
43 | |
44 #ifndef CODEMODEL_POINTER_H | |
45 #define CODEMODEL_POINTER_H | |
46 | |
47 #include <QtCore/QSharedData> | |
48 | |
49 // Since the atomic API changed in 4.4 we need to hack a little here | |
50 // to make it work with both 4.3 and 4.4 until that is not required | |
51 | |
52 #if QT_VERSION >= 0x040400 | |
53 | |
54 # include <QtCore/qatomic.h> | |
55 template <class T> class CodeModelPointer: public QAtomicPointer<T> | |
56 | |
57 #else | |
58 | |
59 template <class T> class CodeModelPointer | |
60 | |
61 #endif // QT_VERSION >= 0x040400 | |
62 | |
63 { | |
64 public: | |
65 typedef T Type; | |
66 | |
67 #if QT_VERSION < 0x040400 | |
68 inline T &operator*() { return *d; } | |
69 inline const T &operator*() const { return *d; } | |
70 inline T *operator->() { return d; } | |
71 inline const T *operator->() const { return d; } | |
72 inline operator T *() { return d; } | |
73 inline operator const T *() const { return d; } | |
74 inline T *data() { return d; } | |
75 inline const T *data() const { return d; } | |
76 inline const T *constData() const { return d; } | |
77 | |
78 inline bool operator==(const CodeModelPointer<T> &other) const { return d == other.d; } | |
79 inline bool operator!=(const CodeModelPointer<T> &other) const { return d != other.d; } | |
80 inline bool operator==(const T *ptr) const { return d == ptr; } | |
81 inline bool operator!=(const T *ptr) const { return d != ptr; } | |
82 | |
83 inline CodeModelPointer() { d = 0; } | |
84 inline ~CodeModelPointer() { if (d && !d->ref.deref()) delete d; } | |
85 | |
86 explicit CodeModelPointer(T *data); | |
87 inline CodeModelPointer(const CodeModelPointer<T> &o) : d(o.d) { if (d) d->ref.ref(); } | |
88 inline CodeModelPointer<T> & operator=(const CodeModelPointer<T> &o) { | |
89 if (o.d != d) { | |
90 T *x = o.d; | |
91 if (x) x->ref.ref(); | |
92 x = qAtomicSetPtr(&d, x); | |
93 if (x && !x->ref.deref()) | |
94 delete x; | |
95 } | |
96 return *this; | |
97 } | |
98 inline CodeModelPointer &operator=(T *o) { | |
99 if (o != d) { | |
100 T *x = o; | |
101 if (x) x->ref.ref(); | |
102 x = qAtomicSetPtr(&d, x); | |
103 if (x && !x->ref.deref()) | |
104 delete x; | |
105 } | |
106 return *this; | |
107 } | |
108 | |
109 inline bool operator!() const { return !d; } | |
110 | |
111 private: | |
112 T *d; | |
113 #else // QT_VERSION < 0x040400 | |
114 inline CodeModelPointer(T *value = 0) : QAtomicPointer<T>(value) {} | |
115 | |
116 inline CodeModelPointer &operator=(T *o) { | |
117 QAtomicPointer<T>::operator=(o); | |
118 return *this; | |
119 } | |
120 | |
121 inline T *data() { return (T *) *this; } | |
122 inline const T *data() const { return (const T *) *this; } | |
123 inline const T *constData() const { return (const T *) *this; } | |
124 #endif | |
125 }; | |
126 | |
127 #if QT_VERSION < 0x040400 | |
128 template <class T> | |
129 Q_INLINE_TEMPLATE CodeModelPointer<T>::CodeModelPointer(T *adata) : d(adata) | |
130 { if (d) d->ref.ref(); } | |
131 #endif | |
132 | |
133 #endif // CODEMODEL_POINTER_H |