Boost logo

Boost Users :

Subject: Re: [Boost-users] boost serialization: can't deserialize pointer to abstract base class where derived classes overload load_construct_data
From: Rebecca Lehman (rebecca.lehman_at_[hidden])
Date: 2013-01-08 23:05:39


Thanks for your helpful comments.

a) note that the issues related to pointers and non-default constructors
> or orthogonal so you actually have two separate problems here.
>
>
I don't think these issues are orthogonal. I have tested cases where there
is a default constructor, and everything works. As soon as I overload
load_construct_data, it breaks. The underlying class is deserializing
correctly, but the pointer causes a segfault.

> b) non-default constuctors. Check out files in the
> ...../libs/serialization/test directory:
> test_non_default_ctor and test_non_default_ctor2. Make a small program
> to test your serialization - don't use pointers just make sure the
> basic serialization works.
>
>
It does. Thanks though.

> c) pointers. The system is designed to permit serialization through an
> abstract pointer to a base class. However, it does require some care
>
> 1) there are two methods - "register" and "export" - you've used both
> in our example. I recommend using one or the other just to keep
> from getting too confused.
>
>
As I said in my email, I tried using one or the other--it doesn't matter
which.

> 2) remember if you serialize through a derived pointer you can't
> de-serialize through the base class. That is, you always have
> to de-serialize to the exact same type you serialized from.
>
>
True.

> 3) your example shows
> class D2 {
> ...
> };
> BOOST_CLASS_EXPORT_GUID(D1, "D1"); // should be D2 !!!
> check out ...../libs/serialization/test/test_exported.cpp for an example.
>
> Robert Ramey
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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