Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2008-07-16 16:32:03


Daryle Walker wrote:
> On Jul 16, 2008, at 2:07 PM, Robert Ramey wrote:
>
>>> So I'll just define serialization in every class in the hierarchy,
>>> and make sure each non-root class calls "ar &
>>> boost::serialization::base_object<BASE_TYPE>(*this)". Can I use a
>>> typedef for the base type, or do I have to use the original name
>>> expression?
>>>
>>> Does this all work for any kind of base: non-polymorphic,
>>> polymorphic, virtual inheritance, and/or multiple inheritance?
>>
>> yes
>
>
> I guess for multiple inheritance, one would serialize all the
> (direct) base classes.

yep

> Do they have to be in declaration order?

>And
> for a virtual base class, wouldn't _every_ derived class have to
> serialize it in its code, since a derived class wouldn't know if it's
> the final type or not?

correct.

>How do you make sure the virtual base class
> gets serialized exactly once?

boost serialization uses object tracking to avoid repetion and save
space in the archive. You should look into "serialization traits" to be
sure that its "turned on" for your class.

Look at the test_diamond.cpp example.

>Do you use reference counting here, or
> make sure that multiple-serialization is safe?

I where belt AND suspenders.

a) We use object tracking to avoid repetition.
b) the serialization library emits a compile time warning if you
try to save a non-const object. This is intended to be sure
that maintainig only one copy of the serialized object is sufficient.

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