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) ; \
}
// ----------------------------------------------------------------------------
// 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<typename T>
-void wxStringReadValue( const wxString &s , T &data ) ;
+void wxStringReadValue( const wxString &s , T &data );
template<typename T>
-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<typename T>
-void wxXmlReadValue( wxXmlNode *node , T &data )
-{
- wxStringReadValue<T>( wxXmlGetContentFromNode( node ) , data ) ;
-}
+// sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs
-template<typename T>
-void wxXmlWriteValue( wxXmlNode *node , const T &data)
-{
- wxString s ;
- wxStringWriteValue<T>( 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
// 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 ;
// 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 ) ; }
// 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
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<typename T>
-void wxXmlReadValue( wxXmlNode *node , T &data ) ;
-
-template<typename T>
-void wxXmlWriteValue( wxXmlNode *node , const T &data) ;
-
template<class Klass, typename T>
class WXDLLIMPEXP_BASE wxPropertyAccessorT : public wxPropertyAccessor
{
}
// 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
}
private :
- wxxVariantDataT<T>* DoGetProperty(wxObject *o) const
+ wxxVariantDataT<T>* DoGetProperty(const wxObject *o) const
{
- Klass *obj = dynamic_cast<Klass*>(o);
+ const Klass *obj = dynamic_cast<const Klass*>(o);
if ( m_getter )
return new wxxVariantDataT<T>( (obj->*(m_getter))() ) ;
else
m_variantOfPtrToObjectConverter( _PtrConverter1 ) , m_variantToObjectConverter( _Converter2 ) , m_objectToVariantConverter( _Converter3 ) , m_next(sm_first)
{
sm_first = this;
- Register( m_className , this ) ;
+ Register() ;
}
virtual ~wxClassInfo() ;
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 ; }
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 ) ;
}
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)
};
{ 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) \
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 ; }
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 ; }
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
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) \
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) \
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 ) \