[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 [1]
and calls SerializeTo (stream) on its contained dir and file HashTables
These first write entry count & table size to the stream [2]
and then calls MISC::SerializeTo (entry, stream) for all its entries,
which calls entry->SerializeHeaderTo (stream) [3]
That way all directory/file header data is written recursively [4] [5]
Then the toplevel dir iterates through its entire hierarchy, [6]
calling SerializeContentTo () on all files, which writes the file data.


[1] First problem - The Directory class writes data to a stream whose
format it cannot know. Right now the format of PakFiles is hardwired into
that.

[2] Same problem as [1], but now for HashTable instead of Directory

[3] Unnicety: MISC::SerializeTo () only calls SerializeHeaderTo () although
its name suggests otherwise

[4] 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).

[5] 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
headaches later.

[6] 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
neccessary.


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
have.


	Christian
-- 

Drive A: not responding...Formatting C: instead