]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
b2edef6f | 2 | // Name: wx/object.h |
c801d85f KB |
3 | // Purpose: wxObject class, plus run-time type information macros |
4 | // Author: Julian Smart | |
0b9ab0bd | 5 | // Modified by: Ron Lee |
c801d85f KB |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
371a5b4e | 8 | // Copyright: (c) 1997 Julian Smart |
0b9ab0bd | 9 | // (c) 2001 Ron Lee <ron@debian.org> |
65571936 | 10 | // Licence: wxWindows licence |
c801d85f KB |
11 | ///////////////////////////////////////////////////////////////////////////// |
12 | ||
34138703 JS |
13 | #ifndef _WX_OBJECTH__ |
14 | #define _WX_OBJECTH__ | |
c801d85f | 15 | |
0b9ab0bd RL |
16 | // ---------------------------------------------------------------------------- |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
e55ad60e | 20 | #include "wx/memory.h" |
c801d85f | 21 | |
28953245 SC |
22 | // based on the value of wxUSE_EXTENDED_RTTI symbol, |
23 | // only one of the RTTI system will be compiled: | |
24 | // - the "old" one (defined by rtti.h) or | |
25 | // - the "new" one (defined by xti.h) | |
a095505c | 26 | #include "wx/xti.h" |
28953245 | 27 | #include "wx/rtti.h" |
a095505c | 28 | |
cbca59a8 SC |
29 | #define wxIMPLEMENT_CLASS(name, basename) \ |
30 | wxIMPLEMENT_ABSTRACT_CLASS(name, basename) | |
31 | ||
32 | #define wxIMPLEMENT_CLASS2(name, basename1, basename2) \ | |
33 | wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) | |
34 | ||
0b9ab0bd RL |
35 | // ----------------------------------- |
36 | // for pluggable classes | |
37 | // ----------------------------------- | |
38 | ||
39 | // NOTE: this should probably be the very first statement | |
40 | // in the class declaration so wxPluginSentinel is | |
41 | // the first member initialised and the last destroyed. | |
42 | ||
43 | // _DECLARE_DL_SENTINEL(name) wxPluginSentinel m_pluginsentinel; | |
44 | ||
45 | #if wxUSE_NESTED_CLASSES | |
46 | ||
60b73526 RL |
47 | #define _DECLARE_DL_SENTINEL(name, exportdecl) \ |
48 | class exportdecl name##PluginSentinel { \ | |
49 | private: \ | |
50 | static const wxString sm_className; \ | |
51 | public: \ | |
52 | name##PluginSentinel(); \ | |
2e0b1b11 | 53 | ~name##PluginSentinel(); \ |
60b73526 | 54 | }; \ |
b19b28c8 | 55 | name##PluginSentinel m_pluginsentinel |
0b9ab0bd RL |
56 | |
57 | #define _IMPLEMENT_DL_SENTINEL(name) \ | |
58 | const wxString name::name##PluginSentinel::sm_className(#name); \ | |
59 | name::name##PluginSentinel::name##PluginSentinel() { \ | |
4f89dbc4 | 60 | wxPluginLibrary *e = (wxPluginLibrary*) wxPluginLibrary::ms_classes.Get(#name); \ |
7c1e2b44 | 61 | if( e != 0 ) { e->RefObj(); } \ |
0b9ab0bd | 62 | } \ |
abad5367 | 63 | name::name##PluginSentinel::~name##PluginSentinel() { \ |
4f89dbc4 | 64 | wxPluginLibrary *e = (wxPluginLibrary*) wxPluginLibrary::ms_classes.Get(#name); \ |
7c1e2b44 | 65 | if( e != 0 ) { e->UnrefObj(); } \ |
0b9ab0bd RL |
66 | } |
67 | #else | |
68 | ||
69 | #define _DECLARE_DL_SENTINEL(name) | |
70 | #define _IMPLEMENT_DL_SENTINEL(name) | |
71 | ||
72 | #endif // wxUSE_NESTED_CLASSES | |
73 | ||
b19b28c8 FM |
74 | #define wxDECLARE_PLUGGABLE_CLASS(name) \ |
75 | wxDECLARE_DYNAMIC_CLASS(name); _DECLARE_DL_SENTINEL(name, WXDLLIMPEXP_CORE) | |
76 | #define wxDECLARE_ABSTRACT_PLUGGABLE_CLASS(name) \ | |
77 | wxDECLARE_ABSTRACT_CLASS(name); _DECLARE_DL_SENTINEL(name, WXDLLIMPEXP_CORE) | |
78 | ||
79 | #define wxDECLARE_USER_EXPORTED_PLUGGABLE_CLASS(name, usergoo) \ | |
80 | wxDECLARE_DYNAMIC_CLASS(name); _DECLARE_DL_SENTINEL(name, usergoo) | |
81 | #define wxDECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, usergoo) \ | |
82 | wxDECLARE_ABSTRACT_CLASS(name); _DECLARE_DL_SENTINEL(name, usergoo) | |
83 | ||
84 | #define wxIMPLEMENT_PLUGGABLE_CLASS(name, basename) \ | |
85 | wxIMPLEMENT_DYNAMIC_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name) | |
86 | #define wxIMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) \ | |
87 | wxIMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name) | |
88 | #define wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) \ | |
89 | wxIMPLEMENT_ABSTRACT_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name) | |
90 | #define wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \ | |
91 | wxIMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name) | |
92 | ||
93 | #define wxIMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(name, basename) \ | |
94 | wxIMPLEMENT_PLUGGABLE_CLASS(name, basename) | |
95 | #define wxIMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(name, basename1, basename2) \ | |
96 | wxIMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) | |
97 | #define wxIMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, basename) \ | |
98 | wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) | |
99 | #define wxIMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \ | |
100 | wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) | |
101 | ||
102 | #define wxCLASSINFO(name) (&name::ms_classInfo) | |
c801d85f | 103 | |
c0db9626 | 104 | #define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::ms_classInfo) |
3013b6f4 | 105 | |
b2edef6f | 106 | // Just seems a bit nicer-looking (pretend it's not a macro) |
c0db9626 | 107 | #define wxIsKindOf(obj, className) obj->IsKindOf(&className::ms_classInfo) |
c801d85f | 108 | |
73fbb031 VZ |
109 | // this cast does some more checks at compile time as it uses static_cast |
110 | // internally | |
111 | // | |
112 | // note that it still has different semantics from dynamic_cast<> and so can't | |
113 | // be replaced by it as long as there are any compilers not supporting it | |
34636400 | 114 | #define wxDynamicCast(obj, className) \ |
5232d996 | 115 | ((className *) wxCheckDynamicCast( \ |
5c33522f VZ |
116 | const_cast<wxObject *>(static_cast<const wxObject *>(\ |
117 | const_cast<className *>(static_cast<const className *>(obj)))), \ | |
5232d996 | 118 | &className::ms_classInfo)) |
0b9ab0bd | 119 | |
b2edef6f VZ |
120 | // The 'this' pointer is always true, so use this version |
121 | // to cast the this pointer and avoid compiler warnings. | |
f7637829 | 122 | #define wxDynamicCastThis(className) \ |
73fbb031 | 123 | (IsKindOf(&className::ms_classInfo) ? (className *)(this) : (className *)0) |
33ac7e6f | 124 | |
657a8a35 VZ |
125 | // FIXME-VC6: dummy argument needed because VC6 doesn't support explicitly |
126 | // choosing the template function to call | |
127 | template <class T> | |
128 | inline T *wxCheckCast(const void *ptr, T * = NULL) | |
0b9ab0bd | 129 | { |
657a8a35 VZ |
130 | wxASSERT_MSG( wxDynamicCast(ptr, T), "wxStaticCast() used incorrectly" ); |
131 | return const_cast<T *>(static_cast<const T *>(ptr)); | |
0b9ab0bd | 132 | } |
f6bcfd97 | 133 | |
657a8a35 | 134 | #define wxStaticCast(obj, className) wxCheckCast((obj), (className *)NULL) |
f6bcfd97 | 135 | |
b2edef6f VZ |
136 | // ---------------------------------------------------------------------------- |
137 | // set up memory debugging macros | |
138 | // ---------------------------------------------------------------------------- | |
139 | ||
140 | /* | |
141 | Which new/delete operator variants do we want? | |
142 | ||
143 | _WX_WANT_NEW_SIZET_WXCHAR_INT = void *operator new (size_t size, wxChar *fileName = 0, int lineNum = 0) | |
144 | _WX_WANT_DELETE_VOID = void operator delete (void * buf) | |
145 | _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET = void operator delete (void *buf, const char *_fname, size_t _line) | |
146 | _WX_WANT_DELETE_VOID_WXCHAR_INT = void operator delete(void *buf, wxChar*, int) | |
147 | _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT = void *operator new[] (size_t size, wxChar *fileName , int lineNum = 0) | |
148 | _WX_WANT_ARRAY_DELETE_VOID = void operator delete[] (void *buf) | |
149 | _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT = void operator delete[] (void* buf, wxChar*, int ) | |
150 | */ | |
151 | ||
657a8a35 | 152 | #if wxUSE_MEMORY_TRACING |
b2edef6f VZ |
153 | |
154 | // All compilers get this one | |
155 | #define _WX_WANT_NEW_SIZET_WXCHAR_INT | |
156 | ||
157 | // Everyone except Visage gets the next one | |
158 | #ifndef __VISAGECPP__ | |
159 | #define _WX_WANT_DELETE_VOID | |
c801d85f | 160 | #endif |
b2edef6f VZ |
161 | |
162 | // Only visage gets this one under the correct circumstances | |
163 | #if defined(__VISAGECPP__) && __DEBUG_ALLOC__ | |
164 | #define _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET | |
165 | #endif | |
166 | ||
4e124582 VZ |
167 | // Only VC++ 6 and CodeWarrior get overloaded delete that matches new |
168 | #if (defined(__VISUALC__) && (__VISUALC__ >= 1200)) || \ | |
169 | (defined(__MWERKS__) && (__MWERKS__ >= 0x2400)) | |
b2edef6f | 170 | #define _WX_WANT_DELETE_VOID_WXCHAR_INT |
fd85b064 | 171 | #endif |
c801d85f | 172 | |
b2edef6f VZ |
173 | // Now see who (if anyone) gets the array memory operators |
174 | #if wxUSE_ARRAY_MEMORY_OPERATORS | |
175 | ||
176 | // Everyone except Visual C++ (cause problems for VC++ - crashes) | |
177 | #if !defined(__VISUALC__) | |
178 | #define _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT | |
179 | #endif | |
180 | ||
181 | // Everyone except Visual C++ (cause problems for VC++ - crashes) | |
182 | #if !defined(__VISUALC__) | |
183 | #define _WX_WANT_ARRAY_DELETE_VOID | |
184 | #endif | |
185 | ||
186 | // Only CodeWarrior 6 or higher | |
187 | #if defined(__MWERKS__) && (__MWERKS__ >= 0x2400) | |
188 | #define _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT | |
189 | #endif | |
190 | ||
191 | #endif // wxUSE_ARRAY_MEMORY_OPERATORS | |
192 | ||
657a8a35 | 193 | #endif // wxUSE_MEMORY_TRACING |
b2edef6f | 194 | |
cbca59a8 SC |
195 | // ---------------------------------------------------------------------------- |
196 | // Compatibility macro aliases DECLARE group | |
197 | // ---------------------------------------------------------------------------- | |
198 | // deprecated variants _not_ requiring a semicolon after them and without wx prefix. | |
199 | // (note that also some wx-prefixed macro do _not_ require a semicolon because | |
200 | // it's not always possible to force the compire to require it) | |
201 | ||
202 | #define DECLARE_CLASS_INFO_ITERATORS() wxDECLARE_CLASS_INFO_ITERATORS(); | |
203 | #define DECLARE_ABSTRACT_CLASS(n) wxDECLARE_ABSTRACT_CLASS(n); | |
204 | #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(n) wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(n); | |
205 | #define DECLARE_DYNAMIC_CLASS_NO_COPY(n) wxDECLARE_DYNAMIC_CLASS_NO_COPY(n); | |
206 | #define DECLARE_DYNAMIC_CLASS(n) wxDECLARE_DYNAMIC_CLASS(n); | |
207 | #define DECLARE_CLASS(n) wxDECLARE_CLASS(n); | |
208 | ||
209 | #define DECLARE_PLUGGABLE_CLASS(n) wxDECLARE_PLUGGABLE_CLASS(n); | |
210 | #define DECLARE_ABSTRACT_PLUGGABLE_CLASS(n) wxDECLARE_ABSTRACT_PLUGGABLE_CLASS(n); | |
211 | #define DECLARE_USER_EXPORTED_PLUGGABLE_CLASS(n,u) wxDECLARE_USER_EXPORTED_PLUGGABLE_CLASS(n,u); | |
212 | #define DECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(n,u) wxDECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(n,u); | |
213 | ||
f8855e47 | 214 | // ---------------------------------------------------------------------------- |
6d37c1b7 | 215 | // wxRefCounter: ref counted data "manager" |
f8855e47 VZ |
216 | // ---------------------------------------------------------------------------- |
217 | ||
6d37c1b7 | 218 | class WXDLLIMPEXP_BASE wxRefCounter |
f8855e47 | 219 | { |
f8855e47 | 220 | public: |
6d37c1b7 | 221 | wxRefCounter() { m_count = 1; } |
f8855e47 VZ |
222 | |
223 | int GetRefCount() const { return m_count; } | |
224 | ||
4a11340a RR |
225 | void IncRef() { m_count++; } |
226 | void DecRef(); | |
227 | ||
228 | protected: | |
229 | // this object should never be destroyed directly but only as a | |
230 | // result of a DecRef() call: | |
6d37c1b7 | 231 | virtual ~wxRefCounter() { } |
4a11340a | 232 | |
f8855e47 | 233 | private: |
4a11340a | 234 | // our refcount: |
f8855e47 | 235 | int m_count; |
fd08ccd2 VZ |
236 | |
237 | // It doesn't make sense to copy the reference counted objects, a new ref | |
238 | // counter should be created for a new object instead and compilation | |
239 | // errors in the code using wxRefCounter due to the lack of copy ctor often | |
240 | // indicate a problem, e.g. a forgotten copy ctor implementation somewhere. | |
241 | wxDECLARE_NO_COPY_CLASS(wxRefCounter); | |
f8855e47 VZ |
242 | }; |
243 | ||
6d37c1b7 RR |
244 | // ---------------------------------------------------------------------------- |
245 | // wxObjectRefData: ref counted data meant to be stored in wxObject | |
246 | // ---------------------------------------------------------------------------- | |
247 | ||
248 | typedef wxRefCounter wxObjectRefData; | |
249 | ||
4a11340a RR |
250 | // ---------------------------------------------------------------------------- |
251 | // wxObjectDataPtr: helper class to avoid memleaks because of missing calls | |
252 | // to wxObjectRefData::DecRef | |
253 | // ---------------------------------------------------------------------------- | |
254 | ||
255 | template <class T> | |
256 | class wxObjectDataPtr | |
257 | { | |
258 | public: | |
259 | typedef T element_type; | |
260 | ||
261 | wxEXPLICIT wxObjectDataPtr(T *ptr = NULL) : m_ptr(ptr) {} | |
262 | ||
263 | // copy ctor | |
53a2db12 | 264 | wxObjectDataPtr(const wxObjectDataPtr<T> &tocopy) |
4a11340a | 265 | : m_ptr(tocopy.m_ptr) |
53a2db12 | 266 | { |
4a11340a | 267 | if (m_ptr) |
53a2db12 | 268 | m_ptr->IncRef(); |
4a11340a RR |
269 | } |
270 | ||
53a2db12 FM |
271 | ~wxObjectDataPtr() |
272 | { | |
273 | if (m_ptr) | |
274 | m_ptr->DecRef(); | |
4a11340a RR |
275 | } |
276 | ||
277 | T *get() const { return m_ptr; } | |
53a2db12 | 278 | |
a60b0ddc RR |
279 | // test for pointer validity: defining conversion to unspecified_bool_type |
280 | // and not more obvious bool to avoid implicit conversions to integer types | |
281 | typedef T *(wxObjectDataPtr<T>::*unspecified_bool_type)() const; | |
282 | operator unspecified_bool_type() const | |
283 | { | |
284 | return m_ptr ? &wxObjectDataPtr<T>::get : NULL; | |
285 | } | |
286 | ||
287 | T& operator*() const | |
53a2db12 FM |
288 | { |
289 | wxASSERT(m_ptr != NULL); | |
a60b0ddc RR |
290 | return *(m_ptr); |
291 | } | |
53a2db12 | 292 | |
e39d30c0 | 293 | T *operator->() const |
53a2db12 FM |
294 | { |
295 | wxASSERT(m_ptr != NULL); | |
296 | return get(); | |
e39d30c0 | 297 | } |
4a11340a RR |
298 | |
299 | void reset(T *ptr) | |
300 | { | |
301 | if (m_ptr) | |
302 | m_ptr->DecRef(); | |
303 | m_ptr = ptr; | |
304 | } | |
305 | ||
306 | wxObjectDataPtr& operator=(const wxObjectDataPtr &tocopy) | |
53a2db12 FM |
307 | { |
308 | if (m_ptr) | |
309 | m_ptr->DecRef(); | |
310 | m_ptr = tocopy.m_ptr; | |
4a11340a | 311 | if (m_ptr) |
53a2db12 | 312 | m_ptr->IncRef(); |
4a11340a RR |
313 | return *this; |
314 | } | |
315 | ||
316 | wxObjectDataPtr& operator=(T *ptr) | |
53a2db12 FM |
317 | { |
318 | if (m_ptr) | |
319 | m_ptr->DecRef(); | |
320 | m_ptr = ptr; | |
4a11340a RR |
321 | return *this; |
322 | } | |
323 | ||
324 | private: | |
325 | T *m_ptr; | |
326 | }; | |
327 | ||
0b9ab0bd | 328 | // ---------------------------------------------------------------------------- |
77ffb593 | 329 | // wxObject: the root class of wxWidgets object hierarchy |
0b9ab0bd RL |
330 | // ---------------------------------------------------------------------------- |
331 | ||
bddd7a8d | 332 | class WXDLLIMPEXP_BASE wxObject |
c801d85f | 333 | { |
b19b28c8 | 334 | wxDECLARE_ABSTRACT_CLASS(wxObject); |
c801d85f | 335 | |
0b9ab0bd | 336 | public: |
b2edef6f | 337 | wxObject() { m_refData = NULL; } |
0b9ab0bd | 338 | virtual ~wxObject() { UnRef(); } |
4393b50c | 339 | |
a6391d30 | 340 | wxObject(const wxObject& other) |
66e9a9f0 | 341 | { |
f8855e47 VZ |
342 | m_refData = other.m_refData; |
343 | if (m_refData) | |
6d37c1b7 | 344 | m_refData->IncRef(); |
66e9a9f0 | 345 | } |
4393b50c | 346 | |
a6391d30 GD |
347 | wxObject& operator=(const wxObject& other) |
348 | { | |
349 | if ( this != &other ) | |
350 | { | |
f8855e47 | 351 | Ref(other); |
a6391d30 GD |
352 | } |
353 | return *this; | |
354 | } | |
355 | ||
303c6f20 | 356 | bool IsKindOf(const wxClassInfo *info) const; |
c801d85f | 357 | |
0b9ab0bd | 358 | |
b2edef6f VZ |
359 | // Turn on the correct set of new and delete operators |
360 | ||
361 | #ifdef _WX_WANT_NEW_SIZET_WXCHAR_INT | |
cf760e4c | 362 | void *operator new ( size_t size, const wxChar *fileName = NULL, int lineNum = 0 ); |
0b9ab0bd | 363 | #endif |
27198be4 | 364 | |
b2edef6f VZ |
365 | #ifdef _WX_WANT_DELETE_VOID |
366 | void operator delete ( void * buf ); | |
367 | #endif | |
0b9ab0bd | 368 | |
b2edef6f VZ |
369 | #ifdef _WX_WANT_DELETE_VOID_CONSTCHAR_SIZET |
370 | void operator delete ( void *buf, const char *_fname, size_t _line ); | |
0b9ab0bd | 371 | #endif |
76626af2 | 372 | |
b2edef6f | 373 | #ifdef _WX_WANT_DELETE_VOID_WXCHAR_INT |
cf760e4c | 374 | void operator delete ( void *buf, const wxChar*, int ); |
b2edef6f | 375 | #endif |
8cfc5426 | 376 | |
b2edef6f | 377 | #ifdef _WX_WANT_ARRAY_NEW_SIZET_WXCHAR_INT |
cf760e4c | 378 | void *operator new[] ( size_t size, const wxChar *fileName = NULL, int lineNum = 0 ); |
0b9ab0bd RL |
379 | #endif |
380 | ||
b2edef6f VZ |
381 | #ifdef _WX_WANT_ARRAY_DELETE_VOID |
382 | void operator delete[] ( void *buf ); | |
0b9ab0bd | 383 | #endif |
27198be4 | 384 | |
b2edef6f | 385 | #ifdef _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT |
cf760e4c | 386 | void operator delete[] (void* buf, const wxChar*, int ); |
b2edef6f | 387 | #endif |
c801d85f | 388 | |
807d8487 VZ |
389 | // ref counted data handling methods |
390 | ||
391 | // get/set | |
392 | wxObjectRefData *GetRefData() const { return m_refData; } | |
393 | void SetRefData(wxObjectRefData *data) { m_refData = data; } | |
394 | ||
395 | // make a 'clone' of the object | |
0b9ab0bd | 396 | void Ref(const wxObject& clone); |
c801d85f | 397 | |
807d8487 | 398 | // destroy a reference |
0b9ab0bd | 399 | void UnRef(); |
c801d85f | 400 | |
93c5f755 PC |
401 | // Make sure this object has only one reference |
402 | void UnShare() { AllocExclusive(); } | |
403 | ||
a3ab1c18 VZ |
404 | // check if this object references the same data as the other one |
405 | bool IsSameAs(const wxObject& o) const { return m_refData == o.m_refData; } | |
55ccdb93 | 406 | |
c801d85f | 407 | protected: |
807d8487 VZ |
408 | // ensure that our data is not shared with anybody else: if we have no |
409 | // data, it is created using CreateRefData() below, if we have shared data | |
410 | // it is copied using CloneRefData(), otherwise nothing is done | |
411 | void AllocExclusive(); | |
412 | ||
4e124582 VZ |
413 | // both methods must be implemented if AllocExclusive() is used, not pure |
414 | // virtual only because of the backwards compatibility reasons | |
807d8487 VZ |
415 | |
416 | // create a new m_refData | |
417 | virtual wxObjectRefData *CreateRefData() const; | |
418 | ||
419 | // create a new m_refData initialized with the given one | |
b8027888 | 420 | virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; |
807d8487 | 421 | |
0b9ab0bd | 422 | wxObjectRefData *m_refData; |
c801d85f KB |
423 | }; |
424 | ||
ea1e6c4b RL |
425 | inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo) |
426 | { | |
b2edef6f | 427 | return obj && obj->GetClassInfo()->IsKindOf(classInfo) ? obj : NULL; |
ea1e6c4b RL |
428 | } |
429 | ||
cbca59a8 | 430 | #include "wx/xti2.h" |
2d51f067 | 431 | |
b2edef6f VZ |
432 | // ---------------------------------------------------------------------------- |
433 | // more debugging macros | |
434 | // ---------------------------------------------------------------------------- | |
435 | ||
657a8a35 | 436 | #if wxUSE_DEBUG_NEW_ALWAYS |
70bf6180 VZ |
437 | #define WXDEBUG_NEW new(__TFILE__,__LINE__) |
438 | ||
657a8a35 VZ |
439 | #if wxUSE_GLOBAL_MEMORY_OPERATORS |
440 | #define new WXDEBUG_NEW | |
441 | #elif defined(__VISUALC__) | |
442 | // Including this file redefines new and allows leak reports to | |
443 | // contain line numbers | |
444 | #include "wx/msw/msvcrt.h" | |
445 | #endif | |
446 | #endif // wxUSE_DEBUG_NEW_ALWAYS | |
c801d85f | 447 | |
b19b28c8 | 448 | // ---------------------------------------------------------------------------- |
cbca59a8 | 449 | // Compatibility macro aliases IMPLEMENT group |
b19b28c8 FM |
450 | // ---------------------------------------------------------------------------- |
451 | ||
452 | // deprecated variants _not_ requiring a semicolon after them and without wx prefix. | |
453 | // (note that also some wx-prefixed macro do _not_ require a semicolon because | |
454 | // it's not always possible to force the compire to require it) | |
455 | ||
b19b28c8 FM |
456 | #define IMPLEMENT_DYNAMIC_CLASS(n,b) wxIMPLEMENT_DYNAMIC_CLASS(n,b) |
457 | #define IMPLEMENT_DYNAMIC_CLASS2(n,b1,b2) wxIMPLEMENT_DYNAMIC_CLASS2(n,b1,b2) | |
458 | #define IMPLEMENT_ABSTRACT_CLASS(n,b) wxIMPLEMENT_ABSTRACT_CLASS(n,b) | |
459 | #define IMPLEMENT_ABSTRACT_CLASS2(n,b1,b2) wxIMPLEMENT_ABSTRACT_CLASS2(n,b1,b2) | |
460 | #define IMPLEMENT_CLASS(n,b) wxIMPLEMENT_CLASS(n,b) | |
461 | #define IMPLEMENT_CLASS2(n,b1,b2) wxIMPLEMENT_CLASS2(n,b1,b2) | |
462 | ||
b19b28c8 FM |
463 | #define IMPLEMENT_PLUGGABLE_CLASS(n,b) wxIMPLEMENT_PLUGGABLE_CLASS(n,b) |
464 | #define IMPLEMENT_PLUGGABLE_CLASS2(n,b,b2) wxIMPLEMENT_PLUGGABLE_CLASS2(n,b,b2) | |
465 | #define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(n,b) wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(n,b) | |
466 | #define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(n,b,b2) wxIMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(n,b,b2) | |
467 | #define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(n,b) wxIMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(n,b) | |
468 | #define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(n,b,b2) wxIMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(n,b,b2) | |
469 | #define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(n,b) wxIMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(n,b) | |
470 | #define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(n,b,b2) wxIMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(n,b,b2) | |
471 | ||
472 | #define CLASSINFO(n) wxCLASSINFO(n) | |
473 | ||
c0089c96 | 474 | #endif // _WX_OBJECTH__ |