]>
Commit | Line | Data |
---|---|---|
bd9396d5 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: No names yet. | |
3 | // Purpose: Contrib. demo | |
4 | // Author: Aleksandras Gluchovas | |
5 | // Modified by: | |
6 | // Created: 26/10/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef __PF_SAMPLE_G__ | |
13 | #define __PF_SAMPLE_G__ | |
14 | ||
15 | #include "objstore.h" | |
16 | ||
17 | // forward decl. | |
18 | class classA; | |
19 | class classB; | |
20 | ||
21 | // sample classes | |
22 | ||
23 | class notStorableClass | |
24 | {}; | |
25 | ||
26 | class classA : public wxObject | |
27 | { | |
28 | DECLARE_DYNAMIC_CLASS( classA ) | |
29 | public: | |
30 | ||
31 | int x; | |
32 | classB* mpBObj; | |
33 | notStorableClass* mpBackRef; | |
34 | }; | |
35 | ||
36 | class classB : public wxObject | |
37 | { | |
38 | DECLARE_DYNAMIC_CLASS( classB ) | |
39 | public: | |
40 | ||
41 | int y; | |
42 | classA* mpAObj; | |
43 | notStorableClass* mpBackRef; | |
44 | }; | |
45 | ||
46 | // serialization handlers for the above classes | |
47 | ||
48 | class classASerializer : public wxSerializerBase | |
49 | { | |
50 | DECLARE_SERIALIZER_CLASS( classASerializer ) | |
51 | ||
52 | static void Serialize( wxObject* pObj, wxObjectStorage& store ) | |
53 | { | |
54 | classA* pA = (classA*)pObj; // cast | |
55 | ||
56 | store.XchgInt ( pA->x ); | |
57 | store.XchgObjPtr( (wxObject**) &(pA->mpBObj) ); | |
58 | store.XchgObjPtr( (wxObject**) &(pA->mpBackRef) ); | |
59 | } | |
60 | }; | |
61 | ||
62 | class classBSerializer : public wxSerializerBase | |
63 | { | |
64 | DECLARE_SERIALIZER_CLASS( classBSerializer ) | |
65 | ||
66 | static void Serialize( wxObject* pObj, wxObjectStorage& store ) | |
67 | { | |
68 | classB* pB = (classB*)pObj; // cast | |
69 | ||
70 | store.XchgInt ( pB->y ); | |
71 | store.XchgObjPtr( (wxObject**) &(pB->mpAObj) ); | |
72 | store.XchgObjPtr( (wxObject**) &(pB->mpBackRef) ); | |
73 | } | |
74 | }; | |
75 | ||
76 | /*---------------------------*/ | |
77 | /* Main testing function */ | |
78 | /*---------------------------*/ | |
79 | ||
80 | // include this header and .cpp file into any of your | |
81 | // wxWindows projects, and invoke the below function | |
82 | // to peform tests | |
83 | ||
84 | void test_obj_storage(); | |
85 | ||
86 | #endif |