X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fa08490f100a6b61161fbe8fd70201c6b194c20b..10da6a8fa4bcff9a1d6ff09012cd70ad7df38f94:/include/wx/xti.h diff --git a/include/wx/xti.h b/include/wx/xti.h index 002d4ce639..6fd7bee0d8 100644 --- a/include/wx/xti.h +++ b/include/wx/xti.h @@ -117,6 +117,15 @@ private : template<> void wxStringWriteValue(wxString &s , const e &data ) \ { \ s = s_enumData##e.GetEnumMemberName((int)data) ; \ + } \ + template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; assert(0) ; return &s_typeInfo ; } \ + template<> void wxStringReadValue(const wxString& , e* & ) \ + { \ + assert(0) ; \ + } \ + template<> void wxStringWriteValue(wxString &s , e* const & ) \ + { \ + assert(0) ; \ } // ---------------------------------------------------------------------------- @@ -304,45 +313,24 @@ template const wxTypeInfo* wxGetTypeInfo( wxSet * ) // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type #define WX_CUSTOM_TYPE_INFO( e ) \ - template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e) ; return &s_typeInfo ; } \ - -// ---------------------------------------------------------------------------- -// value streaming -// -// streaming is defined for xml constructs right now, the aim is to make this -// pluggable in the future -// ---------------------------------------------------------------------------- - -// convenience function (avoids including xml headers in users code) - -class wxXmlNode ; -void wxXmlAddContentToNode( wxXmlNode* node , const wxString& data ) ; -wxString wxXmlGetContentFromNode( wxXmlNode *node ) ; + template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \ + template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e) ; return &s_typeInfo ; } // templated streaming, every type must have their specialization for these methods template -void wxStringReadValue( const wxString &s , T &data ) ; +void wxStringReadValue( const wxString &s , T &data ); template -void wxStringWriteValue( wxString &s , const T &data) ; +void wxStringWriteValue( wxString &s , const T &data); -// for simple types this default implementation is ok, composited structures will have to -// loop through their properties - -template -void wxXmlReadValue( wxXmlNode *node , T &data ) -{ - wxStringReadValue( wxXmlGetContentFromNode( node ) , data ) ; -} +// sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs -template -void wxXmlWriteValue( wxXmlNode *node , const T &data) -{ - wxString s ; - wxStringWriteValue( s, data ) ; - wxXmlAddContentToNode( node ,s ) ; -} +#define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \ +template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \ + static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \ +template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\ +template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; } // ---------------------------------------------------------------------------- // wxxVariant as typesafe data holder @@ -359,12 +347,6 @@ public: // returns the type info of the contentc virtual const wxTypeInfo* GetTypeInfo() const = 0 ; - // write the value into an xml node - virtual void Write( wxXmlNode* node ) const = 0 ; - - // read the value from the xml node - virtual void Read( wxXmlNode* node ) = 0 ; - // write the value into a string virtual void Write( wxString &s ) const = 0 ; @@ -393,12 +375,6 @@ public: // returns the type info of the contentc virtual const wxTypeInfo* GetTypeInfo() const { return wxGetTypeInfo( (T*) NULL ) ; } - // write the value into an xml node - virtual void Write( wxXmlNode* node ) const { wxXmlWriteValue( node , m_data ) ; } - - // read the value from the xml node - virtual void Read( wxXmlNode* node ) { wxXmlReadValue( node , m_data ) ; } - // write the value into a string virtual void Write( wxString &s ) const { wxStringWriteValue( s , m_data ) ; } @@ -456,13 +432,7 @@ public : // get the typeinfo of the stored object const wxTypeInfo* GetTypeInfo() const { return m_data->GetTypeInfo() ; } - // write the value into an xml node - void Write( wxXmlNode* node ) const { m_data->Write( node ) ; } - - // read the value from the xml node - void Read( wxXmlNode* node ) { m_data->Read( node ) ; } - - // write the value into a string + // write the value into a string void Write( wxString &s ) const { m_data->Write( s ) ; } // read the value from a string @@ -503,26 +473,18 @@ public : class SetAndGetByRefRetBool ; class GetByRef ; virtual void SetProperty(wxObject *object, const wxxVariant &value) const = 0 ; - virtual wxxVariant GetProperty(wxObject *object) const = 0 ; + virtual wxxVariant GetProperty(const wxObject *object) const = 0 ; virtual bool HasSetter() const = 0 ; virtual bool HasGetter() const = 0 ; const wxChar * GetGetterName() const { return m_setterName ; } const wxChar * GetSetterName() const { return m_getterName ; } - virtual wxxVariant ReadValue( wxXmlNode* node ) const = 0 ; - virtual void WriteValue( wxXmlNode* node , wxObject *o ) const = 0 ; virtual wxxVariant ReadValue( const wxString &value ) const = 0 ; - virtual void WriteValue( wxString& value , wxObject *o ) const = 0 ; + virtual void WriteValue( wxString& value , const wxObject *o ) const = 0 ; protected : const wxChar *m_setterName ; const wxChar *m_getterName ; }; -template -void wxXmlReadValue( wxXmlNode *node , T &data ) ; - -template -void wxXmlWriteValue( wxXmlNode *node , const T &data) ; - template class WXDLLIMPEXP_BASE wxPropertyAccessorT : public wxPropertyAccessor { @@ -601,34 +563,18 @@ public: } // gets the property this accessor is responsible for from an object - wxxVariant GetProperty(wxObject *o) const + wxxVariant GetProperty(const wxObject *o) const { return wxxVariant( (wxxVariantData* ) DoGetProperty( o ) ) ; } - // write the property this accessor is responsible for from an object into - // a xml node - void WriteValue( wxXmlNode* node , wxObject *o ) const - { - DoGetProperty( o )->Write( node ) ; - } - // write the property this accessor is responsible for from an object into // a string - void WriteValue( wxString& s , wxObject *o ) const + void WriteValue( wxString& s , const wxObject *o ) const { DoGetProperty( o )->Write( s ) ; } - // read a wxxVariant having the correct type for the property this accessor - // is responsible for from an xml node - wxxVariant ReadValue( wxXmlNode* node ) const - { - T data ; - wxXmlReadValue( node , data ) ; - return wxxVariant( data ) ; - } - // read a wxxVariant having the correct type for the property this accessor // is responsible for from a string wxxVariant ReadValue( const wxString &value ) const @@ -639,9 +585,9 @@ public: } private : - wxxVariantDataT* DoGetProperty(wxObject *o) const + wxxVariantDataT* DoGetProperty(const wxObject *o) const { - Klass *obj = dynamic_cast(o); + const Klass *obj = dynamic_cast(o); if ( m_getter ) return new wxxVariantDataT( (obj->*(m_getter))() ) ; else @@ -1011,7 +957,7 @@ public: m_variantOfPtrToObjectConverter( _PtrConverter1 ) , m_variantToObjectConverter( _Converter2 ) , m_objectToVariantConverter( _Converter3 ) , m_next(sm_first) { sm_first = this; - Register( m_className , this ) ; + Register() ; } virtual ~wxClassInfo() ; @@ -1046,16 +992,14 @@ public: return false ; } +#ifdef WXWIN_COMPATIBILITY_2_4 // Initializes parent pointers and hash table for fast searching. - // this is going to be removed by Register/Unregister calls - // in Constructor / Destructor together with making the hash map private - - static void InitializeClasses(); - + wxDEPRECATED( static void InitializeClasses() ); // Cleans up hash table used for fast searching. - - static void CleanUpClasses(); - + wxDEPRECATED( static void CleanUpClasses() ); +#endif + static void CleanUp(); + // returns the first property const wxPropertyInfo* GetFirstProperty() const { return m_firstProperty ; } @@ -1080,9 +1024,9 @@ public: virtual wxxVariant GetProperty (wxObject *object, const wxChar *PropertyName); // we must be able to cast variants to wxObject pointers, templates seem not to be suitable - wxObject* VariantToInstance( wxxVariant &data ) const + wxObject* VariantToInstance( wxxVariant &data ) const { if ( data.GetTypeInfo()->GetKind() == wxT_OBJECT ) - return m_variantToObjectConverter( data ) ; + return m_variantToObjectConverter( data ) ; else return m_variantOfPtrToObjectConverter( data ) ; } @@ -1125,13 +1069,14 @@ private: const wxPropertyAccessor *FindAccessor (const wxChar *propertyName); - // registers the class - static void Register(const wxChar *name, wxClassInfo *info); - - static void Unregister(const wxChar *name); // InitializeClasses() helper static wxClassInfo *GetBaseByName(const wxChar *name); + +protected: + // registers the class + void Register(); + void Unregister(); DECLARE_NO_COPY_CLASS(wxClassInfo) }; @@ -1152,10 +1097,10 @@ WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxChar *name); { return &name::sm_class##name; } #define DECLARE_DYNAMIC_CLASS(name) \ - _DECLARE_DYNAMIC_CLASS(name) \ - static wxConstructorBridge* sm_constructor##name ; \ - static const wxChar * sm_constructorProperties##name[] ; \ - static const int sm_constructorPropertiesCount##name ; +static wxConstructorBridge* sm_constructor##name ; \ +static const wxChar * sm_constructorProperties##name[] ; \ +static const int sm_constructorPropertiesCount##name ; \ + _DECLARE_DYNAMIC_CLASS(name) #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \ DECLARE_NO_ASSIGN_CLASS(name) \ @@ -1189,6 +1134,9 @@ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVaria template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\ template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } @@ -1208,6 +1156,9 @@ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVaria template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\ template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } @@ -1240,6 +1191,10 @@ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit ) 0 , 0 , 0 ); \ template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ + template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } // this is for subclasses that still do not derive from wxobject @@ -1253,8 +1208,13 @@ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit ) 0 , 0 , 0 ); \ template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ + template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } + // Multiple inheritance with two base classes #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \ @@ -1270,6 +1230,10 @@ _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit ) name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \ template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \ + template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \ @@ -1299,7 +1263,11 @@ wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVaria 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \ template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ - template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } + template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\ + template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \ + template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \ + template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \ _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \