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