Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2006-04-03 12:03:26


Robert Ramey <ramey_at_[hidden]> wrote:
> I'm not really sure what you want to do but I'll attempt to answer anyhow.

What I'm trying to do is be able to take live objects, and send them to
disk and/or another application every time it changes (including being
created). The idea being that both another application is kept in sync
with the first, and that if the application goes down, I can replay
the disk version and when the replay is done, the application will be
at the same state it was before it went down.

>> I want to use serialization for some kind of active replication,
>
> It would seem to me that the easiest way to do this would be
> to make a TEE type streambuf using the stream buffer library.
> This would duplicate each write to an additional stream.
Do you mean with boost::iostream? or as a part of boost::serialization?

>> however the biggest barrier to this is the fact that serialization
>> does not allow me to put the same object into the stream twice. To
>> be more precise, I want to be able to serialize both to a network and
>> to disk, and I very much like the elegance of the serialization
>> approach (plus the fact it can re-create pointer references, arrays,
>> and such).
>
> I believe the above would cover this.
TEE would handle going to both network and disk, but it would not
obviate the 'single object only once' problem. According to the
serialization documentation (Reference -> Speical Considerations ->
Object Tracking
(http://www.boost.org/libs/serialization/doc/special.html#objecttracking)),
an object may only be put on the stream once, I cannot put an object
that has been changed on the stream again to be re-serialized (either
by replacing the previously serialized entry, or adding it to be
serialized again, but without allocating a new object).

This is why I was asking in the first place how difficult the
modifications would be to allow an object to be serialized twice, and
serialization to understand this and not create a separate instance,
but just update the existing instance.

Thanks for your help :)

-- 
PreZ :)
Death is life's way of telling you you've been fired.
		-- R. Geis

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