1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
---|
2 | // test_polymorphic_A.cpp |
---|
3 | |
---|
4 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
---|
5 | // Use, modification and distribution is subject to the Boost Software |
---|
6 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
7 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
8 | |
---|
9 | #include "test_polymorphic_A.hpp" |
---|
10 | #include <boost/serialization/nvp.hpp> |
---|
11 | #include "A.hpp" |
---|
12 | |
---|
13 | data::data() : |
---|
14 | a(new A) |
---|
15 | {} |
---|
16 | data::~data(){ |
---|
17 | delete a; |
---|
18 | } |
---|
19 | |
---|
20 | bool data::operator==(const data & rhs) const { |
---|
21 | return * (a) == *(rhs.a); |
---|
22 | } |
---|
23 | |
---|
24 | #if 0 // this method fails with msvc 6.0 and borland |
---|
25 | // now we can define the serialization for class A |
---|
26 | template<class Archive> |
---|
27 | void data::serialize(Archive & ar, const unsigned int /* file_version */){ |
---|
28 | ar & BOOST_SERIALIZATION_NVP(a); |
---|
29 | } |
---|
30 | |
---|
31 | // without the explicit instantiations below, the program will |
---|
32 | // fail to link for lack of instantiantiation of the above function |
---|
33 | // note: the following failed to fix link errors for vc 7.0 ! |
---|
34 | #include <boost/archive/polymorphic_oarchive.hpp> |
---|
35 | |
---|
36 | template void data::serialize<boost::archive::polymorphic_oarchive>( |
---|
37 | boost::archive::polymorphic_oarchive & ar, |
---|
38 | const unsigned int file_version |
---|
39 | ); |
---|
40 | |
---|
41 | #include <boost/archive/polymorphic_iarchive.hpp> |
---|
42 | |
---|
43 | template void data::serialize<boost::archive::polymorphic_iarchive>( |
---|
44 | boost::archive::polymorphic_iarchive & ar, |
---|
45 | const unsigned int file_version |
---|
46 | ); |
---|
47 | #endif |
---|
48 | |
---|
49 | // so use this |
---|
50 | void data::serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int /* file_version */){ |
---|
51 | ar & BOOST_SERIALIZATION_NVP(a); |
---|
52 | } |
---|
53 | |
---|
54 | void data::serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int /* file_version */){ |
---|
55 | ar & BOOST_SERIALIZATION_NVP(a); |
---|
56 | } |
---|