property_serialize.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifndef BOOST_PROPERTY_SERIALIZE_HPP
  6. #define BOOST_PROPERTY_SERIALIZE_HPP
  7. #include <boost/pending/property.hpp>
  8. #include <boost/serialization/is_bitwise_serializable.hpp>
  9. #include <boost/serialization/base_object.hpp>
  10. #include <boost/serialization/nvp.hpp>
  11. namespace boost {
  12. template<class Archive>
  13. inline void serialize(Archive&, no_property&, const unsigned int) { }
  14. template<class Archive, class Tag, class T, class Base>
  15. void
  16. serialize(Archive& ar, property<Tag, T, Base>& prop,
  17. const unsigned int /*version*/)
  18. {
  19. ar & serialization::make_nvp( "property_value" , prop.m_value );
  20. ar & serialization::make_nvp( "property_base" , prop.m_base );
  21. }
  22. #ifdef BOOST_GRAPH_USE_MPI
  23. // Setting the serialization properties of boost::property<> and
  24. // boost::no_property to is_bitwise_serializable, object_serializable,
  25. // track_never only when BOOST_GRAPH_USE_MPI is defined is dubious.
  26. //
  27. // This changes the serialization format of these classes, and hence
  28. // of boost::adjacency_list, depending on whether BOOST_GRAPH_USE_MPI
  29. // is defined.
  30. //
  31. // These serialization properties should probably be set in either case.
  32. //
  33. // Unfortunately, doing that now will change the serialization format
  34. // of boost::adjacency_list in the non-MPI case, and could potentially
  35. // break software that reads files serialized with an older release.
  36. namespace mpi {
  37. // forward declaration, to avoid including mpi
  38. template<typename T> struct is_mpi_datatype;
  39. template<typename Tag, typename T, typename Base>
  40. struct is_mpi_datatype<property<Tag, T, Base> >
  41. : mpl::and_<is_mpi_datatype<T>,
  42. is_mpi_datatype<Base> > { };
  43. }
  44. namespace serialization {
  45. template<typename Tag, typename T, typename Base>
  46. struct is_bitwise_serializable<property<Tag, T, Base> >
  47. : mpl::and_<is_bitwise_serializable<T>,
  48. is_bitwise_serializable<Base> > { };
  49. template<typename Tag, typename T, typename Base>
  50. struct implementation_level<property<Tag, T, Base> >
  51. : mpl::int_<object_serializable> {} ;
  52. template<typename Tag, typename T, typename Base>
  53. struct tracking_level<property<Tag, T, Base> >
  54. : mpl::int_<track_never> {} ;
  55. }
  56. #endif // BOOST_GRAPH_USE_MPI
  57. } // end namespace boost
  58. #ifdef BOOST_GRAPH_USE_MPI
  59. namespace boost { namespace mpi {
  60. template<>
  61. struct is_mpi_datatype<boost::no_property> : mpl::true_ { };
  62. } } // end namespace boost::mpi
  63. BOOST_IS_BITWISE_SERIALIZABLE(boost::no_property)
  64. BOOST_CLASS_IMPLEMENTATION(boost::no_property,object_serializable)
  65. BOOST_CLASS_TRACKING(boost::no_property,track_never)
  66. #endif // BOOST_GRAPH_USE_MPI
  67. #endif // BOOST_PROPERTY_SERIALIZE_HPP