X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c1e2b44010c1a8dcf9bd26c390d1991f6f7e64f..bc55104d9ab0b0b835644f17a152b4fbbfa8c7b9:/include/wx/object.h diff --git a/include/wx/object.h b/include/wx/object.h index 69ad1b9f88..d0eb3167f3 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -84,7 +84,7 @@ public: static const wxClassInfo *GetFirst() { return sm_first; } const wxClassInfo *GetNext() const { return m_next; } static wxClassInfo *FindClass(const wxChar *className); - + // Climb upwards through inheritance hierarchy. // Dual inheritance is catered for. @@ -122,12 +122,17 @@ public: static wxClassInfo *sm_first; wxClassInfo *m_next; + // FIXME: this should be private (currently used directly by way too + // many clients) static wxHashTable *sm_classTable; + +private: + // InitializeClasses() helper + static wxClassInfo *GetBaseByName(const wxChar *name); }; WXDLLEXPORT wxObject *wxCreateDynamicObject(const wxChar *name); - // ---------------------------------------------------------------------------- // Dynamic class macros // ---------------------------------------------------------------------------- @@ -195,31 +200,24 @@ WXDLLEXPORT wxObject *wxCreateDynamicObject(const wxChar *name); #if wxUSE_NESTED_CLASSES -#if 0 -#define _DECLARE_DL_SENTINEL(name) \ - wxPluginSentinel m_pluginsentinel; - -#else - -#define _DECLARE_DL_SENTINEL(name) \ -class name##PluginSentinel { \ -private: \ - static const wxString sm_className; \ -public: \ - name##PluginSentinel(); \ - ~##name##PluginSentinel(); \ -}; \ +#define _DECLARE_DL_SENTINEL(name, exportdecl) \ +class exportdecl name##PluginSentinel { \ +private: \ + static const wxString sm_className; \ +public: \ + name##PluginSentinel(); \ + ~name##PluginSentinel(); \ +}; \ name##PluginSentinel m_pluginsentinel; -#endif #define _IMPLEMENT_DL_SENTINEL(name) \ const wxString name::name##PluginSentinel::sm_className(#name); \ name::name##PluginSentinel::name##PluginSentinel() { \ - wxDLManifestEntry *e = (wxDLManifestEntry*) wxDLManifestEntry::ms_classes.Get(#name); \ + wxPluginLibrary *e = (wxPluginLibrary*) wxPluginLibrary::ms_classes.Get(#name); \ if( e != 0 ) { e->RefObj(); } \ } \ - name::name##PluginSentinel::~##name##PluginSentinel() { \ - wxDLManifestEntry *e = (wxDLManifestEntry*) wxDLManifestEntry::ms_classes.Get(#name); \ + name::name##PluginSentinel::~name##PluginSentinel() { \ + wxPluginLibrary *e = (wxPluginLibrary*) wxPluginLibrary::ms_classes.Get(#name); \ if( e != 0 ) { e->UnrefObj(); } \ } #else @@ -230,21 +228,33 @@ name##PluginSentinel m_pluginsentinel; #endif // wxUSE_NESTED_CLASSES #define DECLARE_PLUGGABLE_CLASS(name) \ - DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name) - + DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name, WXDLLEXPORT) #define DECLARE_ABSTRACT_PLUGGABLE_CLASS(name) \ - DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name) + DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name, WXDLLEXPORT) + +#define DECLARE_USER_EXPORTED_PLUGGABLE_CLASS(name, usergoo) \ + DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name, usergoo) +#define DECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, usergoo) \ + DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name, usergoo) #define IMPLEMENT_PLUGGABLE_CLASS(name, basename) \ IMPLEMENT_DYNAMIC_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name) #define IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) \ IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name) - #define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) \ IMPLEMENT_ABSTRACT_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name) #define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \ IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name) +#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(name, basename) \ + IMPLEMENT_PLUGGABLE_CLASS(name, basename) +#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(name, basename1, basename2) \ + IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) +#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, basename) \ + IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) +#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \ + IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) + #define CLASSINFO(name) (&name::sm_class##name) @@ -269,6 +279,13 @@ name##PluginSentinel m_pluginsentinel; #define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) #define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) +#define DECLARE_USER_EXPORTED_PLUGGABLE_CLASS(name, usergoo) +#define DECLARE_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, usergoo) +#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS(name, basename) +#define IMPLEMENT_USER_EXPORTED_PLUGGABLE_CLASS2(name, basename1, basename2) +#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS(name, basename) +#define IMPLEMENT_USER_EXPORTED_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) + #endif // wxUSE_DYNAMIC_CLASSES @@ -370,18 +387,33 @@ public: virtual void Dump(wxSTD ostream& str); #endif - // make a 'clone' of the object - + // ref counted data handling methods + + // get/set + wxObjectRefData *GetRefData() const { return m_refData; } + void SetRefData(wxObjectRefData *data) { m_refData = data; } + + // make a 'clone' of the object void Ref(const wxObject& clone); - // destroy a reference - + // destroy a reference void UnRef(); - inline wxObjectRefData *GetRefData() const { return m_refData; } - inline void SetRefData(wxObjectRefData *data) { m_refData = data; } - protected: + // ensure that our data is not shared with anybody else: if we have no + // data, it is created using CreateRefData() below, if we have shared data + // it is copied using CloneRefData(), otherwise nothing is done + void AllocExclusive(); + + // both methods must be implemented if Unshare() is used, not pure virtual + // only because of the backwards compatibility reasons + + // create a new m_refData + virtual wxObjectRefData *CreateRefData() const; + + // create a new m_refData initialized with the given one + virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; + wxObjectRefData *m_refData; };