|
Boost Users : |
From: Sohail Somani (s.somani_at_[hidden])
Date: 2007-04-28 17:03:27
> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Robert Ramey
> Sent: Friday, April 27, 2007 9:47 PM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] [Serialization] Multiple BOOST_CLASS_EXPORT
>
> Sohail Somani wrote:
> >> -----Original Message-----
> >> From: boost-users-bounces_at_[hidden]
> >> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Robert
> > If you have BOOST_CLASS_EXPORT in a header file, doesn't that cause
> > the same problems? If this is what your checkins would fix, then
> > that's understandable.
>
> No - code is only instatiated for archives actually used. So
> if the usage
> of an archive is confined to ONE module there are no problems. But
> this requires instatiating the serialization functions not in
> the header -
> that
> is in "out of line" code. Its quite doable but somewhat
> annoying. This
> is a result of the C++ instantiation model. Note that
> different compilers
> and linkers do things differently, but I believe that this
> method works
> on all of them.
>
> Downside you have to explictly instantiate combination of type/archive
> you might export. So I recommend putting them in a library and
> linking against that so you don't suffer from code bloat.
Well the way I work is I define the class in the hpp file with
template<typename Archive> void serialize(...);
Then in the cpp file I do (something like):
#include "myclass.hpp"
#include "all_my_archives.hpp"
#include "export.hpp"
template<typename Archive>
void MyClass::serialize(...){...}
BOOST_CLASS_EXPORT(MyClass);
So I think I'm already doing what you suggest as all my classes get
compiled once into a single library.
> Finally, you can also use the polymorphic version of the archive.
> This permits you to compile only one instantiation for all
> archive types.
> Linking
> is accomplished at runtime via a virtual function interface.
In time, I think I will do that. Had some issues when I tried to do it
earlier but didn't bother to figure them out as I only need a single
archive type.
Thanks,
Sohail
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