property_serialize.hpp 2.8 KB

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