Boost logo

Boost :

From: George A. Heintzelman (georgeh_at_[hidden])
Date: 2002-02-27 13:23:15

> The addresses of stored objects are recorded as the objects are
> stored so that if an object is serialized twice it is only stored
> once in the archive. This:
> a) prevents redundant data from being added to the archive. resulting
> in more efficient file structure
> b) prevents serialization from being called more than once on the
> same object - there by improving runtime efficiency
> c) is essential for the automatic saving and loading of pointers and
> pointed to data. If this is not included, then this would have to be
> implemented "by hand" for each program - this would be no more
> efficient than including it in the library. If this is a large
> consideration, then one is free to abstain from serializing pointers.

In general I think this is a pretty good idea. But, there are some
devils in the details here. I have seen more than one serialization
library run into trouble here. So I have three questions to think about
in judging your design (I haven't looked at the code, which I will try
to do when I find some free time):

1) Suppose I have polymphic object of class Derived, a child of Base;
suppose I try to write this object out twice, once through a pointer to
Base and once through a pointer to Derived. Am I guaranteed with your
implementation to write out this object only once, as an object of type
Derived? Even if the pointers have different numeric representations

2) Suppose I delete an object which has been serialized, then create a
new object in the same place, then attempt to write out the new one.
Under what circumstances will I get a new object in the archive?
Essentially, this is asking over what timescale pointers to objects are
saved by the archive.

3) Suppose I have an object of class Composite which has a data member
of class Element. Suppose I have given out a pointer or reference to
that Element, which has been serialized. I now serialize Composite,
which we should assume has a simple serialization implementation of
simply serializing its elements, including Element. Will I write out
another copy of the Element? Will the answer be the same if I reverse
the order of these events?

Boost list run by bdawes at, gregod at, cpdaniel at, john at