]> git.saurik.com Git - wxWidgets.git/blame - include/wx/xtistrm.h
Fix missing or broken interface items for Phoenix
[wxWidgets.git] / include / wx / xtistrm.h
CommitLineData
70e88103
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/xtistrm.h
3// Purpose: streaming runtime metadata information (extended class info)
4// Author: Stefan Csomor
cab1a605 5// Modified by:
70e88103
SC
6// Created: 27/07/03
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Stefan Csomor
65571936 9// Licence: wxWindows licence
70e88103
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_XTISTRMH__
13#define _WX_XTISTRMH__
14
28953245 15#include "wx/defs.h"
70e88103
SC
16
17#if wxUSE_EXTENDED_RTTI
18
28953245
SC
19#include "wx/object.h"
20
21const int wxInvalidObjectID = -2;
22const int wxNullObjectID = -3;
8ec1974e 23
70e88103
SC
24// Filer contains the interfaces for streaming objects in and out of XML,
25// rendering them either to objects in memory, or to code. Note: We
26// consider the process of generating code to be one of *depersisting* the
27// object from xml, *not* of persisting the object to code from an object
cbca59a8 28// in memory. This distinction can be confusing, and should be kept
70e88103
SC
29// in mind when looking at the property streamers and callback interfaces
30// listed below.
31
70e88103 32
ab6e4913 33// ----------------------------------------------------------------------------
cbca59a8 34// wxObjectWriterCallback
ab6e4913
SC
35//
36// This class will be asked during the streaming-out process about every single
37// property or object instance. It can veto streaming out by returning false
38// or modify the value before it is streamed-out.
39// ----------------------------------------------------------------------------
40
28953245
SC
41class WXDLLIMPEXP_BASE wxObjectWriter;
42class WXDLLIMPEXP_BASE wxObjectReader;
43class WXDLLIMPEXP_BASE wxClassInfo;
cbca59a8 44class WXDLLIMPEXP_BASE wxAnyList;
28953245 45class WXDLLIMPEXP_BASE wxPropertyInfo;
cbca59a8 46class WXDLLIMPEXP_BASE wxAny;
28953245
SC
47class WXDLLIMPEXP_BASE wxObjectWriter;
48class WXDLLIMPEXP_BASE wxHandlerInfo;
ab6e4913 49
cbca59a8 50class WXDLLIMPEXP_BASE wxObjectWriterCallback
aa8d7c2f 51{
28953245 52public:
cbca59a8 53 virtual ~wxObjectWriterCallback() {}
afc89ff4 54
ab6e4913 55 // will be called before an object is written, may veto by returning false
28953245
SC
56 virtual bool BeforeWriteObject( wxObjectWriter *WXUNUSED(writer),
57 const wxObject *WXUNUSED(object),
58 const wxClassInfo *WXUNUSED(classInfo),
cbca59a8 59 const wxStringToAnyHashMap &WXUNUSED(metadata))
28953245
SC
60 { return true; }
61
62 // will be called after this object has been written, may be
63 // needed for adjusting stacks
64 virtual void AfterWriteObject( wxObjectWriter *WXUNUSED(writer),
65 const wxObject *WXUNUSED(object),
66 const wxClassInfo *WXUNUSED(classInfo) )
67 {}
68
69 // will be called before a property gets written, may change the value,
70 // eg replace a concrete wxSize by wxSize( wxDefaultCoord, wxDefaultCoord )
71 // or veto writing that property at all by returning false
72 virtual bool BeforeWriteProperty( wxObjectWriter *WXUNUSED(writer),
73 const wxObject *WXUNUSED(object),
74 const wxPropertyInfo *WXUNUSED(propInfo),
cbca59a8 75 const wxAny &WXUNUSED(value) )
28953245
SC
76 { return true; }
77
78 // will be called before a property gets written, may change the value,
79 // eg replace a concrete wxSize by wxSize( wxDefaultCoord, wxDefaultCoord )
80 // or veto writing that property at all by returning false
81 virtual bool BeforeWriteProperty( wxObjectWriter *WXUNUSED(writer),
82 const wxObject *WXUNUSED(object),
83 const wxPropertyInfo *WXUNUSED(propInfo),
cbca59a8 84 const wxAnyList &WXUNUSED(value) )
28953245
SC
85 { return true; }
86
87 // will be called after a property has been written out, may be needed
88 // for adjusting stacks
89 virtual void AfterWriteProperty( wxObjectWriter *WXUNUSED(writer),
90 const wxPropertyInfo *WXUNUSED(propInfo) )
91 {}
ab6e4913
SC
92
93 // will be called before this delegate gets written
28953245
SC
94 virtual bool BeforeWriteDelegate( wxObjectWriter *WXUNUSED(writer),
95 const wxObject *WXUNUSED(object),
96 const wxClassInfo* WXUNUSED(classInfo),
97 const wxPropertyInfo *WXUNUSED(propInfo),
98 const wxObject *&WXUNUSED(eventSink),
99 const wxHandlerInfo* &WXUNUSED(handlerInfo) )
100 { return true; }
101
102 virtual void AfterWriteDelegate( wxObjectWriter *WXUNUSED(writer),
103 const wxObject *WXUNUSED(object),
104 const wxClassInfo* WXUNUSED(classInfo),
105 const wxPropertyInfo *WXUNUSED(propInfo),
106 const wxObject *&WXUNUSED(eventSink),
107 const wxHandlerInfo* &WXUNUSED(handlerInfo) )
108 { }
109};
aa8d7c2f 110
cbca59a8
SC
111class WXDLLIMPEXP_BASE wxObjectWriterFunctor: public wxObjectFunctor
112{
113};
114
28953245 115class WXDLLIMPEXP_BASE wxObjectWriter: public wxObject
aa8d7c2f 116{
cbca59a8 117 friend class wxObjectWriterFunctor;
28953245
SC
118public:
119 wxObjectWriter();
120 virtual ~wxObjectWriter();
aa8d7c2f
SC
121
122 // with this call you start writing out a new top-level object
28953245 123 void WriteObject(const wxObject *object, const wxClassInfo *classInfo,
cbca59a8
SC
124 wxObjectWriterCallback *writercallback, const wxString &name,
125 const wxStringToAnyHashMap &metadata);
aa8d7c2f 126
ab6e4913
SC
127 // Managing the object identity table a.k.a context
128 //
28953245
SC
129 // these methods make sure that no object gets written twice,
130 // because sometimes multiple calls to the WriteObject will be
131 // made without wanting to have duplicate objects written, the
132 // object identity table will be reset manually
133 virtual void ClearObjectContext();
2abce515 134
ab6e4913 135 // gets the object Id for a passed in object in the context
28953245 136 int GetObjectID(const wxObject *obj);
aa8d7c2f 137
ab6e4913 138 // returns true if this object has already been written in this context
28953245 139 bool IsObjectKnown( const wxObject *obj );
aa8d7c2f
SC
140
141 //
142 // streaming callbacks
143 //
144 // these callbacks really write out the values in the stream format
aa8d7c2f 145
ab6e4913 146 // begins writing out a new toplevel entry which has the indicated unique name
28953245 147 virtual void DoBeginWriteTopLevelEntry( const wxString &name ) = 0;
ab6e4913
SC
148
149 // ends writing out a new toplevel entry which has the indicated unique name
28953245 150 virtual void DoEndWriteTopLevelEntry( const wxString &name ) = 0;
ab6e4913
SC
151
152 // start of writing an object having the passed in ID
28953245 153 virtual void DoBeginWriteObject(const wxObject *object, const wxClassInfo *classInfo,
cbca59a8 154 int objectID, const wxStringToAnyHashMap &metadata ) = 0;
aa8d7c2f 155
28953245
SC
156 // end of writing an toplevel object name param is used for unique
157 // identification within the container
158 virtual void DoEndWriteObject(const wxObject *object,
159 const wxClassInfo *classInfo, int objectID ) = 0;
ab6e4913
SC
160
161 // writes a simple property in the stream format
cbca59a8 162 virtual void DoWriteSimpleType( const wxAny &value ) = 0;
aa8d7c2f 163
ab6e4913 164 // start of writing a complex property into the stream (
28953245 165 virtual void DoBeginWriteProperty( const wxPropertyInfo *propInfo ) = 0;
aa8d7c2f 166
ab6e4913
SC
167 // end of writing a complex property into the stream
168 virtual void DoEndWriteProperty( const wxPropertyInfo *propInfo ) = 0;
aa8d7c2f 169
28953245
SC
170 virtual void DoBeginWriteElement() = 0;
171 virtual void DoEndWriteElement() = 0;
cab1a605 172 // insert an object reference to an already written object
28953245 173 virtual void DoWriteRepeatedObject( int objectID ) = 0;
aa8d7c2f 174
ab6e4913 175 // insert a null reference
28953245 176 virtual void DoWriteNullObject() = 0;
aa8d7c2f
SC
177
178 // writes a delegate in the stream format
28953245
SC
179 virtual void DoWriteDelegate( const wxObject *object, const wxClassInfo* classInfo,
180 const wxPropertyInfo *propInfo, const wxObject *eventSink,
181 int sinkObjectID, const wxClassInfo* eventSinkClassInfo,
182 const wxHandlerInfo* handlerIndo ) = 0;
183
cbca59a8
SC
184 void WriteObject(const wxObject *object, const wxClassInfo *classInfo,
185 wxObjectWriterCallback *writercallback, bool isEmbedded, const wxStringToAnyHashMap &metadata );
186
187protected:
28953245
SC
188 struct wxObjectWriterInternal;
189 wxObjectWriterInternal* m_data;
190
191 struct wxObjectWriterInternalPropertiesData;
aa8d7c2f 192
28953245 193 void WriteAllProperties( const wxObject * obj, const wxClassInfo* ci,
cbca59a8 194 wxObjectWriterCallback *writercallback,
28953245 195 wxObjectWriterInternalPropertiesData * data );
aa8d7c2f 196
28953245 197 void WriteOneProperty( const wxObject *obj, const wxClassInfo* ci,
cbca59a8 198 const wxPropertyInfo* pi, wxObjectWriterCallback *writercallback,
28953245 199 wxObjectWriterInternalPropertiesData *data );
aa8d7c2f 200
28953245
SC
201
202 void FindConnectEntry(const wxEvtHandler * evSource,
203 const wxEventSourceTypeInfo* dti, const wxObject* &sink,
204 const wxHandlerInfo *&handler);
205};
aa8d7c2f 206
70e88103 207
70e88103 208/*
8ec1974e 209Streaming callbacks for depersisting XML to code, or running objects
70e88103
SC
210*/
211
cbca59a8 212class WXDLLIMPEXP_BASE wxObjectReaderCallback;
70e88103
SC
213
214/*
28953245 215wxObjectReader handles streaming in a class from a arbitrary format.
cbca59a8 216While walking through it issues calls out to interfaces to readercallback
28953245 217the guts from the underlying storage format.
70e88103 218*/
8ec1974e 219
28953245 220class WXDLLIMPEXP_BASE wxObjectReader: public wxObject
70e88103 221{
28953245
SC
222public:
223 wxObjectReader();
224 virtual ~wxObjectReader();
aa8d7c2f 225
28953245
SC
226 // the only thing wxObjectReader knows about is the class info by object ID
227 wxClassInfo *GetObjectClassInfo(int objectID);
228 bool HasObjectClassInfo( int objectID );
8ec1974e
SC
229 void SetObjectClassInfo(int objectID, wxClassInfo* classInfo);
230
cab1a605 231 // Reads the component the reader is pointed at from the underlying format.
8ec1974e
SC
232 // The return value is the root object ID, which can
233 // then be used to ask the depersister about that object
8f2b1cfd
SC
234 // if there was a problem you will get back wxInvalidObjectID and the current
235 // error log will carry the problems encoutered
cbca59a8 236 virtual int ReadObject( const wxString &name, wxObjectReaderCallback *readercallback ) = 0;
8ec1974e 237
28953245
SC
238private:
239 struct wxObjectReaderInternal;
240 wxObjectReaderInternal *m_data;
241};
8ec1974e 242
8ec1974e
SC
243// This abstract class matches the allocate-init/create model of creation of objects.
244// At runtime, these will create actual instances, and manipulate them.
245// When generating code, these will just create statements of C++
246// code to create the objects.
247
cbca59a8 248class WXDLLIMPEXP_BASE wxObjectReaderCallback
70e88103 249{
28953245 250public:
cbca59a8 251 virtual ~wxObjectReaderCallback() {}
afc89ff4 252
8ec1974e 253 // allocate the new object on the heap, that object will have the passed in ID
28953245 254 virtual void AllocateObject(int objectID, wxClassInfo *classInfo,
cbca59a8 255 wxStringToAnyHashMap &metadata) = 0;
8ec1974e 256
16a45a23 257 // initialize the already allocated object having the ID objectID with the Create method
8ec1974e
SC
258 // creation parameters which are objects are having their Ids passed in objectIDValues
259 // having objectId <> wxInvalidObjectID
260
16a45a23
SC
261 virtual void CreateObject(int objectID,
262 const wxClassInfo *classInfo,
263 int paramCount,
cbca59a8 264 wxAny *VariantValues,
28953245
SC
265 int *objectIDValues,
266 const wxClassInfo **objectClassInfos,
cbca59a8 267 wxStringToAnyHashMap &metadata) = 0;
8ec1974e 268
28953245
SC
269 // construct the new object on the heap, that object will have the passed in ID
270 // (for objects that don't support allocate-create type of creation)
271 // creation parameters which are objects are having their Ids passed in
272 // objectIDValues having objectId <> wxInvalidObjectID
583150e3
SC
273
274 virtual void ConstructObject(int objectID,
275 const wxClassInfo *classInfo,
276 int paramCount,
cbca59a8 277 wxAny *VariantValues,
28953245
SC
278 int *objectIDValues,
279 const wxClassInfo **objectClassInfos,
cbca59a8 280 wxStringToAnyHashMap &metadata) = 0;
28953245
SC
281
282 // destroy the heap-allocated object having the ID objectID, this may be used
283 // if an object is embedded in another object and set via value semantics,
284 // so the intermediate object can be destroyed after safely
16a45a23 285 virtual void DestroyObject(int objectID, wxClassInfo *classInfo) = 0;
8ec1974e
SC
286
287 // set the corresponding property
16a45a23
SC
288 virtual void SetProperty(int objectID,
289 const wxClassInfo *classInfo,
28953245 290 const wxPropertyInfo* propertyInfo,
cbca59a8 291 const wxAny &VariantValue) = 0;
8ec1974e
SC
292
293 // sets the corresponding property (value is an object)
16a45a23
SC
294 virtual void SetPropertyAsObject(int objectID,
295 const wxClassInfo *classInfo,
28953245 296 const wxPropertyInfo* propertyInfo,
8ec1974e
SC
297 int valueObjectId) = 0;
298
16a45a23 299 // adds an element to a property collection
28953245 300 virtual void AddToPropertyCollection( int objectID,
16a45a23 301 const wxClassInfo *classInfo,
28953245 302 const wxPropertyInfo* propertyInfo,
cbca59a8 303 const wxAny &VariantValue) = 0;
16a45a23
SC
304
305 // sets the corresponding property (value is an object)
306 virtual void AddToPropertyCollectionAsObject(int objectID,
307 const wxClassInfo *classInfo,
28953245 308 const wxPropertyInfo* propertyInfo,
16a45a23 309 int valueObjectId) = 0;
8ec1974e
SC
310
311 // sets the corresponding event handler
70e88103 312 virtual void SetConnect(int EventSourceObjectID,
8ec1974e 313 const wxClassInfo *EventSourceClassInfo,
28953245
SC
314 const wxPropertyInfo *delegateInfo,
315 const wxClassInfo *EventSinkClassInfo,
316 const wxHandlerInfo* handlerInfo,
8ec1974e 317 int EventSinkObjectID ) = 0;
70e88103
SC
318};
319
320/*
cbca59a8
SC
321wxObjectRuntimeReaderCallback implements the callbacks that will bring back
322an object into a life memory instance
70e88103 323*/
1c263d56 324
cbca59a8 325class WXDLLIMPEXP_BASE wxObjectRuntimeReaderCallback: public wxObjectReaderCallback
70e88103 326{
28953245
SC
327 struct wxObjectRuntimeReaderCallbackInternal;
328 wxObjectRuntimeReaderCallbackInternal * m_data;
329
330public:
331 wxObjectRuntimeReaderCallback();
332 virtual ~wxObjectRuntimeReaderCallback();
8ec1974e 333
cab1a605 334 // returns the object having the corresponding ID fully constructed
28953245 335 wxObject *GetObject(int objectID);
8ec1974e
SC
336
337 // allocate the new object on the heap, that object will have the passed in ID
28953245 338 virtual void AllocateObject(int objectID, wxClassInfo *classInfo,
cbca59a8 339 wxStringToAnyHashMap &metadata);
8ec1974e 340
28953245
SC
341 // initialize the already allocated object having the ID objectID with
342 // the Create method creation parameters which are objects are having
343 // their Ids passed in objectIDValues having objectId <> wxInvalidObjectID
8ec1974e 344
16a45a23
SC
345 virtual void CreateObject(int objectID,
346 const wxClassInfo *classInfo,
347 int paramCount,
cbca59a8 348 wxAny *VariantValues,
8ec1974e 349 int *objectIDValues,
28953245 350 const wxClassInfo **objectClassInfos,
cbca59a8 351 wxStringToAnyHashMap &metadata
28953245 352 );
8ec1974e 353
28953245
SC
354 // construct the new object on the heap, that object will have the
355 // passed in ID (for objects that don't support allocate-create type of
356 // creation) creation parameters which are objects are having their Ids
357 // passed in objectIDValues having objectId <> wxInvalidObjectID
583150e3
SC
358
359 virtual void ConstructObject(int objectID,
360 const wxClassInfo *classInfo,
361 int paramCount,
cbca59a8 362 wxAny *VariantValues,
8ec1974e 363 int *objectIDValues,
28953245 364 const wxClassInfo **objectClassInfos,
cbca59a8 365 wxStringToAnyHashMap &metadata);
583150e3 366
28953245
SC
367 // destroy the heap-allocated object having the ID objectID, this may be
368 // used if an object is embedded in another object and set via value semantics,
369 // so the intermediate object can be destroyed after safely
370 virtual void DestroyObject(int objectID, wxClassInfo *classInfo);
8ec1974e
SC
371
372 // set the corresponding property
373 virtual void SetProperty(int objectID,
374 const wxClassInfo *classInfo,
28953245 375 const wxPropertyInfo* propertyInfo,
cbca59a8 376 const wxAny &variantValue);
8ec1974e
SC
377
378 // sets the corresponding property (value is an object)
379 virtual void SetPropertyAsObject(int objectId,
380 const wxClassInfo *classInfo,
28953245
SC
381 const wxPropertyInfo* propertyInfo,
382 int valueObjectId);
8ec1974e 383
16a45a23 384 // adds an element to a property collection
28953245 385 virtual void AddToPropertyCollection( int objectID,
16a45a23 386 const wxClassInfo *classInfo,
28953245 387 const wxPropertyInfo* propertyInfo,
cbca59a8 388 const wxAny &VariantValue);
16a45a23
SC
389
390 // sets the corresponding property (value is an object)
391 virtual void AddToPropertyCollectionAsObject(int objectID,
392 const wxClassInfo *classInfo,
28953245
SC
393 const wxPropertyInfo* propertyInfo,
394 int valueObjectId);
8ec1974e
SC
395
396 // sets the corresponding event handler
397 virtual void SetConnect(int eventSourceObjectID,
398 const wxClassInfo *eventSourceClassInfo,
28953245
SC
399 const wxPropertyInfo *delegateInfo,
400 const wxClassInfo *eventSinkClassInfo,
401 const wxHandlerInfo* handlerInfo,
402 int eventSinkObjectID );
70e88103
SC
403};
404
405#endif // wxUSE_EXTENDED_RTTI
406
12028905 407#endif