// Copyright (C) 2007 Douglas Gregor and Matthias Troyer // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // // This file contains helper data structures for use in transmitting // properties. The basic idea is to optimize away any storage for the // properties when no properties are specified. #ifndef BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP #define BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP #ifndef BOOST_GRAPH_USE_MPI #error "Parallel BGL files should not be included unless has been included" #endif #include #include #include #include #include namespace boost { namespace detail { namespace parallel { /** * This structure contains an instance of @c Property, unless @c * Property is a placeholder for "no property". Always access the * property through @c get_property. Typically used as a base class. */ template struct maybe_store_property { maybe_store_property() {} maybe_store_property(const Property& p) : p(p) {} Property& get_property() { return p; } const Property& get_property() const { return p; } private: Property p; friend class boost::serialization::access; template void serialize(Archiver& ar, const unsigned int /*version*/) { ar & p; } }; template<> struct maybe_store_property { maybe_store_property() {} maybe_store_property(no_property) {} no_property get_property() const { return no_property(); } private: friend class boost::serialization::access; template void serialize(Archiver&, const unsigned int /*version*/) { } }; /** * This structure is a simple pair that also contains a property. */ template class pair_with_property : public boost::parallel::detail::untracked_pair , public maybe_store_property { public: typedef boost::parallel::detail::untracked_pair pair_base; typedef maybe_store_property property_base; pair_with_property() { } pair_with_property(const T& t, const U& u, const Property& property) : pair_base(t, u), property_base(property) { } private: friend class boost::serialization::access; template void serialize(Archiver& ar, const unsigned int /*version*/) { ar & boost::serialization::base_object(*this) & boost::serialization::base_object(*this); } }; template inline pair_with_property make_pair_with_property(const T& t, const U& u, const Property& property) { return pair_with_property(t, u, property); } } } } // end namespace boost::parallel::detail namespace boost { namespace mpi { template<> struct is_mpi_datatype > : mpl::true_ { }; template struct is_mpi_datatype > : is_mpi_datatype { }; template struct is_mpi_datatype > : boost::mpl::and_ >, is_mpi_datatype > { }; } } // end namespace boost::mpi BOOST_IS_BITWISE_SERIALIZABLE(boost::detail::parallel::maybe_store_property) namespace boost { namespace serialization { template struct is_bitwise_serializable > : is_bitwise_serializable { }; template struct implementation_level > : mpl::int_ {} ; template struct tracking_level > : mpl::int_ {} ; template struct is_bitwise_serializable< boost::detail::parallel::pair_with_property > : boost::mpl::and_ >, is_bitwise_serializable > { }; template struct implementation_level< boost::detail::parallel::pair_with_property > : mpl::int_ {} ; template struct tracking_level< boost::detail::parallel::pair_with_property > : mpl::int_ {} ; } } // end namespace boost::serialization #endif // BOOST_PARALLEL_DETAIL_PROPERTY_HOLDERS_HPP