1 //  (C) Copyright Jeremy Siek 2006
2 //  Distributed under the Boost Software License, Version 1.0. (See
3 //  accompanying file LICENSE_1_0.txt or copy at
4 //  http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef BOOST_PROPERTY_SERIALIZE_HPP
7 #define BOOST_PROPERTY_SERIALIZE_HPP
8 
9 #include <boost/pending/property.hpp>
10 #include <boost/serialization/is_bitwise_serializable.hpp>
11 #include <boost/serialization/base_object.hpp>
12 #include <boost/serialization/nvp.hpp>
13 
14 namespace boost {
15   template<class Archive>
serialize(Archive &,no_property &,const unsigned int)16   inline void serialize(Archive&, no_property&, const unsigned int) { }
17 
18   template<class Archive, class Tag, class T, class Base>
19   void
serialize(Archive & ar,property<Tag,T,Base> & prop,const unsigned int)20   serialize(Archive& ar, property<Tag, T, Base>& prop,
21             const unsigned int /*version*/)
22   {
23     ar & serialization::make_nvp( "property_value" , prop.m_value );
24     ar & serialization::make_nvp( "property_base" , prop.m_base );
25   }
26 
27 #ifdef BOOST_GRAPH_USE_MPI
28 
29 // Setting the serialization properties of boost::property<> and
30 // boost::no_property to is_bitwise_serializable, object_serializable,
31 // track_never only when BOOST_GRAPH_USE_MPI is defined is dubious.
32 //
33 // This changes the serialization format of these classes, and hence
34 // of boost::adjacency_list, depending on whether BOOST_GRAPH_USE_MPI
35 // is defined.
36 //
37 // These serialization properties should probably be set in either case.
38 //
39 // Unfortunately, doing that now will change the serialization format
40 // of boost::adjacency_list in the non-MPI case, and could potentially
41 // break software that reads files serialized with an older release.
42 
43   namespace mpi {
44 
45     // forward declaration, to avoid including mpi
46     template<typename T> struct is_mpi_datatype;
47 
48     template<typename Tag, typename T, typename Base>
49     struct is_mpi_datatype<property<Tag, T, Base> >
50       : mpl::and_<is_mpi_datatype<T>,
51                   is_mpi_datatype<Base> > { };
52   }
53 
54   namespace serialization {
55     template<typename Tag, typename T, typename Base>
56     struct is_bitwise_serializable<property<Tag, T, Base> >
57       : mpl::and_<is_bitwise_serializable<T>,
58                   is_bitwise_serializable<Base> > { };
59 
60   template<typename Tag, typename T, typename Base>
61   struct implementation_level<property<Tag, T, Base>  >
62    : mpl::int_<object_serializable> {} ;
63 
64   template<typename Tag, typename T, typename Base>
65   struct tracking_level<property<Tag, T, Base>  >
66    : mpl::int_<track_never> {} ;
67 
68   }
69 #endif // BOOST_GRAPH_USE_MPI
70 
71 } // end namespace boost
72 
73 #ifdef BOOST_GRAPH_USE_MPI
74 namespace boost { namespace mpi {
75     template<>
76     struct is_mpi_datatype<boost::no_property> : mpl::true_ { };
77 
78 } } // end namespace boost::mpi
79 
80 BOOST_IS_BITWISE_SERIALIZABLE(boost::no_property)
81 BOOST_CLASS_IMPLEMENTATION(boost::no_property,object_serializable)
82 BOOST_CLASS_TRACKING(boost::no_property,track_never)
83 #endif // BOOST_GRAPH_USE_MPI
84 
85 #endif // BOOST_PROPERTY_SERIALIZE_HPP
86