[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Serialization et al
I'm looking through the serialization code, and well, it just doesn't work.
Conceptually that is.
Serialization to somewhere right now works like that (the numbers in the 
brackets are "links" to the problem descriptions below):
PakFile::Umount calls SerializeTo (PakFileHandle) on its root dir.
This calls first SerializeHeaderTo (stream),
which writes the dir header to the stream 
and calls SerializeTo (stream) on its contained dir and file HashTables
These first write entry count & table size to the stream 
and then calls MISC::SerializeTo (entry, stream) for all its entries,
which calls entry->SerializeHeaderTo (stream) 
That way all directory/file header data is written recursively  
Then the toplevel dir iterates through its entire hierarchy, 
calling SerializeContentTo () on all files, which writes the file data.
 First problem - The Directory class writes data to a stream whose
format it cannot know. Right now the format of PakFiles is hardwired into
 Same problem as , but now for HashTable instead of Directory
 Unnicety: MISC::SerializeTo () only calls SerializeHeaderTo () although
its name suggests otherwise
 Unnicety: This gives a data structure which can be correctly read
again, but which is very complex (not complicated to read/write though) and
thus hard to verify during debugging. It is also *very* fault intolerant
(doesn't have any hooks for checking "I'm at the right place", "I'm
really reading directory data, not just some random file contents" etc).
 Again a problem with format hardwiring. This process as it stands is
simply impossible to adapt for writing/reading different formats (remember
the ZIP file example). So it might be ok for now, but surely will give us
 I consider that bad design. On the one hand forwarding responsibilities
recursively (as for the headers) and on the other hand iterating over all
entries and calling methods om them is confusing at least. Adding a
SerializeContentTo () method to directories as well, which calls the same
method for all of that dir's files & recursively for its subdirs is better.
Sorry for taking your work apart in this way, Bjarke. But I think it's
I haven't completely worked out a better system (preserving as many of the
benefits of the current one as possible) yet, but I'm sure I'll very soon
Drive A: not responding...Formatting C: instead