|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2005-04-08 11:27:57
martin.ecker_at_[hidden] wrote:
> Hi,
>
> Robert Ramey wrote:
>> For what its worth, my thoughts along these lines are something like:
>>
>> calss helper_base {
>> virtual ~helper_base() = 0;
>> }
>>
>> class text_iarchive ...
>> std::list<helpbase *> helper_list;
>> text_iarchive(){
>> for(it = help_list.begin();it != helper_list.end();++it)
>> delete *it;
>> }
>> };
>
> This is a good idea, although it shouldn't be part of text_iarchive,
> but some base class of it instead,
Of course, this was only an example/sketch for illustrative purposes.
> so that all archive types can use
> these 'helpers' as you call them. Some time ago, this was one of our
> feature requests for boost::serialization and we've implemented this
> in our version of the library. We currently call these 'helpers'
> 'archive state', for the lack of a better word.
> Basically, this mechanism allows applications to associate arbitrary
> objects with archives that can be accessed from serialization code.
> These objects are basically per-instance variables of an archive.
> This is not only useful for shared_ptr serialization, but for other
> things as well, such as integrating boost::serialization with a
> serialization system of a 3rd party library. Another thing we use this
> mechanism for is when de-serialized objects need to register
> themselves with some kind of global registry or other type of manager
> object. So we strongly encourage adding such a feature to
> boost::serialization.
Your experience suggests this is on the right track. I would like to see
this kicked around a while to see that it would really satisfy those who are
unhappy about this aspect of serialization. Its also possible that someone
can invent a more elegant, transparent, and typesafe way of doing I can
live with it - question is can everyone else?
Robert Ramey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk