|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2005-12-08 11:23:14
Hmmm - my question is:
My intention has always been that serialization "features" for class A
always be defined in A.h.
That way the correct and consistent set of "features" would be used by all
programs
which use class A. So I would expect A.h to look like:
#include <boost/serialization/version.hpp>
namespace boost {
namespace serialization {
class access;
}
}
class A
{...
};
BOOST_CLASS_VERSION(A, 1)
which I think would solve your problem.
I would not expect this to slow down compilation significantly unless
as long as no <boost/archive/....> headers are not included.
Robert Ramey
Mikhail Kubzin wrote:
> I use boost serialisation in my project and I need to serialise a
> vector of pointers (boost::shared_ptr) to a base class. The base class
> is declared in one dll in the following way:
>
> A.h:
>
> namespace boost {
> namespace serialization {
> class access;
> }
> }
> class A
> {...
> };
>
> A.cpp
> #include <... boost serialization headers .. >
> BOOST_CLASS_VERSION(A, 1)
>
> ....
>
> In another dll I declare class B derived from A declared and
> implemented in the same manner ( .h files do not include boost
> serialization headers). The problem is that inside the sirialisation
> (save/load) function of the derived class I get correct file_version
> value while in the serialisation function of the base class
> file_version is 0.
>
> I call serialization function of the base class as advised in the
> documentation:
> ar & boost::serialization::base_object<A>(*this);
>
> However, if I insert BOOST_CLASS_VERSION(A, 1) into B.cpp then
> file_version in A's serialisation function is initialised properly.
>
> It is a pain to update the version of the base class in all derived
> classes from one side, it is also impractical to include all boost
> headers and class version information into .h files since the
> compilation time grows dramatically and the size of the executables
> increases several times.
>
> Any thoughts and suggestions are welcome!
> Thank you in advance,
>
> Mikhail
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk