103 s_int8 get (igzstream& file);
113 s_int8 load (string fname);
123 s_int8 put (ogzstream& file) const;
131 s_int8 save (string fname) const;
147 s_int8 get_state (igzstream& file);
155 s_int8 put_state (ogzstream& file) const;
165 \section objreuse Making your objects reusable
166 Another issue that can decrease the %game performance is %objects lifetime.
167 Take our sample %animation class. Say that I've already loaded an %animation that
168 I don't need anymore, and I need to load another one. If my %object doesn't have
169 a cleaning method, I'll have to delete my %animation %object and reallocate another
170 one. And destructor call + deallocation + allocation + constructor call = a lot of
171 time wasted. This can easily be avoided if your %object has a cleaning method, that
172 restores it to it's post-constructor state and allow you to reuse it as if it was
173 a new one. The loading method is a good place where to call this cleaning function,
174 as you can't expect to load something if your %object isn't empty. In our %animation
175 sample class, the \e clear () method would delete the \e frames vector (cleaning up
176 the %datas) and put \e currentframe to 0 (safe, post-constructor state). And I now
177 can use the same %object multiple times. Most often too, the destructor will be a
178 simple call to clear (), as it also frees all the memory occupied by the %object.
180 The declaration convention is quite straightforward then:
197 Note that not every %object int the %game needs to be state-saveable. First, they must
198 have a changeable state, and second, they have to be saved/loaded during %game