Boost logo

Boost Users :

Subject: [Boost-users] [serialization] serialization of a class as pointer and non-pointer
From: Daniela Lambertz (lambertz.lists_at_[hidden])
Date: 2011-10-10 05:10:03


Hello,

I'm using Boost Serialization for a rather complex code system and I've been very happy with it.
But now, an issue occured which I don't really understand.

I have a class Energy which is first serialized as a vector of pointers. Then, it is serialized multiple times as a non-pointer attribute. Here, the issue occurs.
The first non-pointer Energy is serialized normally and all following non-pointer Energies are serialized as pointers to the first one. This leads to wrong values.
When I tried another class which is not serialized as a pointer anywhere in the code, it worked fine.
(I'm using non-intrusive serialization and I split the serialize-method into save and load.)

Now in the Serialization tutorial, I found that the adresses of objects with the tracking trait "track_selectively" are tracked if "an object of this type is anywhere in the program serialized through a pointer".
Can this be the reason for my Energy-problem? If yes, is there a way to avoid this behaviour?

So far, it only works correctly if I transform this Energy attribute into a pointer in the save-method and serialize the pointer. But as my program is still in development, the problem might also turn up with other classes in the future and so it would be nice to have a general solution for this.

Please tell me, if you need example code.

Hope you can help me. Thanks in advance!

Best regards
Daniela Lambertz  

SMS schreiben mit WEB.DE FreeMail - einfach, schnell und   
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192

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