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