|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2005-07-04 10:59:22
Sergey Skorniakov wrote:
>> Trying to load an archive with one set of traits from a archive saved
>> with another set of traits would generally not work without making
>> special arrangements to read the "old" archives. That is, saving one
>> way and loading another way cannot be generally expected to work and
>> should give an exception.
>
> Ok, we are using class versioning to support loading of older
> versions of classes. Can we remove obsolete classes (serialized by
> pointer to base) from time to time or this will break reading
> archives even if no instances of such classes was used during
> writing?
I would expect this to break any archives that contain any instances of the
obsolete classes but not break any that didn't contain the obsolete classes.
The question arises as to what an "obsolete class" means. How can one be
sure it was never written to an archive. It had serialization in it for a
reason at one time. At the very least I would be inclined to leave it with
an assertion in the serialization function. Hopefully, this would trap any
erroneous presumption that that an old archive doesn't contain an instance
of the obsolete class.
Note that handling obsolete classes through versioning can sometimes be
tricky. For an example take a look at the new shared_ptr serialization
which inlcludes code to handle the shared_ptr's serialized by v 1.32. The
ways of doing it are totally different between the two versions. So mapping
the old serialization to the new one wasn't at all straight forward.
>I see some class names and numeric ids for classes in
> archives but I'm not sure that these names or ids used for
> polymorphic loading.
ids are used when possible. That is when a type is automatically
"registered" by its first use. Otherwise it is identified by its class name
declared with export.
>Of course, if ids used, we should not remove any
> class that marked with BOOST_CLASS_EXPORT macro, but if class names
> used, I see no reasons why we can't drop obsolete classes.
well, the archive will contain a name of the obsolete class. when that name
is looked up in the table which maps class names to types
(extended_type_info) a matching type won't be found as the program expects
and you'll get an error like class id not found - as it seems you have done.
Robert Ramey
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net