|
Boost : |
From: Thomas Wenisch (twenisch_at_[hidden])
Date: 2004-01-08 13:13:56
Hi Robert, all,
I spent the last couple of days using the serialization library
(serialization release #13) in a project of mine, and wanted to report
back on my experience and issues I encountered. I am using the library
with Boost 1.30, and gcc 3.3.2.
First, let me say that this library is very good and has saved me an
enormous amount of time over rolling my own save/restore code.
Here are the issues I ran into:
1) xml archives won't build.
I had to remove all the source files for xml support from the Jamfile in
order to get the library to build. I believe the compile failures were
related to iterators of some sort, but I don't need xml, so I didn't spend
any time investigating.
2) link problem with void_caster::self_register()
I had linker problems with void_caster::self_register(). To fix these,
I commented out the inline keyword in
/libs/serialization/src/void_cast.cpp:68
3) Registration of polymorphic types
I remember from the review a year ago that serializing polymorphic types
through a base pointer was very heavily debated. I am doing this quite a
bit, and it took me a while to figure out how to do this right. A few
comments:
a) Clearer documentation
The "Pointers to Objects of Derived Classes" section of the docs talks
about loading an object through a base pointer, and why registration is
neccessary. From reading this, I did not understand that registration
is also neccessary when writing to an archive. Also, when using
register_type<>, it isn't clear in the docs if the types need to be
registered in the same order to deserialize, but I presume this is the
case. Is this true? Can I avoid this requirement with the EXPORT
mechanism?
b) export.hpp broken under gcc 3.3.2
I got all sorts of nasty compile errors when I tried to include
export.hpp. I did not investigate them, since I was able to get things
working with the register_type<> mechanism.
c) registration and templates
I have a bunch of templates which produce types which I want to
serialize. I have written serialize code for them, and they work
swimmingly. The problem is with registering them with register_type<>.
What I would want is to automatically register templates when they are
instantiated, for example, by having a static member variable in
the class whose constructor does the registering. But there are a
number of problems with this idea: You have to register with a specific
archive object, which doesn't exist in my use case until I actually go
to save. Also, how do I enforce that the same set of templates are
instantiated, in the same order, in the program which
deserializes? Clearly, if the instantiation doesn't exist, you won't be
able to load the object. In my use case, it would be extremely helpful
if the library were able to generate an error message that indicated the
name of the type (using typeinfo) that is missing, so I can go and add
an explicit instantiation to the loading program. Any thoughts or
advice on these issues?
4) BOOST_IS_ABSTRACT() and incomplete types
Can I place the BOOST_IS_ABSTRACT macro at a location where the type it
is naming is incomplete? Same question for the EXPORT macros.
5) serialize::access does not work with template types. (gcc bug?)
This one is almost certainly a gcc bug. serialize::access grants the
serialization code access to private constructors of the class to be
serialized, and this works correctly for non-template types. However,
in templates, gcc claims that the constructors are not accessible within
serialize::access, despite the friend declaration. Anyone seen this
behavior before?
That's all I have for now, though I am sure there will be more.
I look forward to seeing this library included into Boost soon!!!
Regards,
-Tom Wenisch
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk