+// ----------------------------------------------------------------------------
+// wxObjectWriterCallback
+//
+// This class will be asked during the streaming-out process about every single
+// property or object instance. It can veto streaming out by returning false
+// or modify the value before it is streamed-out.
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxObjectWriter;
+class WXDLLIMPEXP_BASE wxObjectReader;
+class WXDLLIMPEXP_BASE wxClassInfo;
+class WXDLLIMPEXP_BASE wxAnyList;
+class WXDLLIMPEXP_BASE wxPropertyInfo;
+class WXDLLIMPEXP_BASE wxAny;
+class WXDLLIMPEXP_BASE wxObjectWriter;
+class WXDLLIMPEXP_BASE wxHandlerInfo;
+
+class WXDLLIMPEXP_BASE wxObjectWriterCallback
+{
+public:
+ virtual ~wxObjectWriterCallback() {}
+
+ // will be called before an object is written, may veto by returning false
+ virtual bool BeforeWriteObject( wxObjectWriter *WXUNUSED(writer),
+ const wxObject *WXUNUSED(object),
+ const wxClassInfo *WXUNUSED(classInfo),
+ const wxStringToAnyHashMap &WXUNUSED(metadata))
+ { return true; }
+
+ // will be called after this object has been written, may be
+ // needed for adjusting stacks
+ virtual void AfterWriteObject( wxObjectWriter *WXUNUSED(writer),
+ const wxObject *WXUNUSED(object),
+ const wxClassInfo *WXUNUSED(classInfo) )
+ {}
+
+ // will be called before a property gets written, may change the value,
+ // eg replace a concrete wxSize by wxSize( wxDefaultCoord, wxDefaultCoord )
+ // or veto writing that property at all by returning false
+ virtual bool BeforeWriteProperty( wxObjectWriter *WXUNUSED(writer),
+ const wxObject *WXUNUSED(object),
+ const wxPropertyInfo *WXUNUSED(propInfo),
+ const wxAny &WXUNUSED(value) )
+ { return true; }
+
+ // will be called before a property gets written, may change the value,
+ // eg replace a concrete wxSize by wxSize( wxDefaultCoord, wxDefaultCoord )
+ // or veto writing that property at all by returning false
+ virtual bool BeforeWriteProperty( wxObjectWriter *WXUNUSED(writer),
+ const wxObject *WXUNUSED(object),
+ const wxPropertyInfo *WXUNUSED(propInfo),
+ const wxAnyList &WXUNUSED(value) )
+ { return true; }
+
+ // will be called after a property has been written out, may be needed
+ // for adjusting stacks
+ virtual void AfterWriteProperty( wxObjectWriter *WXUNUSED(writer),
+ const wxPropertyInfo *WXUNUSED(propInfo) )
+ {}
+
+ // will be called before this delegate gets written
+ virtual bool BeforeWriteDelegate( wxObjectWriter *WXUNUSED(writer),
+ const wxObject *WXUNUSED(object),
+ const wxClassInfo* WXUNUSED(classInfo),
+ const wxPropertyInfo *WXUNUSED(propInfo),
+ const wxObject *&WXUNUSED(eventSink),
+ const wxHandlerInfo* &WXUNUSED(handlerInfo) )
+ { return true; }
+
+ virtual void AfterWriteDelegate( wxObjectWriter *WXUNUSED(writer),
+ const wxObject *WXUNUSED(object),
+ const wxClassInfo* WXUNUSED(classInfo),
+ const wxPropertyInfo *WXUNUSED(propInfo),
+ const wxObject *&WXUNUSED(eventSink),
+ const wxHandlerInfo* &WXUNUSED(handlerInfo) )
+ { }
+};
+
+class WXDLLIMPEXP_BASE wxObjectWriterFunctor: public wxObjectFunctor
+{
+};
+
+class WXDLLIMPEXP_BASE wxObjectWriter: public wxObject
+{
+ friend class wxObjectWriterFunctor;
+public:
+ wxObjectWriter();
+ virtual ~wxObjectWriter();
+
+ // with this call you start writing out a new top-level object
+ void WriteObject(const wxObject *object, const wxClassInfo *classInfo,
+ wxObjectWriterCallback *writercallback, const wxString &name,
+ const wxStringToAnyHashMap &metadata);
+
+ // Managing the object identity table a.k.a context
+ //
+ // these methods make sure that no object gets written twice,
+ // because sometimes multiple calls to the WriteObject will be
+ // made without wanting to have duplicate objects written, the
+ // object identity table will be reset manually
+ virtual void ClearObjectContext();
+
+ // gets the object Id for a passed in object in the context
+ int GetObjectID(const wxObject *obj);
+
+ // returns true if this object has already been written in this context
+ bool IsObjectKnown( const wxObject *obj );
+
+ //
+ // streaming callbacks
+ //
+ // these callbacks really write out the values in the stream format
+
+ // begins writing out a new toplevel entry which has the indicated unique name
+ virtual void DoBeginWriteTopLevelEntry( const wxString &name ) = 0;
+
+ // ends writing out a new toplevel entry which has the indicated unique name
+ virtual void DoEndWriteTopLevelEntry( const wxString &name ) = 0;
+
+ // start of writing an object having the passed in ID
+ virtual void DoBeginWriteObject(const wxObject *object, const wxClassInfo *classInfo,
+ int objectID, const wxStringToAnyHashMap &metadata ) = 0;
+
+ // end of writing an toplevel object name param is used for unique
+ // identification within the container
+ virtual void DoEndWriteObject(const wxObject *object,
+ const wxClassInfo *classInfo, int objectID ) = 0;
+
+ // writes a simple property in the stream format
+ virtual void DoWriteSimpleType( const wxAny &value ) = 0;
+
+ // start of writing a complex property into the stream (
+ virtual void DoBeginWriteProperty( const wxPropertyInfo *propInfo ) = 0;
+
+ // end of writing a complex property into the stream
+ virtual void DoEndWriteProperty( const wxPropertyInfo *propInfo ) = 0;
+
+ virtual void DoBeginWriteElement() = 0;
+ virtual void DoEndWriteElement() = 0;
+ // insert an object reference to an already written object
+ virtual void DoWriteRepeatedObject( int objectID ) = 0;
+
+ // insert a null reference
+ virtual void DoWriteNullObject() = 0;
+
+ // writes a delegate in the stream format
+ virtual void DoWriteDelegate( const wxObject *object, const wxClassInfo* classInfo,
+ const wxPropertyInfo *propInfo, const wxObject *eventSink,
+ int sinkObjectID, const wxClassInfo* eventSinkClassInfo,
+ const wxHandlerInfo* handlerIndo ) = 0;
+
+ void WriteObject(const wxObject *object, const wxClassInfo *classInfo,
+ wxObjectWriterCallback *writercallback, bool isEmbedded, const wxStringToAnyHashMap &metadata );
+
+protected:
+ struct wxObjectWriterInternal;
+ wxObjectWriterInternal* m_data;
+
+ struct wxObjectWriterInternalPropertiesData;
+
+ void WriteAllProperties( const wxObject * obj, const wxClassInfo* ci,
+ wxObjectWriterCallback *writercallback,
+ wxObjectWriterInternalPropertiesData * data );
+
+ void WriteOneProperty( const wxObject *obj, const wxClassInfo* ci,
+ const wxPropertyInfo* pi, wxObjectWriterCallback *writercallback,
+ wxObjectWriterInternalPropertiesData *data );
+
+
+ void FindConnectEntry(const wxEvtHandler * evSource,
+ const wxEventSourceTypeInfo* dti, const wxObject* &sink,
+ const wxHandlerInfo *&handler);
+};
+