+template<class Klass, typename CollectionType , typename AddedElementType>
+class WXDLLIMPEXP_BASE wxPropertyCollectionAccessorT : public wxPropertyAccessor
+{
+public:
+
+ typedef void (Klass::*adder_t)(AddedElementType value);
+ typedef const CollectionType& (Klass::*getter_t)() const ;
+
+ wxPropertyCollectionAccessorT(adder_t adder, getter_t getter, const wxChar *a, const wxChar *g)
+ : m_getter(getter), m_adder(adder) { m_adderName = a;m_getterName=g ;}
+
+ ~wxPropertyCollectionAccessorT() {}
+
+ // returns true if this accessor has a setter
+ bool HasSetter() const { return false ;}
+
+ // return true if this accessor has a getter
+ bool HasGetter() const { return m_getter != NULL ;}
+
+ // return true if this accessor has a getter
+ bool HasAdder() const { return m_adder != NULL ;}
+
+ // set the property this accessor is responsible for in an object
+ void AddToPropertyCollection(wxObject *o, const wxxVariant &v) const
+ {
+ Klass *obj = dynamic_cast<Klass*>(o);
+ AddedElementType value ;
+
+ if ( wxGetTypeInfo((AddedElementType*)NULL)->GetKind() == wxT_OBJECT && v.GetTypeInfo()->GetKind() == wxT_OBJECT_PTR )
+ value = *v.Get<AddedElementType*>();
+ else
+ value = v.Get<AddedElementType>();
+
+ if (m_adder)
+ (obj->*(m_adder))(value);
+ else
+ {
+ wxASSERT_MSG(0 , wxT("SetPropertyCalled without a valid Setter") ) ;
+ }
+ }
+
+ // gets the property this accessor is responsible for from an object
+ wxxVariantArray GetPropertyCollection(const wxObject *o) const
+ {
+ const Klass *obj = dynamic_cast<const Klass*>(o);
+
+ wxxVariantArray result ;
+ CollectionType::compatibility_iterator current = (obj->*(m_getter))().GetFirst();
+ while (current)
+ {
+ result.Add( new wxxVariant(current->GetData()) ) ;
+ current = current->GetNext();
+ }
+ return result ;
+ }
+
+
+ // set the property this accessor is responsible for in an object
+ void SetProperty(wxObject *WXUNUSED(o), const wxxVariant &WXUNUSED(v)) const
+ {
+ wxASSERT_MSG(0,wxT("SetProperty called on Collection Property")) ;
+ }
+
+ // gets the property this accessor is responsible for from an object
+ wxxVariant GetProperty(const wxObject *WXUNUSED(o)) const
+ {
+ wxASSERT_MSG(0,wxT("GetProperty called on Collection Property")) ;
+ return wxxVariant() ;
+ }
+
+ // write the property this accessor is responsible for from an object into
+ // a string
+ void WriteValue( wxString& s , const wxObject *o ) const
+ {
+ wxASSERT_MSG(0,wxT("WriteValue called on Collection Property")) ;
+ }
+
+ // read a wxxVariant having the correct type for the property this accessor
+ // is responsible for from a string
+ wxxVariant ReadValue( const wxString &value ) const
+ {
+ wxASSERT_MSG(0,wxT("ReadValue called on Collection Property")) ;
+ return wxxVariant() ;
+ }
+
+private :
+ getter_t m_getter;
+ adder_t m_adder;
+};
+