|
Boost Users : |
From: Markus.Himmerich_at_[hidden]
Date: 2008-07-10 03:53:24
Hi,
I am trying to serialize a large set of objects in our library. I am
using the
Serialization library from version 1.33 with MSVC 2003. When I had all
serialization code in the header files of the classes, linking took too
much
time and memory. Therefore I am now using explicit template
instantiation
of the serialize function (see below) in conjunction with precompiled
headers
for the Boost.Serialization.
The problem is this: When I de-serialize a DerivedObject to a
BaseObject-pointer
(so that only the header of the BaseObject class is included) the linker
seems
to throw away the information from the explicit template instantiation
of the
DerivedObject in some cases. When I combine the explicit template
instantiation
and definition of serialize into one object for BaseObject and all
DerivedObject,
the linker keeps the registration information of the derived class
(because MSVC
uses object-level linking). Due to the coding standards in our
institution this
method was disapproved.
Is there a way to make the linker keep the registration information of
DerivedObject?
Best regards,
Markus Himmerich
.h-File:
----------------------------------------
namespace boost{
namespace serialization {
class access;
}
}
class BaseObject {
public:
...
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int /*version*/);
}
.cpp-File:
----------------------------------
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/export.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/set.hpp>
#include <boost/serialization/string.hpp> //Use precompiled headers
for these headers
template<class Archive>
void BaseObject::serialize(Archive & ar, const unsigned int /*version*/)
{
ar & BOOST_SERIALIZATION_NVP(id_);
ar & BOOST_SERIALIZATION_NVP(data1_);
}
template void a::serialize<>(boost::archive::xml_iarchive & ar, const
unsigned int /*version*/);
template void a::serialize<>(boost::archive::xml_oarchive & ar, const
unsigned int /*version*/);
BOOST_CLASS_EXPORT(a)
BOOST_SERIALIZATION_SHARED_PTR(a)
Analogous files for DerivedObject.
</PRE>
<meta content="text/html; charset=ISO-8859-1"
<font face="Arial"><font color="#BABABA"><SPAN style="FONT-SIZE: 8pt">Diese E-Mail und eventuell beigefügte Anhänge enthalten vertrauliche Informationen, die rechtlich besonders geschützt sein können, zum Beispiel durch das Bankgeheimnis. Diese Informationen sind ausschlieÃlich für die als Adressaten genannten Personen bestimmt. Wenn Sie nicht der angeschriebene Empfänger sind oder diese E-Mail durch einen Ãbertragungsfehler erhalten haben, informieren Sie uns bitte sofort per E-Mail, Telefon oder Telefax und löschen danach die vorliegende E-Mail. Das unbefugte Kopieren dieser E-Mail, ihrer eventuell beigefügten Anhänge sowie die unbefugte Weitergabe der enthaltenen Informationen an Dritte sind nicht gestattet. Wir danken für Ihre Hilfe.<br>
<font face="Arial"><font color="#BABABA"><SPAN style="FONT-SIZE: 8pt"><br>
<font face="Arial"><font color="#BABABA"><SPAN style="FONT-SIZE: 8pt">This e-mail message together with its attachments, if any, is confidential and may contain information subject to legal privilege, e.g. banking secrecy. The information contained in this e-mail or its attachments is intended solely for the persons named as addressees. If you are not the intended recipient or have received this e-mail in error, please advise us immediately by e-mail, telephone or fax and delete this message. Any unauthorised copying of this message or unauthorised distribution of the information contained herein is prohibited. Thank you for your co-operation.
<PRE>
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