1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the QtDeclarative module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QMETAOBJECTBUILDER_H
|
---|
43 | #define QMETAOBJECTBUILDER_H
|
---|
44 |
|
---|
45 | //
|
---|
46 | // W A R N I N G
|
---|
47 | // -------------
|
---|
48 | //
|
---|
49 | // This file is not part of the Qt API. It exists for the convenience
|
---|
50 | // of moc. This header file may change from version to version without notice,
|
---|
51 | // or even be removed.
|
---|
52 | //
|
---|
53 | // We mean it.
|
---|
54 | //
|
---|
55 |
|
---|
56 | #include <QtCore/qobject.h>
|
---|
57 | #include <QtCore/qmetaobject.h>
|
---|
58 | #include <QtCore/qdatastream.h>
|
---|
59 | #include <QtCore/qmap.h>
|
---|
60 |
|
---|
61 | #include <private/qdeclarativeglobal_p.h>
|
---|
62 |
|
---|
63 | QT_BEGIN_NAMESPACE
|
---|
64 |
|
---|
65 | class QMetaObjectBuilderPrivate;
|
---|
66 | class QMetaMethodBuilder;
|
---|
67 | class QMetaMethodBuilderPrivate;
|
---|
68 | class QMetaPropertyBuilder;
|
---|
69 | class QMetaPropertyBuilderPrivate;
|
---|
70 | class QMetaEnumBuilder;
|
---|
71 | class QMetaEnumBuilderPrivate;
|
---|
72 |
|
---|
73 | class Q_DECLARATIVE_PRIVATE_EXPORT QMetaObjectBuilder
|
---|
74 | {
|
---|
75 | public:
|
---|
76 | enum AddMember
|
---|
77 | {
|
---|
78 | ClassName = 0x00000001,
|
---|
79 | SuperClass = 0x00000002,
|
---|
80 | Methods = 0x00000004,
|
---|
81 | Signals = 0x00000008,
|
---|
82 | Slots = 0x00000010,
|
---|
83 | Constructors = 0x00000020,
|
---|
84 | Properties = 0x00000040,
|
---|
85 | Enumerators = 0x00000080,
|
---|
86 | ClassInfos = 0x00000100,
|
---|
87 | RelatedMetaObjects = 0x00000200,
|
---|
88 | StaticMetacall = 0x00000400,
|
---|
89 | PublicMethods = 0x00000800,
|
---|
90 | ProtectedMethods = 0x00001000,
|
---|
91 | PrivateMethods = 0x00002000,
|
---|
92 | AllMembers = 0x7FFFFFFF,
|
---|
93 | AllPrimaryMembers = 0x7FFFFBFC
|
---|
94 | };
|
---|
95 | Q_DECLARE_FLAGS(AddMembers, AddMember)
|
---|
96 |
|
---|
97 | enum MetaObjectFlag {
|
---|
98 | DynamicMetaObject = 0x01
|
---|
99 | };
|
---|
100 | Q_DECLARE_FLAGS(MetaObjectFlags, MetaObjectFlag)
|
---|
101 |
|
---|
102 | QMetaObjectBuilder();
|
---|
103 | explicit QMetaObjectBuilder(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
|
---|
104 | virtual ~QMetaObjectBuilder();
|
---|
105 |
|
---|
106 | QByteArray className() const;
|
---|
107 | void setClassName(const QByteArray& name);
|
---|
108 |
|
---|
109 | const QMetaObject *superClass() const;
|
---|
110 | void setSuperClass(const QMetaObject *meta);
|
---|
111 |
|
---|
112 | MetaObjectFlags flags() const;
|
---|
113 | void setFlags(MetaObjectFlags);
|
---|
114 |
|
---|
115 | int methodCount() const;
|
---|
116 | int constructorCount() const;
|
---|
117 | int propertyCount() const;
|
---|
118 | int enumeratorCount() const;
|
---|
119 | int classInfoCount() const;
|
---|
120 | int relatedMetaObjectCount() const;
|
---|
121 |
|
---|
122 | QMetaMethodBuilder addMethod(const QByteArray& signature);
|
---|
123 | QMetaMethodBuilder addMethod(const QByteArray& signature, const QByteArray& returnType);
|
---|
124 | QMetaMethodBuilder addMethod(const QMetaMethod& prototype);
|
---|
125 |
|
---|
126 | QMetaMethodBuilder addSlot(const QByteArray& signature);
|
---|
127 | QMetaMethodBuilder addSignal(const QByteArray& signature);
|
---|
128 |
|
---|
129 | QMetaMethodBuilder addConstructor(const QByteArray& signature);
|
---|
130 | QMetaMethodBuilder addConstructor(const QMetaMethod& prototype);
|
---|
131 |
|
---|
132 | QMetaPropertyBuilder addProperty(const QByteArray& name, const QByteArray& type, int notifierId=-1);
|
---|
133 | QMetaPropertyBuilder addProperty(const QMetaProperty& prototype);
|
---|
134 |
|
---|
135 | QMetaEnumBuilder addEnumerator(const QByteArray& name);
|
---|
136 | QMetaEnumBuilder addEnumerator(const QMetaEnum& prototype);
|
---|
137 |
|
---|
138 | int addClassInfo(const QByteArray& name, const QByteArray& value);
|
---|
139 |
|
---|
140 | #ifdef Q_NO_DATA_RELOCATION
|
---|
141 | int addRelatedMetaObject(const QMetaObjectAccessor &meta);
|
---|
142 | #else
|
---|
143 | int addRelatedMetaObject(const QMetaObject *meta);
|
---|
144 | #endif
|
---|
145 |
|
---|
146 | void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
|
---|
147 |
|
---|
148 | QMetaMethodBuilder method(int index) const;
|
---|
149 | QMetaMethodBuilder constructor(int index) const;
|
---|
150 | QMetaPropertyBuilder property(int index) const;
|
---|
151 | QMetaEnumBuilder enumerator(int index) const;
|
---|
152 | const QMetaObject *relatedMetaObject(int index) const;
|
---|
153 |
|
---|
154 | QByteArray classInfoName(int index) const;
|
---|
155 | QByteArray classInfoValue(int index) const;
|
---|
156 |
|
---|
157 | void removeMethod(int index);
|
---|
158 | void removeConstructor(int index);
|
---|
159 | void removeProperty(int index);
|
---|
160 | void removeEnumerator(int index);
|
---|
161 | void removeClassInfo(int index);
|
---|
162 | void removeRelatedMetaObject(int index);
|
---|
163 |
|
---|
164 | int indexOfMethod(const QByteArray& signature);
|
---|
165 | int indexOfSignal(const QByteArray& signature);
|
---|
166 | int indexOfSlot(const QByteArray& signature);
|
---|
167 | int indexOfConstructor(const QByteArray& signature);
|
---|
168 | int indexOfProperty(const QByteArray& name);
|
---|
169 | int indexOfEnumerator(const QByteArray& name);
|
---|
170 | int indexOfClassInfo(const QByteArray& name);
|
---|
171 |
|
---|
172 | typedef int (*StaticMetacallFunction)(QMetaObject::Call, int, void **);
|
---|
173 |
|
---|
174 | QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
|
---|
175 | void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
|
---|
176 |
|
---|
177 | QMetaObject *toMetaObject() const;
|
---|
178 | QByteArray toRelocatableData(bool * = 0) const;
|
---|
179 | static void fromRelocatableData(QMetaObject *, const QMetaObject *, const QByteArray &);
|
---|
180 |
|
---|
181 | #ifndef QT_NO_DATASTREAM
|
---|
182 | void serialize(QDataStream& stream) const;
|
---|
183 | void deserialize
|
---|
184 | (QDataStream& stream,
|
---|
185 | const QMap<QByteArray, const QMetaObject *>& references);
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | private:
|
---|
189 | Q_DISABLE_COPY(QMetaObjectBuilder)
|
---|
190 |
|
---|
191 | QMetaObjectBuilderPrivate *d;
|
---|
192 |
|
---|
193 | friend class QMetaMethodBuilder;
|
---|
194 | friend class QMetaPropertyBuilder;
|
---|
195 | friend class QMetaEnumBuilder;
|
---|
196 | };
|
---|
197 |
|
---|
198 | class Q_DECLARATIVE_PRIVATE_EXPORT QMetaMethodBuilder
|
---|
199 | {
|
---|
200 | public:
|
---|
201 | QMetaMethodBuilder() : _mobj(0), _index(0) {}
|
---|
202 |
|
---|
203 | int index() const;
|
---|
204 |
|
---|
205 | QMetaMethod::MethodType methodType() const;
|
---|
206 | QByteArray signature() const;
|
---|
207 |
|
---|
208 | QByteArray returnType() const;
|
---|
209 | void setReturnType(const QByteArray& value);
|
---|
210 |
|
---|
211 | QList<QByteArray> parameterNames() const;
|
---|
212 | void setParameterNames(const QList<QByteArray>& value);
|
---|
213 |
|
---|
214 | QByteArray tag() const;
|
---|
215 | void setTag(const QByteArray& value);
|
---|
216 |
|
---|
217 | QMetaMethod::Access access() const;
|
---|
218 | void setAccess(QMetaMethod::Access value);
|
---|
219 |
|
---|
220 | int attributes() const;
|
---|
221 | void setAttributes(int value);
|
---|
222 |
|
---|
223 | private:
|
---|
224 | const QMetaObjectBuilder *_mobj;
|
---|
225 | int _index;
|
---|
226 |
|
---|
227 | friend class QMetaObjectBuilder;
|
---|
228 | friend class QMetaPropertyBuilder;
|
---|
229 |
|
---|
230 | QMetaMethodBuilder(const QMetaObjectBuilder *mobj, int index)
|
---|
231 | : _mobj(mobj), _index(index) {}
|
---|
232 |
|
---|
233 | QMetaMethodBuilderPrivate *d_func() const;
|
---|
234 | };
|
---|
235 |
|
---|
236 | class Q_DECLARATIVE_PRIVATE_EXPORT QMetaPropertyBuilder
|
---|
237 | {
|
---|
238 | public:
|
---|
239 | QMetaPropertyBuilder() : _mobj(0), _index(0) {}
|
---|
240 |
|
---|
241 | int index() const { return _index; }
|
---|
242 |
|
---|
243 | QByteArray name() const;
|
---|
244 | QByteArray type() const;
|
---|
245 |
|
---|
246 | bool hasNotifySignal() const;
|
---|
247 | QMetaMethodBuilder notifySignal() const;
|
---|
248 | void setNotifySignal(const QMetaMethodBuilder& value);
|
---|
249 | void removeNotifySignal();
|
---|
250 |
|
---|
251 | bool isReadable() const;
|
---|
252 | bool isWritable() const;
|
---|
253 | bool isResettable() const;
|
---|
254 | bool isDesignable() const;
|
---|
255 | bool isScriptable() const;
|
---|
256 | bool isStored() const;
|
---|
257 | bool isEditable() const;
|
---|
258 | bool isUser() const;
|
---|
259 | bool hasStdCppSet() const;
|
---|
260 | bool isEnumOrFlag() const;
|
---|
261 | bool isDynamic() const;
|
---|
262 |
|
---|
263 | void setReadable(bool value);
|
---|
264 | void setWritable(bool value);
|
---|
265 | void setResettable(bool value);
|
---|
266 | void setDesignable(bool value);
|
---|
267 | void setScriptable(bool value);
|
---|
268 | void setStored(bool value);
|
---|
269 | void setEditable(bool value);
|
---|
270 | void setUser(bool value);
|
---|
271 | void setStdCppSet(bool value);
|
---|
272 | void setEnumOrFlag(bool value);
|
---|
273 | void setDynamic(bool value);
|
---|
274 |
|
---|
275 | private:
|
---|
276 | const QMetaObjectBuilder *_mobj;
|
---|
277 | int _index;
|
---|
278 |
|
---|
279 | friend class QMetaObjectBuilder;
|
---|
280 |
|
---|
281 | QMetaPropertyBuilder(const QMetaObjectBuilder *mobj, int index)
|
---|
282 | : _mobj(mobj), _index(index) {}
|
---|
283 |
|
---|
284 | QMetaPropertyBuilderPrivate *d_func() const;
|
---|
285 | };
|
---|
286 |
|
---|
287 | class Q_DECLARATIVE_PRIVATE_EXPORT QMetaEnumBuilder
|
---|
288 | {
|
---|
289 | public:
|
---|
290 | QMetaEnumBuilder() : _mobj(0), _index(0) {}
|
---|
291 |
|
---|
292 | int index() const { return _index; }
|
---|
293 |
|
---|
294 | QByteArray name() const;
|
---|
295 |
|
---|
296 | bool isFlag() const;
|
---|
297 | void setIsFlag(bool value);
|
---|
298 |
|
---|
299 | int keyCount() const;
|
---|
300 | QByteArray key(int index) const;
|
---|
301 | int value(int index) const;
|
---|
302 |
|
---|
303 | int addKey(const QByteArray& name, int value);
|
---|
304 | void removeKey(int index);
|
---|
305 |
|
---|
306 | private:
|
---|
307 | const QMetaObjectBuilder *_mobj;
|
---|
308 | int _index;
|
---|
309 |
|
---|
310 | friend class QMetaObjectBuilder;
|
---|
311 |
|
---|
312 | QMetaEnumBuilder(const QMetaObjectBuilder *mobj, int index)
|
---|
313 | : _mobj(mobj), _index(index) {}
|
---|
314 |
|
---|
315 | QMetaEnumBuilderPrivate *d_func() const;
|
---|
316 | };
|
---|
317 |
|
---|
318 | Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers)
|
---|
319 | Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::MetaObjectFlags)
|
---|
320 |
|
---|
321 | QT_END_NAMESPACE
|
---|
322 |
|
---|
323 | #endif
|
---|