]> git.saurik.com Git - wxWidgets.git/blame - include/wx/xtistrm.h
Use wxUniv textctrl for wxX11
[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
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
8ec1974e
SC
23const int wxInvalidObjectID = -2 ;
24const int wxNullObjectID = -1 ;
25
70e88103
SC
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/*
8ec1974e 35Main interface for streaming out an object to XML.
70e88103
SC
36*/
37
38void WriteComponent(wxObject *Object, const wxClassInfo *ClassInfo, wxXmlNode *parent, const wxString& nodeName );
39
70e88103 40/*
8ec1974e 41Streaming callbacks for depersisting XML to code, or running objects
70e88103
SC
42*/
43
8ec1974e 44class wxDepersister ;
70e88103
SC
45
46/*
8ec1974e
SC
47wxReader handles streaming in a class from a arbitrary format. While walking through
48it issues calls out to interfaces to depersist the guts from the underlying storage format.
70e88103 49*/
8ec1974e
SC
50
51class wxReader : public wxObject
70e88103 52{
8ec1974e
SC
53public :
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
66private :
70e88103 67 struct wxReaderInternal;
8ec1974e
SC
68 wxReaderInternal *m_data;
69} ;
70
71/*
72wxXmlReader handles streaming in a class from XML
73*/
74
75class wxXmlReader : public wxReader
76{
70e88103 77public:
8ec1974e
SC
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
86private :
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 ;
70e88103
SC
94};
95
8ec1974e
SC
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
101class wxDepersister
70e88103 102{
8ec1974e
SC
103public :
104 // allocate the new object on the heap, that object will have the passed in ID
70e88103 105 virtual void AllocateObject(int ObjectID, wxClassInfo *ClassInfo) = 0;
8ec1974e
SC
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
70e88103 111 virtual void CreateObject(int ObjectID,
8ec1974e
SC
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
70e88103 125 virtual void SetProperty(int ObjectID,
8ec1974e
SC
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
70e88103 138 virtual void SetConnect(int EventSourceObjectID,
8ec1974e
SC
139 const wxClassInfo *EventSourceClassInfo,
140 const wxDelegateTypeInfo *delegateInfo ,
141 const wxClassInfo *EventSinkClassInfo ,
142 const wxHandlerInfo* handlerInfo ,
143 int EventSinkObjectID ) = 0;
70e88103
SC
144};
145
146/*
8ec1974e
SC
147wxRuntimeDepersister implements the callbacks that will depersist
148an object into a running memory image, as opposed to writing
149C++ initialization code to bring the object to life.
70e88103 150*/
8ec1974e 151class wxRuntimeDepersister : public wxDepersister
70e88103 152{
8ec1974e
SC
153 struct wxRuntimeDepersisterInternal ;
154 wxRuntimeDepersisterInternal * m_data ;
155public :
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 ) ;
70e88103
SC
202};
203
204/*
8ec1974e
SC
205wxDepersisterCode implements the callbacks that will depersist
206an object into a C++ initialization function.
70e88103
SC
207*/
208
209class wxTextOutputStream ;
210
8ec1974e 211class wxCodeDepersister : public wxDepersister
70e88103 212{
8ec1974e
SC
213private :
214 struct wxCodeDepersisterInternal ;
215 wxCodeDepersisterInternal * m_data ;
216 wxTextOutputStream *m_fp;
217 wxString ValueAsCode( const wxxVariant &param ) ;
70e88103 218public:
8ec1974e
SC
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 ) ;
70e88103
SC
262};
263
264#endif // wxUSE_EXTENDED_RTTI
265
266#endif