]> git.saurik.com Git - wxWidgets.git/blob - include/wx/xtistrm.h
deprecated Initialize/CleanUpClasses
[wxWidgets.git] / include / wx / xtistrm.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/xtistrm.h
3 // Purpose: streaming runtime metadata information (extended class info)
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 27/07/03
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_XTISTRMH__
13 #define _WX_XTISTRMH__
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "xtistrm.h"
17 #endif
18
19 #include "wx/wx.h"
20
21 #if wxUSE_EXTENDED_RTTI
22
23 const int wxInvalidObjectID = -2 ;
24 const int wxNullObjectID = -1 ;
25
26 // Filer contains the interfaces for streaming objects in and out of XML,
27 // rendering them either to objects in memory, or to code. Note: We
28 // consider the process of generating code to be one of *depersisting* the
29 // object from xml, *not* of persisting the object to code from an object
30 // in memory. This distincation can be confusing, and should be kept
31 // in mind when looking at the property streamers and callback interfaces
32 // listed below.
33
34 /*
35 Main interface for streaming out an object to XML.
36 */
37
38 void WriteComponent(wxObject *Object, const wxClassInfo *ClassInfo, wxXmlNode *parent, const wxString& nodeName );
39
40 /*
41 Streaming callbacks for depersisting XML to code, or running objects
42 */
43
44 class wxDepersister ;
45
46 /*
47 wxReader handles streaming in a class from a arbitrary format. While walking through
48 it issues calls out to interfaces to depersist the guts from the underlying storage format.
49 */
50
51 class wxReader : public wxObject
52 {
53 public :
54 wxReader() ;
55 ~wxReader() ;
56 // the only thing wxReader knows about is the class info by object ID
57 wxClassInfo *GetObjectClassInfo(int objectID) ;
58 bool HasObjectClassInfo( int objectID ) ;
59 void SetObjectClassInfo(int objectID, wxClassInfo* classInfo);
60
61 // Reads the component the reader is pointed at from the underlying format.
62 // The return value is the root object ID, which can
63 // then be used to ask the depersister about that object
64 virtual int ReadObject( wxDepersister *depersist ) = 0 ;
65
66 private :
67 struct wxReaderInternal;
68 wxReaderInternal *m_data;
69 } ;
70
71 /*
72 wxXmlReader handles streaming in a class from XML
73 */
74
75 class wxXmlReader : public wxReader
76 {
77 public:
78 wxXmlReader(wxXmlNode *parent) { m_parent = parent ; }
79 ~wxXmlReader() {}
80
81 // Reads a component from XML. The return value is the root object ID, which can
82 // then be used to ask the depersister about that object
83
84 int ReadObject(wxDepersister *callbacks);
85
86 private :
87 int ReadComponent(wxXmlNode *parent, wxDepersister *callbacks);
88
89 // accessor is only used as a temporary measure
90 wxxVariant ReadValue(wxXmlNode *Node,
91 wxPropertyAccessor *accessor );
92
93 wxXmlNode * m_parent ;
94 };
95
96 // This abstract class matches the allocate-init/create model of creation of objects.
97 // At runtime, these will create actual instances, and manipulate them.
98 // When generating code, these will just create statements of C++
99 // code to create the objects.
100
101 class wxDepersister
102 {
103 public :
104 // allocate the new object on the heap, that object will have the passed in ID
105 virtual void AllocateObject(int ObjectID, wxClassInfo *ClassInfo) = 0;
106
107 // initialize the already allocated object having the ID ObjectID with the Create method
108 // creation parameters which are objects are having their Ids passed in objectIDValues
109 // having objectId <> wxInvalidObjectID
110
111 virtual void CreateObject(int ObjectID,
112 const wxClassInfo *ClassInfo,
113 int ParamCount,
114 wxxVariant *VariantValues ,
115 int *objectIDValues ,
116 const wxClassInfo **objectClassInfos
117 ) = 0;
118
119 // destroy the heap-allocated object having the ID ObjectID, this may be used if an object
120 // is embedded in another object and set via value semantics, so the intermediate
121 // object can be destroyed after safely
122 virtual void DestroyObject(int ObjectID, wxClassInfo *ClassInfo) = 0;
123
124 // set the corresponding property
125 virtual void SetProperty(int ObjectID,
126 const wxClassInfo *ClassInfo,
127 const wxPropertyInfo* PropertyInfo ,
128 const wxxVariant &VariantValue) = 0;
129
130 // sets the corresponding property (value is an object)
131 virtual void SetPropertyAsObject(int ObjectId,
132 const wxClassInfo *ClassInfo,
133 const wxPropertyInfo* PropertyInfo ,
134 int valueObjectId) = 0;
135
136
137 // sets the corresponding event handler
138 virtual void SetConnect(int EventSourceObjectID,
139 const wxClassInfo *EventSourceClassInfo,
140 const wxDelegateTypeInfo *delegateInfo ,
141 const wxClassInfo *EventSinkClassInfo ,
142 const wxHandlerInfo* handlerInfo ,
143 int EventSinkObjectID ) = 0;
144 };
145
146 /*
147 wxRuntimeDepersister implements the callbacks that will depersist
148 an object into a running memory image, as opposed to writing
149 C++ initialization code to bring the object to life.
150 */
151 class wxRuntimeDepersister : public wxDepersister
152 {
153 struct wxRuntimeDepersisterInternal ;
154 wxRuntimeDepersisterInternal * m_data ;
155 public :
156 wxRuntimeDepersister() ;
157 ~wxRuntimeDepersister() ;
158
159 // returns the object having the corresponding ID fully constructed
160 wxObject *GetObject(int objectID) ;
161
162 // allocate the new object on the heap, that object will have the passed in ID
163 virtual void AllocateObject(int objectID, wxClassInfo *classInfo) ;
164
165 // initialize the already allocated object having the ID ObjectID with the Create method
166 // creation parameters which are objects are having their Ids passed in objectIDValues
167 // having objectId <> wxInvalidObjectID
168
169 virtual void CreateObject(int ObjectID,
170 const wxClassInfo *ClassInfo,
171 int ParamCount,
172 wxxVariant *VariantValues ,
173 int *objectIDValues,
174 const wxClassInfo **objectClassInfos
175 ) ;
176
177 // destroy the heap-allocated object having the ID ObjectID, this may be used if an object
178 // is embedded in another object and set via value semantics, so the intermediate
179 // object can be destroyed after safely
180 virtual void DestroyObject(int objectID, wxClassInfo *classInfo) ;
181
182 // set the corresponding property
183 virtual void SetProperty(int objectID,
184 const wxClassInfo *classInfo,
185 const wxPropertyInfo* propertyInfo ,
186 const wxxVariant &variantValue);
187
188 // sets the corresponding property (value is an object)
189 virtual void SetPropertyAsObject(int objectId,
190 const wxClassInfo *classInfo,
191 const wxPropertyInfo* propertyInfo ,
192 int valueObjectId) ;
193
194
195 // sets the corresponding event handler
196 virtual void SetConnect(int eventSourceObjectID,
197 const wxClassInfo *eventSourceClassInfo,
198 const wxDelegateTypeInfo *delegateInfo ,
199 const wxClassInfo *eventSinkClassInfo ,
200 const wxHandlerInfo* handlerInfo ,
201 int eventSinkObjectID ) ;
202 };
203
204 /*
205 wxDepersisterCode implements the callbacks that will depersist
206 an object into a C++ initialization function.
207 */
208
209 class wxTextOutputStream ;
210
211 class wxCodeDepersister : public wxDepersister
212 {
213 private :
214 struct wxCodeDepersisterInternal ;
215 wxCodeDepersisterInternal * m_data ;
216 wxTextOutputStream *m_fp;
217 wxString ValueAsCode( const wxxVariant &param ) ;
218 public:
219 wxCodeDepersister(wxTextOutputStream *out) ;
220 ~wxCodeDepersister() ;
221
222 // allocate the new object on the heap, that object will have the passed in ID
223 virtual void AllocateObject(int objectID, wxClassInfo *classInfo) ;
224
225 // initialize the already allocated object having the ID ObjectID with the Create method
226 // creation parameters which are objects are having their Ids passed in objectIDValues
227 // having objectId <> wxInvalidObjectID
228
229 virtual void CreateObject(int objectID,
230 const wxClassInfo *classInfo,
231 int paramCount,
232 wxxVariant *variantValues ,
233 int *objectIDValues,
234 const wxClassInfo **objectClassInfos
235 ) ;
236
237 // destroy the heap-allocated object having the ID ObjectID, this may be used if an object
238 // is embedded in another object and set via value semantics, so the intermediate
239 // object can be destroyed after safely
240 virtual void DestroyObject(int objectID, wxClassInfo *classInfo) ;
241
242 // set the corresponding property
243 virtual void SetProperty(int objectID,
244 const wxClassInfo *classInfo,
245 const wxPropertyInfo* propertyInfo ,
246 const wxxVariant &variantValue);
247
248 // sets the corresponding property (value is an object)
249 virtual void SetPropertyAsObject(int objectId,
250 const wxClassInfo *classInfo,
251 const wxPropertyInfo* propertyInfo ,
252 int valueObjectId) ;
253
254
255 // sets the corresponding event handler
256 virtual void SetConnect(int eventSourceObjectID,
257 const wxClassInfo *eventSourceClassInfo,
258 const wxDelegateTypeInfo *delegateInfo ,
259 const wxClassInfo *eventSinkClassInfo ,
260 const wxHandlerInfo* handlerInfo ,
261 int eventSinkObjectID ) ;
262 };
263
264 #endif // wxUSE_EXTENDED_RTTI
265
266 #endif