|
Boost Users : |
Subject: Re: [Boost-users] [serialization] Stop tracking a specific item
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-08-25 18:11:09
the only way that I can think of to do this is to:
Let T be "the type you want to serialize"
a) set tracking of the T to "track_never"
b) make a "wrapper" tracked<T> used the default tracking.
BOOST_CLASS_TRACKING(T, track_never)
use
ar & tracked(t); // for the tracked version
and
ar & t; for the untracked version.
Look into the documentation regarding wrappers and
the nvp as an example on this.
Robert Ramey
Chard wrote:
> I have no access to the default constructor of a type I want to
> serialize (and no knowledge of any other constructors). However, the
> type is a friend to boost::serialization::access.
>
> Rather than duplicating a chunk of the serialization code, I thought
> I could just reuse the guts of it by serializing the object through a
> pointer.
> However, this would require me to construct the pointer during the
> serialization process, which would mess up the object tracking. Is it
> possible to turn the tracking off for a specific serialized object,
> but not the whole type ?
>
> E.g. a contrived example:
>
> template ...
> void serialize(Archive &ar, const unsigned)
> {
> Type *p = 0;
>
> if (Archive::is_saving::value)
> {
> p = FuncThatCanGiveMeAPointerToType();
> }
>
> // Want to turn off object tracking on p here
> ar & p;
> // or remove it here
>
> if (Archive::is_loading::value)
> {
> FuncThatCanAssignTypeByValue(*p);
> delete p;
> }
> }
>
> It's like I require a remove_object_address, as opposed to
> reset_object_address.
>
> Or is there an alternative approach?
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