1 | /****************************************************************************
|
---|
2 | ** $Id: qmetaobject.h 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of QMetaObject class
|
---|
5 | **
|
---|
6 | ** Created : 930419
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #ifndef QMETAOBJECT_H
|
---|
39 | #define QMETAOBJECT_H
|
---|
40 |
|
---|
41 | #ifndef QT_H
|
---|
42 | #include "qconnection.h"
|
---|
43 | #include "qstrlist.h"
|
---|
44 | #endif // QT_H
|
---|
45 |
|
---|
46 | #ifndef Q_MOC_OUTPUT_REVISION
|
---|
47 | #define Q_MOC_OUTPUT_REVISION 26
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | class QObject;
|
---|
51 | struct QUMethod;
|
---|
52 | class QMetaObjectPrivate;
|
---|
53 |
|
---|
54 | struct QMetaData // - member function meta data
|
---|
55 | { // for signal and slots
|
---|
56 | const char *name; // - member name
|
---|
57 | const QUMethod* method; // - detailed method description
|
---|
58 | enum Access { Private, Protected, Public };
|
---|
59 | Access access; // - access permission
|
---|
60 | };
|
---|
61 |
|
---|
62 | #ifndef QT_NO_PROPERTIES
|
---|
63 | struct QMetaEnum // enumerator meta data
|
---|
64 | { // for properties
|
---|
65 | const char *name; // - enumerator name
|
---|
66 | uint count; // - number of values
|
---|
67 | struct Item // - a name/value pair
|
---|
68 | {
|
---|
69 | const char *key;
|
---|
70 | int value;
|
---|
71 | };
|
---|
72 | const Item *items; // - the name/value pairs
|
---|
73 | bool set; // whether enum has to be treated as a set
|
---|
74 | };
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | #ifndef QT_NO_PROPERTIES
|
---|
78 |
|
---|
79 | class Q_EXPORT QMetaProperty // property meta data
|
---|
80 | {
|
---|
81 | public:
|
---|
82 | const char* type() const { return t; } // type of the property
|
---|
83 | const char* name() const { return n; } // name of the property
|
---|
84 |
|
---|
85 | bool writable() const;
|
---|
86 | bool isValid() const;
|
---|
87 |
|
---|
88 | bool isSetType() const;
|
---|
89 | bool isEnumType() const;
|
---|
90 | QStrList enumKeys() const; // enumeration names
|
---|
91 |
|
---|
92 | int keyToValue( const char* key ) const; // enum and set conversion functions
|
---|
93 | const char* valueToKey( int value ) const;
|
---|
94 | int keysToValue( const QStrList& keys ) const;
|
---|
95 | QStrList valueToKeys( int value ) const;
|
---|
96 |
|
---|
97 | bool designable( QObject* = 0 ) const;
|
---|
98 | bool scriptable( QObject* = 0 ) const;
|
---|
99 | bool stored( QObject* = 0 ) const;
|
---|
100 |
|
---|
101 | bool reset( QObject* ) const;
|
---|
102 |
|
---|
103 | const char* t; // internal
|
---|
104 | const char* n; // internal
|
---|
105 |
|
---|
106 | enum Flags {
|
---|
107 | Invalid = 0x00000000,
|
---|
108 | Readable = 0x00000001,
|
---|
109 | Writable = 0x00000002,
|
---|
110 | EnumOrSet = 0x00000004,
|
---|
111 | UnresolvedEnum = 0x00000008,
|
---|
112 | StdSet = 0x00000100,
|
---|
113 | Override = 0x00000200
|
---|
114 | };
|
---|
115 |
|
---|
116 | uint flags; // internal
|
---|
117 | bool testFlags( uint f ) const; // internal
|
---|
118 | bool stdSet() const; // internal
|
---|
119 | int id() const; // internal
|
---|
120 |
|
---|
121 | QMetaObject** meta; // internal
|
---|
122 |
|
---|
123 | const QMetaEnum* enumData; // internal
|
---|
124 | int _id; // internal
|
---|
125 | void clear(); // internal
|
---|
126 | };
|
---|
127 |
|
---|
128 | inline bool QMetaProperty::testFlags( uint f ) const
|
---|
129 | { return (flags & (uint)f) != (uint)0; }
|
---|
130 |
|
---|
131 | #endif // QT_NO_PROPERTIES
|
---|
132 |
|
---|
133 | struct QClassInfo // class info meta data
|
---|
134 | {
|
---|
135 | const char* name; // - name of the info
|
---|
136 | const char* value; // - value of the info
|
---|
137 | };
|
---|
138 |
|
---|
139 | class Q_EXPORT QMetaObject // meta object class
|
---|
140 | {
|
---|
141 | public:
|
---|
142 | QMetaObject( const char * const class_name, QMetaObject *superclass,
|
---|
143 | const QMetaData * const slot_data, int n_slots,
|
---|
144 | const QMetaData * const signal_data, int n_signals,
|
---|
145 | #ifndef QT_NO_PROPERTIES
|
---|
146 | const QMetaProperty *const prop_data, int n_props,
|
---|
147 | const QMetaEnum *const enum_data, int n_enums,
|
---|
148 | #endif
|
---|
149 | const QClassInfo *const class_info, int n_info );
|
---|
150 |
|
---|
151 | #ifndef QT_NO_PROPERTIES
|
---|
152 | QMetaObject( const char * const class_name, QMetaObject *superclass,
|
---|
153 | const QMetaData * const slot_data, int n_slots,
|
---|
154 | const QMetaData * const signal_data, int n_signals,
|
---|
155 | const QMetaProperty *const prop_data, int n_props,
|
---|
156 | const QMetaEnum *const enum_data, int n_enums,
|
---|
157 | bool (*qt_static_property)(QObject*, int, int, QVariant*),
|
---|
158 | const QClassInfo *const class_info, int n_info );
|
---|
159 | #endif
|
---|
160 |
|
---|
161 |
|
---|
162 | virtual ~QMetaObject();
|
---|
163 |
|
---|
164 | const char *className() const { return classname; }
|
---|
165 | const char *superClassName() const { return superclassname; }
|
---|
166 |
|
---|
167 | QMetaObject *superClass() const { return superclass; }
|
---|
168 |
|
---|
169 | bool inherits( const char* clname ) const;
|
---|
170 |
|
---|
171 | int numSlots( bool super = FALSE ) const;
|
---|
172 | int numSignals( bool super = FALSE ) const;
|
---|
173 |
|
---|
174 | int findSlot( const char *, bool super = FALSE ) const;
|
---|
175 | int findSignal( const char *, bool super = FALSE ) const;
|
---|
176 |
|
---|
177 | const QMetaData *slot( int index, bool super = FALSE ) const;
|
---|
178 | const QMetaData *signal( int index, bool super = FALSE ) const;
|
---|
179 |
|
---|
180 | QStrList slotNames( bool super = FALSE ) const;
|
---|
181 | QStrList signalNames( bool super = FALSE ) const;
|
---|
182 |
|
---|
183 | int slotOffset() const;
|
---|
184 | int signalOffset() const;
|
---|
185 | int propertyOffset() const;
|
---|
186 |
|
---|
187 | int numClassInfo( bool super = FALSE ) const;
|
---|
188 | const QClassInfo *classInfo( int index, bool super = FALSE ) const;
|
---|
189 | const char *classInfo( const char* name, bool super = FALSE ) const;
|
---|
190 |
|
---|
191 | #ifndef QT_NO_PROPERTIES
|
---|
192 | const QMetaProperty *property( int index, bool super = FALSE ) const;
|
---|
193 | int findProperty( const char *name, bool super = FALSE ) const;
|
---|
194 | int indexOfProperty( const QMetaProperty*, bool super = FALSE ) const;
|
---|
195 | const QMetaProperty* resolveProperty( const QMetaProperty* ) const;
|
---|
196 | int resolveProperty( int ) const;
|
---|
197 | QStrList propertyNames( bool super = FALSE ) const;
|
---|
198 | int numProperties( bool super = FALSE ) const;
|
---|
199 | #endif
|
---|
200 |
|
---|
201 | // static wrappers around constructors, necessary to work around a
|
---|
202 | // Windows-DLL limitation: objects can only be deleted within a
|
---|
203 | // DLL if they were actually created within that DLL.
|
---|
204 | static QMetaObject *new_metaobject( const char *, QMetaObject *,
|
---|
205 | const QMetaData *const, int,
|
---|
206 | const QMetaData *const, int,
|
---|
207 | #ifndef QT_NO_PROPERTIES
|
---|
208 | const QMetaProperty *const prop_data, int n_props,
|
---|
209 | const QMetaEnum *const enum_data, int n_enums,
|
---|
210 | #endif
|
---|
211 | const QClassInfo *const class_info, int n_info );
|
---|
212 | #ifndef QT_NO_PROPERTIES
|
---|
213 | static QMetaObject *new_metaobject( const char *, QMetaObject *,
|
---|
214 | const QMetaData *const, int,
|
---|
215 | const QMetaData *const, int,
|
---|
216 | const QMetaProperty *const prop_data, int n_props,
|
---|
217 | const QMetaEnum *const enum_data, int n_enums,
|
---|
218 | bool (*qt_static_property)(QObject*, int, int, QVariant*),
|
---|
219 | const QClassInfo *const class_info, int n_info );
|
---|
220 | QStrList enumeratorNames( bool super = FALSE ) const;
|
---|
221 | int numEnumerators( bool super = FALSE ) const;
|
---|
222 | const QMetaEnum *enumerator( const char* name, bool super = FALSE ) const;
|
---|
223 | #endif
|
---|
224 |
|
---|
225 | static QMetaObject *metaObject( const char *class_name );
|
---|
226 | static bool hasMetaObject( const char *class_name );
|
---|
227 |
|
---|
228 | private:
|
---|
229 | QMemberDict *init( const QMetaData *, int );
|
---|
230 |
|
---|
231 | const char *classname; // class name
|
---|
232 | const char *superclassname; // super class name
|
---|
233 | QMetaObject *superclass; // super class meta object
|
---|
234 | QMetaObjectPrivate *d; // private data for...
|
---|
235 | void *reserved; // ...binary compatibility
|
---|
236 | const QMetaData *slotData; // slot meta data
|
---|
237 | QMemberDict *slotDict; // slot dictionary
|
---|
238 | const QMetaData *signalData; // signal meta data
|
---|
239 | QMemberDict *signalDict; // signal dictionary
|
---|
240 | int signaloffset;
|
---|
241 | int slotoffset;
|
---|
242 | #ifndef QT_NO_PROPERTIES
|
---|
243 | int propertyoffset;
|
---|
244 | public:
|
---|
245 | bool qt_static_property( QObject* o, int id, int f, QVariant* v);
|
---|
246 | private:
|
---|
247 | friend class QMetaProperty;
|
---|
248 | #endif
|
---|
249 |
|
---|
250 | private: // Disabled copy constructor and operator=
|
---|
251 | #if defined(Q_DISABLE_COPY)
|
---|
252 | QMetaObject( const QMetaObject & );
|
---|
253 | QMetaObject &operator=( const QMetaObject & );
|
---|
254 | #endif
|
---|
255 | };
|
---|
256 |
|
---|
257 | inline int QMetaObject::slotOffset() const
|
---|
258 | { return slotoffset; }
|
---|
259 |
|
---|
260 | inline int QMetaObject::signalOffset() const
|
---|
261 | { return signaloffset; }
|
---|
262 |
|
---|
263 | #ifndef QT_NO_PROPERTIES
|
---|
264 | inline int QMetaObject::propertyOffset() const
|
---|
265 | { return propertyoffset; }
|
---|
266 | #endif
|
---|
267 |
|
---|
268 | typedef QMetaObject *(*QtStaticMetaObjectFunction)();
|
---|
269 |
|
---|
270 | class Q_EXPORT QMetaObjectCleanUp
|
---|
271 | {
|
---|
272 | public:
|
---|
273 | QMetaObjectCleanUp( const char *mo_name, QtStaticMetaObjectFunction );
|
---|
274 | QMetaObjectCleanUp();
|
---|
275 | ~QMetaObjectCleanUp();
|
---|
276 |
|
---|
277 | void setMetaObject( QMetaObject *&mo );
|
---|
278 |
|
---|
279 | private:
|
---|
280 | QMetaObject **metaObject;
|
---|
281 | };
|
---|
282 |
|
---|
283 | #endif // QMETAOBJECT_H
|
---|