Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > fff948ba35a5ae9f9dfbad3da9c22cf6 > files > 13

viking-1.1-1.fc14.x86_64.rpm

WARNING: OLD file format. Will be discarded. Read FF2
----------
Magic Number:
6c45e131

lE..

at beginning of file. I love magic numbers.

For Serialization, we need to separate realizing a layer and adding it to a aggregate. An aggregate 
layer, when realized, should realize all of its children, and add all of its children to the treeview. 
An aggregate should realize a layer and add it to the treeview in add_layer only if it is already 
realized (we cannot assume that it is.) This will pave the road for serialization.

Tree
  Child
    Child


START
(TopLayer)
layer type ID
layer name len + layer name
Layer Data. Call Layer serialize-in func.

(if type == aggregate, len = # of layers)

Example:

Top
+ Aggy
  + Aggy2
    - TRW
    - MAP
  - COORD
+ Aggy1
  - TRW
  - TRW
  - TRW

File:

0	(Aggregate)
4
Aggy
2	(2 Sublayers)

0	(Aggregate)
5
Aggy2
2	(2 Subs)

1	(TRW)
3
TRW
(TRW DATA)

2	(MAP)
3
MAP
(MAP DATA)

3	(COORD)
5
COORD
(COORD DATA)

1
5
Aggy1
3	(3 subs)

1
3
TRW
100
(TRW DATA)

1
3
TRW
100
(TRW DATA)

1
3
TRW
100
(TRW DATA)

(END)

Parsing
Call agg parse function (top layer) with file format.
agg parse function parses, calls appropriate function.
repeats add infinitum.

----

Functions:

Aggregate Read:
for loop thru # of layers:
  read a byte, get id, create a layer of such type via the "serialize_read" func which 
  returns a layer I can then read.
  repeat, enjoy.

Ahhh, the joys of Recursion.

Aggregate Write:
write length of layers array.
for each layer:
  write ID.
  run serialize_write.


MAX # of layers: 2^16