Boost logo

Boost Users :

Subject: [Boost-users] [serialization] Deserialize by pointer without calling new/constructor
From: Adam Verigin (averigin_at_[hidden])
Date: 2010-09-27 19:53:43


I'm working on integrating Boost serialization into an OMNeT++ simulation as
a means of saving a partial simulation state (to speed up statistical
testing). The problem I am running into is related to the process of
deserializing a derived-class object by a base-class pointer without
tracking.

As far as I can tell, in this case the serialization library normally:
1. Determines the most-derived type
2. Allocates memory for that type of object
3. Updates the pointer to point the the above allocated memory block
4. Invokes placement new and the default constructor (overloadable by
load_construct_data)
5. Calls the class' serialize() or load() method on the newly-constructed
object

However, I have a case where I start out with an existing derived-class
object that is partially initialized, and I just want to call the
serialize() or load() method for it using a base-class pointer (i.e., no
memory allocation since that's already done, and no constructor call since
that's also already done.) Is this possible or am I trying to do something
the serialization library is not meant for?

Thanks,
Adam Verigin



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