|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2007-12-24 17:21:45
"Yan Drugalya" <ydrugalya_at_[hidden]> wrote in message
news:2441427d0712240501w2fca0f4em4bedfdeaf2981e3b_at_mail.gmail.com...
Folks ,
I feel a lack of understanding what actually track_always trait does. I
expect that boost does not allow me to save/load twice object with the same
address?
***
when tracking is enabled for a given type, the keeps a collection of the
addresses of all items saved and uses this to be sure that each item is only
stored once. So it will allow the same object to be saved more than once,
but after the first time, only an object id is saved.
note that tracking is usally on/off by default so normally you don't have to
specify it.
But it reports BOOST_STATIC_ASSERT even in following case:
****
This is a separate (though related issue which is described int eh
"rationale" section of the documentation.
Question 1
Class A
{
// serialization support
};
BOOST_CLASS_TRACKING (A, track_always)
BOOST_CLASS_EXPORT( A)
const A* a = new A; // at const here.
oa << a ;
I expect that it should raise above BOOST_STATIC_ASSERT because I trying to
store the same object twice?
*** no - its raising the assert because the fact that the object is not a
"const" suggests that you might be altering in the course of the
serialization which would of course conflict with the concept of tracking
which in turn suppress extra copies.
Question 3
Also I can't understand how track_always serialization trait works in case
of Diamond inheritance
Quataion from documentation
"In a diamond hesitance structure with a virtual base class, object tracking
will prevent redundant save/load invocations"
How boost knows that this is virtual base class and prevents redundant
save/load invocations?
***
It doesn't understand the inhertance structure, it just suppresses redundant
saves by keeping a record of what it has saved.
Please help me to find the way to understanding of object tracking trait :)
Thank you
You're welcome.
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