ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/cfperl.h
(Generate patch)

Comparing deliantra/server/include/cfperl.h (file contents):
Revision 1.7 by root, Sat Aug 26 23:36:32 2006 UTC vs.
Revision 1.8 by root, Sun Aug 27 16:15:12 2006 UTC

26 DT_PLAYER, 26 DT_PLAYER,
27 DT_ARCH, 27 DT_ARCH,
28 DT_PARTY, 28 DT_PARTY,
29 DT_REGION, 29 DT_REGION,
30 DT_AV, // av that needs to be flattened out 30 DT_AV, // av that needs to be flattened out
31
32 NUM_DATA_TYPES
31}; 33};
32 34
33enum event_klass 35enum event_klass
34{ 36{
35 KLASS_GLOBAL, 37 KLASS_GLOBAL,
80 void *self, *cb; // CF+ perl self and callback 82 void *self, *cb; // CF+ perl self and callback
81 const char *attach; // generic extension attachment information 83 const char *attach; // generic extension attachment information
82 84
83 void clear (); // called when free'ing objects 85 void clear (); // called when free'ing objects
84 void optimise (); // possibly save some memory by destroying unneeded data 86 void optimise (); // possibly save some memory by destroying unneeded data
85 void reattach (data_type type, void *self); // called after swapin 87
88 void extendable_init ()
89 {
90 self = cb = 0;
91 attach = 0;
92 }
86}; 93};
87 94
88// objects extendable from perl (or any other extension) should include or 95// objects extendable from perl (or any other extension) should include or
89// derive using the curiously recurring template pattern, to avoid 96// derive using the curiously recurring template pattern, to avoid
90// virtual method calls etc. 97// virtual method calls etc.
91template<class subclass> 98template<class subclass>
92struct extendable : extendable_base 99struct extendable : extendable_base
93{ 100{
94 void reattach () 101 static data_type get_dt ()
95 { 102 {
96 if (attach) 103 subclass::get_dt ();
97 extendable_base::reattach (
98 static_cast<subclass *>(this)->get_dt (),
99 static_cast<subclass *>(this)
100 );
101 } 104 }
102}; 105};
103 106
104struct object_freezer 107struct object_freezer
105{ 108{
106 const char *filename; 109 const char *filename;
107 void *av; 110 void *av;
111 int idx;
108 112
109 object_freezer (const char *filename) : filename (filename) { } 113 object_freezer (const char *filename);
114 ~object_freezer ();
115
110 void put (extendable_base *object); 116 void put (extendable_base *ext);
117
118 template<class subclass>
119 void put (extendable<subclass> *obj)
120 {
121 put ((extendable_base *)obj);
122 }
123
111 void finish (); 124 void finish ();
112}; 125};
113 126
114struct object_thawer 127struct object_thawer
115{ 128{
116 void *av; 129 void *av;
130 int idx;
117 131
118 object_thawer (const char *filename); 132 object_thawer (const char *filename = 0);
133 ~object_thawer ();
134
135 void get (data_type type, void *obj, extendable_base *ext);
136
137 template<class subclass>
119 void get (extendable_base *object); 138 void get (extendable<subclass> *obj)
139 {
140 if (av)
141 get (subclass::get_dt (), (subclass *)obj, obj);
142 }
143
120 void finish (); 144 void finish ();
121}; 145};
122 146
123#endif 147#endif
124 148

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines