1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QMETAOBJECTBUILDER_H
43 #define QMETAOBJECTBUILDER_H
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.
56 #include <QtCore/qobject.h>
57 #include <QtCore/qmetaobject.h>
58 #include <QtCore/qdatastream.h>
59 #include <QtCore/qmap.h>
61 #include <private/qdeclarativeglobal_p.h>
65 class QMetaObjectBuilderPrivate;
66 class QMetaMethodBuilder;
67 class QMetaMethodBuilderPrivate;
68 class QMetaPropertyBuilder;
69 class QMetaPropertyBuilderPrivate;
70 class QMetaEnumBuilder;
71 class QMetaEnumBuilderPrivate;
73 class Q_DECLARATIVE_PRIVATE_EXPORT QMetaObjectBuilder
78 ClassName = 0x00000001,
79 SuperClass = 0x00000002,
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
95 Q_DECLARE_FLAGS(AddMembers, AddMember)
98 DynamicMetaObject = 0x01
100 Q_DECLARE_FLAGS(MetaObjectFlags, MetaObjectFlag)
102 QMetaObjectBuilder();
103 explicit QMetaObjectBuilder(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
104 virtual ~QMetaObjectBuilder();
106 QByteArray className() const;
107 void setClassName(const QByteArray& name);
109 const QMetaObject *superClass() const;
110 void setSuperClass(const QMetaObject *meta);
112 MetaObjectFlags flags() const;
113 void setFlags(MetaObjectFlags);
115 int methodCount() const;
116 int constructorCount() const;
117 int propertyCount() const;
118 int enumeratorCount() const;
119 int classInfoCount() const;
120 int relatedMetaObjectCount() const;
122 QMetaMethodBuilder addMethod(const QByteArray& signature);
123 QMetaMethodBuilder addMethod(const QByteArray& signature, const QByteArray& returnType);
124 QMetaMethodBuilder addMethod(const QMetaMethod& prototype);
126 QMetaMethodBuilder addSlot(const QByteArray& signature);
127 QMetaMethodBuilder addSignal(const QByteArray& signature);
129 QMetaMethodBuilder addConstructor(const QByteArray& signature);
130 QMetaMethodBuilder addConstructor(const QMetaMethod& prototype);
132 QMetaPropertyBuilder addProperty(const QByteArray& name, const QByteArray& type, int notifierId=-1);
133 QMetaPropertyBuilder addProperty(const QMetaProperty& prototype);
135 QMetaEnumBuilder addEnumerator(const QByteArray& name);
136 QMetaEnumBuilder addEnumerator(const QMetaEnum& prototype);
138 int addClassInfo(const QByteArray& name, const QByteArray& value);
140 #ifdef Q_NO_DATA_RELOCATION
141 int addRelatedMetaObject(const QMetaObjectAccessor &meta);
143 int addRelatedMetaObject(const QMetaObject *meta);
146 void addMetaObject(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members = AllMembers);
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;
154 QByteArray classInfoName(int index) const;
155 QByteArray classInfoValue(int index) const;
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);
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);
172 typedef QMetaObjectExtraData::StaticMetacallFunction StaticMetacallFunction;
174 QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction() const;
175 void setStaticMetacallFunction(QMetaObjectBuilder::StaticMetacallFunction value);
177 QMetaObject *toMetaObject() const;
178 QByteArray toRelocatableData(bool * = 0) const;
179 static void fromRelocatableData(QMetaObject *, const QMetaObject *, const QByteArray &);
181 #ifndef QT_NO_DATASTREAM
182 void serialize(QDataStream& stream) const;
184 (QDataStream& stream,
185 const QMap<QByteArray, const QMetaObject *>& references);
189 Q_DISABLE_COPY(QMetaObjectBuilder)
191 QMetaObjectBuilderPrivate *d;
193 friend class QMetaMethodBuilder;
194 friend class QMetaPropertyBuilder;
195 friend class QMetaEnumBuilder;
198 class Q_DECLARATIVE_PRIVATE_EXPORT QMetaMethodBuilder
201 QMetaMethodBuilder() : _mobj(0), _index(0) {}
205 QMetaMethod::MethodType methodType() const;
206 QByteArray signature() const;
208 QByteArray returnType() const;
209 void setReturnType(const QByteArray& value);
211 QList<QByteArray> parameterNames() const;
212 void setParameterNames(const QList<QByteArray>& value);
214 QByteArray tag() const;
215 void setTag(const QByteArray& value);
217 QMetaMethod::Access access() const;
218 void setAccess(QMetaMethod::Access value);
220 int attributes() const;
221 void setAttributes(int value);
224 const QMetaObjectBuilder *_mobj;
227 friend class QMetaObjectBuilder;
228 friend class QMetaPropertyBuilder;
230 QMetaMethodBuilder(const QMetaObjectBuilder *mobj, int index)
231 : _mobj(mobj), _index(index) {}
233 QMetaMethodBuilderPrivate *d_func() const;
236 class Q_DECLARATIVE_PRIVATE_EXPORT QMetaPropertyBuilder
239 QMetaPropertyBuilder() : _mobj(0), _index(0) {}
241 int index() const { return _index; }
243 QByteArray name() const;
244 QByteArray type() const;
246 bool hasNotifySignal() const;
247 QMetaMethodBuilder notifySignal() const;
248 void setNotifySignal(const QMetaMethodBuilder& value);
249 void removeNotifySignal();
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;
259 bool hasStdCppSet() const;
260 bool isEnumOrFlag() const;
261 bool isConstant() const;
262 bool isFinal() const;
264 void setReadable(bool value);
265 void setWritable(bool value);
266 void setResettable(bool value);
267 void setDesignable(bool value);
268 void setScriptable(bool value);
269 void setStored(bool value);
270 void setEditable(bool value);
271 void setUser(bool value);
272 void setStdCppSet(bool value);
273 void setEnumOrFlag(bool value);
274 void setConstant(bool value);
275 void setFinal(bool value);
278 const QMetaObjectBuilder *_mobj;
281 friend class QMetaObjectBuilder;
283 QMetaPropertyBuilder(const QMetaObjectBuilder *mobj, int index)
284 : _mobj(mobj), _index(index) {}
286 QMetaPropertyBuilderPrivate *d_func() const;
289 class Q_DECLARATIVE_PRIVATE_EXPORT QMetaEnumBuilder
292 QMetaEnumBuilder() : _mobj(0), _index(0) {}
294 int index() const { return _index; }
296 QByteArray name() const;
299 void setIsFlag(bool value);
301 int keyCount() const;
302 QByteArray key(int index) const;
303 int value(int index) const;
305 int addKey(const QByteArray& name, int value);
306 void removeKey(int index);
309 const QMetaObjectBuilder *_mobj;
312 friend class QMetaObjectBuilder;
314 QMetaEnumBuilder(const QMetaObjectBuilder *mobj, int index)
315 : _mobj(mobj), _index(index) {}
317 QMetaEnumBuilderPrivate *d_func() const;
320 Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers)
321 Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::MetaObjectFlags)