]>
Commit | Line | Data |
---|---|---|
cc3977bf SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/rtti.h | |
3 | // Purpose: old RTTI macros (use XTI when possible instead) | |
4 | // Author: Julian Smart | |
5 | // Modified by: Ron Lee | |
6 | // Created: 01/02/97 | |
cc3977bf SC |
7 | // Copyright: (c) 1997 Julian Smart |
8 | // (c) 2001 Ron Lee <ron@debian.org> | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_RTTIH__ | |
13 | #define _WX_RTTIH__ | |
14 | ||
15 | #if !wxUSE_EXTENDED_RTTI // XTI system is meant to replace these macros | |
16 | ||
17 | // ---------------------------------------------------------------------------- | |
18 | // headers | |
19 | // ---------------------------------------------------------------------------- | |
20 | ||
21 | #include "wx/memory.h" | |
22 | ||
23 | // ---------------------------------------------------------------------------- | |
24 | // forward declarations | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
27 | class WXDLLIMPEXP_FWD_BASE wxObject; | |
62d70b39 | 28 | class WXDLLIMPEXP_FWD_BASE wxString; |
cc3977bf SC |
29 | class WXDLLIMPEXP_FWD_BASE wxClassInfo; |
30 | class WXDLLIMPEXP_FWD_BASE wxHashTable; | |
31 | class WXDLLIMPEXP_FWD_BASE wxObject; | |
32 | class WXDLLIMPEXP_FWD_BASE wxPluginLibrary; | |
33 | class WXDLLIMPEXP_FWD_BASE wxHashTable_Node; | |
34 | ||
35 | // ---------------------------------------------------------------------------- | |
36 | // wxClassInfo | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
39 | typedef wxObject *(*wxObjectConstructorFn)(void); | |
40 | ||
41 | class WXDLLIMPEXP_BASE wxClassInfo | |
42 | { | |
43 | friend class WXDLLIMPEXP_FWD_BASE wxObject; | |
44 | friend WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name); | |
45 | public: | |
46 | wxClassInfo( const wxChar *className, | |
47 | const wxClassInfo *baseInfo1, | |
48 | const wxClassInfo *baseInfo2, | |
49 | int size, | |
50 | wxObjectConstructorFn ctor ) | |
51 | : m_className(className) | |
52 | , m_objectSize(size) | |
53 | , m_objectConstructor(ctor) | |
54 | , m_baseInfo1(baseInfo1) | |
55 | , m_baseInfo2(baseInfo2) | |
56 | , m_next(sm_first) | |
57 | { | |
58 | sm_first = this; | |
59 | Register(); | |
60 | } | |
61 | ||
62 | ~wxClassInfo(); | |
63 | ||
64 | wxObject *CreateObject() const | |
65 | { return m_objectConstructor ? (*m_objectConstructor)() : 0; } | |
66 | bool IsDynamic() const { return (NULL != m_objectConstructor); } | |
67 | ||
68 | const wxChar *GetClassName() const { return m_className; } | |
69 | const wxChar *GetBaseClassName1() const | |
70 | { return m_baseInfo1 ? m_baseInfo1->GetClassName() : NULL; } | |
71 | const wxChar *GetBaseClassName2() const | |
72 | { return m_baseInfo2 ? m_baseInfo2->GetClassName() : NULL; } | |
73 | const wxClassInfo *GetBaseClass1() const { return m_baseInfo1; } | |
74 | const wxClassInfo *GetBaseClass2() const { return m_baseInfo2; } | |
75 | int GetSize() const { return m_objectSize; } | |
76 | ||
77 | wxObjectConstructorFn GetConstructor() const | |
78 | { return m_objectConstructor; } | |
79 | static const wxClassInfo *GetFirst() { return sm_first; } | |
80 | const wxClassInfo *GetNext() const { return m_next; } | |
81 | static wxClassInfo *FindClass(const wxString& className); | |
82 | ||
83 | // Climb upwards through inheritance hierarchy. | |
84 | // Dual inheritance is catered for. | |
85 | ||
86 | bool IsKindOf(const wxClassInfo *info) const | |
87 | { | |
88 | return info != 0 && | |
89 | ( info == this || | |
90 | ( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) || | |
91 | ( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) ); | |
92 | } | |
93 | ||
62d70b39 | 94 | wxDECLARE_CLASS_INFO_ITERATORS(); |
cc3977bf SC |
95 | |
96 | private: | |
97 | const wxChar *m_className; | |
98 | int m_objectSize; | |
99 | wxObjectConstructorFn m_objectConstructor; | |
100 | ||
101 | // Pointers to base wxClassInfos | |
102 | ||
103 | const wxClassInfo *m_baseInfo1; | |
104 | const wxClassInfo *m_baseInfo2; | |
105 | ||
106 | // class info object live in a linked list: | |
107 | // pointers to its head and the next element in it | |
108 | ||
109 | static wxClassInfo *sm_first; | |
110 | wxClassInfo *m_next; | |
111 | ||
112 | static wxHashTable *sm_classTable; | |
113 | ||
114 | protected: | |
115 | // registers the class | |
116 | void Register(); | |
117 | void Unregister(); | |
118 | ||
62d70b39 | 119 | wxDECLARE_NO_COPY_CLASS(wxClassInfo); |
cc3977bf SC |
120 | }; |
121 | ||
62d70b39 | 122 | WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name); |
cc3977bf SC |
123 | |
124 | // ---------------------------------------------------------------------------- | |
125 | // Dynamic class macros | |
126 | // ---------------------------------------------------------------------------- | |
127 | ||
128 | #define wxDECLARE_ABSTRACT_CLASS(name) \ | |
129 | public: \ | |
130 | static wxClassInfo ms_classInfo; \ | |
131 | virtual wxClassInfo *GetClassInfo() const | |
132 | ||
133 | #define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \ | |
134 | wxDECLARE_NO_ASSIGN_CLASS(name); \ | |
135 | wxDECLARE_DYNAMIC_CLASS(name) | |
136 | ||
137 | #define wxDECLARE_DYNAMIC_CLASS_NO_COPY(name) \ | |
138 | wxDECLARE_NO_COPY_CLASS(name); \ | |
139 | wxDECLARE_DYNAMIC_CLASS(name) | |
140 | ||
141 | #define wxDECLARE_DYNAMIC_CLASS(name) \ | |
142 | wxDECLARE_ABSTRACT_CLASS(name); \ | |
143 | static wxObject* wxCreateObject() | |
144 | ||
145 | #define wxDECLARE_CLASS(name) \ | |
ffc13495 | 146 | wxDECLARE_ABSTRACT_CLASS(name) |
cc3977bf SC |
147 | |
148 | ||
149 | // common part of the macros below | |
150 | #define wxIMPLEMENT_CLASS_COMMON(name, basename, baseclsinfo2, func) \ | |
151 | wxClassInfo name::ms_classInfo(wxT(#name), \ | |
152 | &basename::ms_classInfo, \ | |
153 | baseclsinfo2, \ | |
154 | (int) sizeof(name), \ | |
155 | func); \ | |
156 | \ | |
157 | wxClassInfo *name::GetClassInfo() const \ | |
158 | { return &name::ms_classInfo; } | |
159 | ||
160 | #define wxIMPLEMENT_CLASS_COMMON1(name, basename, func) \ | |
161 | wxIMPLEMENT_CLASS_COMMON(name, basename, NULL, func) | |
162 | ||
163 | #define wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, func) \ | |
164 | wxIMPLEMENT_CLASS_COMMON(name, basename1, &basename2::ms_classInfo, func) | |
165 | ||
166 | // ----------------------------------- | |
167 | // for concrete classes | |
168 | // ----------------------------------- | |
169 | ||
170 | // Single inheritance with one base class | |
171 | #define wxIMPLEMENT_DYNAMIC_CLASS(name, basename) \ | |
172 | wxIMPLEMENT_CLASS_COMMON1(name, basename, name::wxCreateObject) \ | |
173 | wxObject* name::wxCreateObject() \ | |
174 | { return new name; } | |
175 | ||
176 | // Multiple inheritance with two base classes | |
177 | #define wxIMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \ | |
178 | wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, \ | |
179 | name::wxCreateObject) \ | |
180 | wxObject* name::wxCreateObject() \ | |
181 | { return new name; } | |
182 | ||
183 | // ----------------------------------- | |
184 | // for abstract classes | |
185 | // ----------------------------------- | |
186 | ||
187 | // Single inheritance with one base class | |
188 | #define wxIMPLEMENT_ABSTRACT_CLASS(name, basename) \ | |
189 | wxIMPLEMENT_CLASS_COMMON1(name, basename, NULL) | |
190 | ||
191 | // Multiple inheritance with two base classes | |
192 | #define wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \ | |
193 | wxIMPLEMENT_CLASS_COMMON2(name, basename1, basename2, NULL) | |
194 | ||
cc3977bf SC |
195 | // ----------------------------------- |
196 | // XTI-compatible macros | |
197 | // ----------------------------------- | |
198 | ||
199 | #include "wx/flags.h" | |
200 | ||
201 | // these macros only do something when wxUSE_EXTENDED_RTTI=1 | |
202 | // (and in that case they are defined by xti.h); however to avoid | |
203 | // to be forced to wrap these macros (in user's source files) with | |
204 | // | |
205 | // #if wxUSE_EXTENDED_RTTI | |
206 | // ... | |
207 | // #endif | |
208 | // | |
209 | // blocks, we define them here as empty. | |
210 | ||
211 | #define wxEMPTY_PARAMETER_VALUE /**/ | |
212 | ||
213 | #define wxBEGIN_ENUM( e ) wxEMPTY_PARAMETER_VALUE | |
214 | #define wxENUM_MEMBER( v ) wxEMPTY_PARAMETER_VALUE | |
215 | #define wxEND_ENUM( e ) wxEMPTY_PARAMETER_VALUE | |
216 | ||
217 | #define wxIMPLEMENT_SET_STREAMING(SetName,e) wxEMPTY_PARAMETER_VALUE | |
218 | ||
219 | #define wxBEGIN_FLAGS( e ) wxEMPTY_PARAMETER_VALUE | |
220 | #define wxFLAGS_MEMBER( v ) wxEMPTY_PARAMETER_VALUE | |
221 | #define wxEND_FLAGS( e ) wxEMPTY_PARAMETER_VALUE | |
222 | ||
223 | #define wxCOLLECTION_TYPE_INFO( element, collection ) wxEMPTY_PARAMETER_VALUE | |
224 | ||
225 | #define wxHANDLER(name,eventClassType) wxEMPTY_PARAMETER_VALUE | |
226 | #define wxBEGIN_HANDLERS_TABLE(theClass) wxEMPTY_PARAMETER_VALUE | |
227 | #define wxEND_HANDLERS_TABLE() wxEMPTY_PARAMETER_VALUE | |
228 | ||
469b56ea SC |
229 | #define wxIMPLEMENT_DYNAMIC_CLASS_XTI( name, basename, unit ) \ |
230 | wxIMPLEMENT_DYNAMIC_CLASS( name, basename ) | |
cc3977bf | 231 | #define wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name, basename, unit, callback ) \ |
469b56ea | 232 | wxIMPLEMENT_DYNAMIC_CLASS( name, basename ) |
cc3977bf | 233 | |
469b56ea SC |
234 | #define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name, basename, unit ) \ |
235 | wxIMPLEMENT_DYNAMIC_CLASS( name, basename) | |
cc3977bf SC |
236 | |
237 | #define wxIMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( name, basename, \ | |
238 | unit, toString, \ | |
239 | fromString ) wxEMPTY_PARAMETER_VALUE | |
240 | #define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name, unit ) wxEMPTY_PARAMETER_VALUE | |
241 | #define wxIMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name, basename, unit ) wxEMPTY_PARAMETER_VALUE | |
242 | ||
243 | #define wxIMPLEMENT_DYNAMIC_CLASS2_XTI( name, basename, basename2, unit) wxIMPLEMENT_DYNAMIC_CLASS2( name, basename, basename2 ) | |
244 | ||
245 | #define wxCONSTRUCTOR_0(klass) \ | |
246 | wxEMPTY_PARAMETER_VALUE | |
247 | #define wxCONSTRUCTOR_DUMMY(klass) \ | |
248 | wxEMPTY_PARAMETER_VALUE | |
249 | #define wxDIRECT_CONSTRUCTOR_0(klass) \ | |
250 | wxEMPTY_PARAMETER_VALUE | |
251 | #define wxCONSTRUCTOR_1(klass,t0,v0) \ | |
252 | wxEMPTY_PARAMETER_VALUE | |
253 | #define wxDIRECT_CONSTRUCTOR_1(klass,t0,v0) \ | |
254 | wxEMPTY_PARAMETER_VALUE | |
255 | #define wxCONSTRUCTOR_2(klass,t0,v0,t1,v1) \ | |
256 | wxEMPTY_PARAMETER_VALUE | |
257 | #define wxDIRECT_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \ | |
258 | wxEMPTY_PARAMETER_VALUE | |
259 | #define wxCONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ | |
260 | wxEMPTY_PARAMETER_VALUE | |
261 | #define wxDIRECT_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \ | |
262 | wxEMPTY_PARAMETER_VALUE | |
263 | #define wxCONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \ | |
264 | wxEMPTY_PARAMETER_VALUE | |
265 | #define wxDIRECT_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \ | |
266 | wxEMPTY_PARAMETER_VALUE | |
267 | #define wxCONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \ | |
268 | wxEMPTY_PARAMETER_VALUE | |
269 | #define wxDIRECT_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \ | |
270 | wxEMPTY_PARAMETER_VALUE | |
271 | #define wxCONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ | |
272 | wxEMPTY_PARAMETER_VALUE | |
273 | #define wxDIRECT_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \ | |
274 | wxEMPTY_PARAMETER_VALUE | |
275 | #define wxCONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ | |
276 | wxEMPTY_PARAMETER_VALUE | |
277 | #define wxDIRECT_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \ | |
278 | wxEMPTY_PARAMETER_VALUE | |
279 | #define wxCONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \ | |
280 | wxEMPTY_PARAMETER_VALUE | |
281 | #define wxDIRECT_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \ | |
282 | wxEMPTY_PARAMETER_VALUE | |
283 | ||
284 | #define wxSETTER( property, Klass, valueType, setterMethod ) wxEMPTY_PARAMETER_VALUE | |
285 | #define wxGETTER( property, Klass, valueType, gettermethod ) wxEMPTY_PARAMETER_VALUE | |
286 | #define wxADDER( property, Klass, valueType, addermethod ) wxEMPTY_PARAMETER_VALUE | |
287 | #define wxCOLLECTION_GETTER( property, Klass, valueType, gettermethod ) wxEMPTY_PARAMETER_VALUE | |
288 | ||
289 | #define wxBEGIN_PROPERTIES_TABLE(theClass) wxEMPTY_PARAMETER_VALUE | |
290 | #define wxEND_PROPERTIES_TABLE() wxEMPTY_PARAMETER_VALUE | |
291 | #define wxHIDE_PROPERTY( pname ) wxEMPTY_PARAMETER_VALUE | |
292 | ||
293 | #define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \ | |
294 | wxEMPTY_PARAMETER_VALUE | |
295 | ||
296 | #define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue, \ | |
297 | pflags, help, group) wxEMPTY_PARAMETER_VALUE | |
298 | ||
299 | #define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \ | |
300 | wxGETTER( pname, class_t, type, getter ) wxEMPTY_PARAMETER_VALUE | |
301 | ||
302 | #define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue, \ | |
303 | pflags, help, group) wxEMPTY_PARAMETER_VALUE | |
304 | ||
305 | #define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter, \ | |
306 | flags, help, group ) wxEMPTY_PARAMETER_VALUE | |
307 | ||
308 | #define wxREADONLY_PROPERTY_COLLECTION( pname, colltype, addelemtype, getter, \ | |
309 | flags, help, group) wxEMPTY_PARAMETER_VALUE | |
310 | #define wxEVENT_PROPERTY( name, eventType, eventClass ) wxEMPTY_PARAMETER_VALUE | |
311 | ||
312 | #define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) wxEMPTY_PARAMETER_VALUE | |
313 | ||
314 | #define wxIMPLEMENT_PROPERTY(name, type) wxEMPTY_PARAMETER_VALUE | |
315 | ||
316 | #define wxEMPTY_HANDLERS_TABLE(name) wxEMPTY_PARAMETER_VALUE | |
317 | ||
318 | #endif // !wxUSE_EXTENDED_RTTI | |
319 | #endif // _WX_RTTIH__ |