Re: [Alephmodular-devel] Serializing the world
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2005-06-14 07:29:46
|
On Jun 13, 2005, at 9:09 PM, Br'fin wrote: > MyFoo.h > ------- > #include "CLoader.h" // CSerializer? > > // CLoader::Result some variable size data run with a count > class MyFooLoader : public CLoader > { > void load_raw_data(char* raw_data, size_t length); > CLoader::Result get_save_data(); > } Refinements on a concept void CLoader::LoadFromStream(AIStream&, bool versioned= TRUE); CLoader::Result GetSaveData(); The Load routine doesn't really need data* and size, though I suppose if we wanted to keep a firm separation of outer data and inner awareness of AIStream/AOStream usage, then it might be better to use data+size as external arguments, and the interal _LoadFromStream uses the streams. Tweak the wad version to say 'supports tag versions' (Likely check A1 for Minf wad version and go with higher then that) then when all data is written out, it has an int16 at the beginning of the tag data that encapsulates version info for that tag. We then have the version flag on LoadFromStream merely to indicate the older map files where this version information on the tags is not present. Alternatively, we add more than one byte to the fore of tag info, with the other new bytes being a unique marker that should only be likely and present if the version bytes are also set. Taken from someone's slashdot post: (http://hardware.slashdot.org/ comments.pl? sid=139404&threshold=0&commentsort=0&tid=198&mode=thread&pid=11676766#11 677336) > ver = deserialize<int>(stream); > if (ver==2) > { > . // standard deserialization code > } > else if (ver==1) > { > . // Code that reads an old stream and builds a new object > . // in a backwards-compatible way. > } Sigh, ramblings and incoherencies from way too late at night. -Jeremy Parsons http://alephmodular.sourceforge.net/ |