1 /****************************************************************************
2 ** $Id: qt/qobjectdefs.h   3.3.8   edited Jan 11 14:38 $
3 **
4 ** Macros and definitions related to QObject
5 **
6 ** Created : 930419
7 **
8 ** Copyright (C) 1992-2007 Trolltech ASA.  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 ASA 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 QOBJECTDEFS_H
39 #define QOBJECTDEFS_H
40 
41 #ifndef QT_H
42 #include "qglobal.h"
43 #endif // QT_H
44 
45 
46 #ifndef QT_NO_TRANSLATION
47 # ifndef QT_NO_TEXTCODEC
48 // full set of tr functions
49 #  define QT_TR_FUNCTIONS \
50     static QString tr( const char *, const char * = 0 ); \
51     static QString trUtf8( const char *, const char * = 0 );
52 # else
53 // no QTextCodec, no utf8
54 #  define QT_TR_FUNCTIONS \
55     static QString tr( const char *, const char * = 0 );
56 # endif
57 #else
58 // inherit the ones from QObject
59 # define QT_TR_FUNCTIONS
60 #endif
61 
62 #ifndef QT_NO_PROPERTIES
63 # define QT_PROP_FUNCTIONS \
64     virtual bool qt_property( int id, int f, QVariant* v); \
65     static bool qt_static_property( QObject* , int, int, QVariant* );
66 #else
67 # define QT_PROP_FUNCTIONS
68 #endif
69 
70 // The following macros are our "extensions" to C++
71 // They are used, strictly speaking, only by the moc.
72 struct QUObject;
73 
74 #ifdef QT_MOC_CPP
75 #define slots			    slots
76 #define signals		    signals
77 #define Q_CLASSINFO( name, value ) Q_CLASSINFO( name, value )
78 #define Q_PROPERTY( text )	    Q_PROPERTY( text )
79 #define Q_OVERRIDE( text )	    Q_OVERRIDE( text )
80 #define Q_ENUMS( x )		    Q_ENUMS( x )
81 #define Q_SETS( x )		    Q_SETS( x )
82  /* tmake ignore Q_OBJECT */
83 #define Q_OBJECT		    Q_OBJECT
84  /* tmake ignore Q_OBJECT */
85 #define Q_OBJECT_FAKE		    Q_OBJECT_FAKE
86 
87 #else
88 #define slots					// slots: in class
89 #define signals protected			// signals: in class
90 #ifndef QT_NO_EMIT
91 #define emit					// emit signal
92 #endif
93 #define Q_CLASSINFO( name, value )		// class info
94 #define Q_PROPERTY( text )			// property
95 #define Q_OVERRIDE( text )			// override property
96 #define Q_ENUMS( x )
97 #define Q_SETS( x )
98 
99 /* tmake ignore Q_OBJECT */
100 #define Q_OBJECT							\
101 public:									\
102     virtual QMetaObject *metaObject() const { 				\
103          return staticMetaObject();					\
104     }									\
105     virtual const char *className() const;				\
106     virtual void* qt_cast( const char* ); 				\
107     virtual bool qt_invoke( int, QUObject* ); 				\
108     virtual bool qt_emit( int, QUObject* ); 				\
109     QT_PROP_FUNCTIONS							\
110     static QMetaObject* staticMetaObject();				\
111     QObject* qObject() { return (QObject*)this; } 			\
112     QT_TR_FUNCTIONS							\
113 private:								\
114     static QMetaObject *metaObj;
115 
116 /* tmake ignore Q_OBJECT */
117 #define Q_OBJECT_FAKE Q_OBJECT
118 
119 #endif
120 
121 // macro for naming members
122 #ifdef METHOD
123 #undef METHOD
124 #endif
125 #ifdef SLOT
126 #undef SLOT
127 #endif
128 #ifdef SIGNAL
129 #undef SIGNAL
130 #endif
131 
132 #if defined(_OLD_CPP_)
133 #define METHOD(a)	"0""a"
134 #define SLOT(a)		"1""a"
135 #define SIGNAL(a)	"2""a"
136 #else
137 #define METHOD(a)	"0"#a
138 #define SLOT(a)		"1"#a
139 #define SIGNAL(a)	"2"#a
140 #endif
141 
142 #ifndef QT_CLEAN_NAMESPACE
143 #define METHOD_CODE	0			// member type codes
144 #define SLOT_CODE	1
145 #define SIGNAL_CODE	2
146 #endif
147 
148 #define QMETHOD_CODE	0			// member type codes
149 #define QSLOT_CODE	1
150 #define QSIGNAL_CODE	2
151 
152 class QObject;
153 class QMetaObject;
154 class QSignal;
155 class QConnection;
156 class QEvent;
157 struct QMetaData;
158 class QConnectionList;
159 class QConnectionListIt;
160 class QSignalVec;
161 class QObjectList;
162 class QObjectListIt;
163 class QMemberDict;
164 
165 Q_EXPORT void *qt_find_obj_child( QObject *, const char *, const char * );
166 #define Q_CHILD(parent,type,name) \
167 	((type*)qt_find_obj_child(parent,#type,name))
168 
169 Q_EXPORT void *qt_inheritedBy( QMetaObject *super, const QObject *cls );
170 
171 template <typename T>
qt_cast(const QObject * object)172 Q_INLINE_TEMPLATES T qt_cast(const QObject *object)
173 { return (T)qt_inheritedBy( ((T)0)->staticMetaObject(), object ); }
174 #endif // QOBJECTDEFS_H
175