Boost logo

Boost :

From: troy d. straszheim (troy_at_[hidden])
Date: 2005-10-10 13:47:09


On Mon, Oct 10, 2005 at 11:42:36AM -0600, Jared McIntyre wrote:

> I've gone through the documentation, and I'm still unable to get
> this particular aspect of serialization working. I have two objects
> 'a' and 'b', and 'b' inherits from 'a'. I have a vector of 'a'
> pointers that may just be 'a' or may be 'b'. I've preregistered
> 'b', right before the vector serialization occurs, so that the
> serialization system should properly recognize that 'b' inherits
> from 'a'. However, only the 'a' pieces of each 'b' in the vector
> serializes. If I place all the 'b' items in a second 'b' containing
> vector, and serialize that afterwards, it properly discovers that
> the 'a' part has been serialized already and simply points to that
> reference. I don't really want to store this second 'b' vector. Is
> there a way to get a vector of a items to also serialize the 'b'
> part of the element if the item is a 'b'?
>

You might want to post some code that shows what's wrong. Have you
tried informing the archives of the existence of derived 'b' via
BOOST_CLASS_EXPORT(b)? And does your 'b' correctly serialize it's
base class 'a' via base_object<> ?

> Also, there is an issue in the documentation. In the "Pointers to
> Objects of Derived Classes" section, it has example registration
> code:
>
> main(){
> ...
> ar.template register_type<derived_one>();
> ar.template register_type<derived_two>();
> base *b;
> ar & b;
> }
>
> I'm guessing that is supposed to be:
>
> main(){
> ...
> ar.register_type<derived_one>();
> ar.register_type<derived_two>();
> base *b;
> ar & b;
> }

Doesn't matter what order they're registered in. Just that they're
registered.

HTH,

-t


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk