Chris@16: // Copyright (C) 2006 Douglas Gregor . 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: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: /** @file status.hpp Chris@16: * Chris@16: * This header defines the class @c status, which reports on the Chris@16: * results of point-to-point communication. Chris@16: */ Chris@16: #ifndef BOOST_MPI_STATUS_HPP Chris@16: #define BOOST_MPI_STATUS_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace mpi { Chris@16: Chris@16: class request; Chris@16: class communicator; Chris@16: Chris@16: /** @brief Contains information about a message that has been or can Chris@16: * be received. Chris@16: * Chris@16: * This structure contains status information about messages that Chris@16: * have been received (with @c communicator::recv) or can be received Chris@16: * (returned from @c communicator::probe or @c Chris@16: * communicator::iprobe). It permits access to the source of the Chris@16: * message, message tag, error code (rarely used), or the number of Chris@16: * elements that have been transmitted. Chris@16: */ Chris@16: class BOOST_MPI_DECL status Chris@16: { Chris@16: public: Chris@16: status() : m_count(-1) { } Chris@16: Chris@16: status(MPI_Status const& s) : m_status(s), m_count(-1) {} Chris@16: Chris@16: /** Chris@16: * Retrieve the source of the message. Chris@16: */ Chris@16: int source() const { return m_status.MPI_SOURCE; } Chris@16: Chris@16: /** Chris@16: * Retrieve the message tag. Chris@16: */ Chris@16: int tag() const { return m_status.MPI_TAG; } Chris@16: Chris@16: /** Chris@16: * Retrieve the error code. Chris@16: */ Chris@16: int error() const { return m_status.MPI_ERROR; } Chris@16: Chris@16: /** Chris@16: * Determine whether the communication associated with this object Chris@16: * has been successfully cancelled. Chris@16: */ Chris@16: bool cancelled() const; Chris@16: Chris@16: /** Chris@16: * Determines the number of elements of type @c T contained in the Chris@16: * message. The type @c T must have an associated data type, i.e., Chris@16: * @c is_mpi_datatype must derive @c mpl::true_. In cases where Chris@16: * the type @c T does not match the transmitted type, this routine Chris@16: * will return an empty @c optional. Chris@16: * Chris@16: * @returns the number of @c T elements in the message, if it can be Chris@16: * determined. Chris@16: */ Chris@16: template optional count() const; Chris@16: Chris@16: /** Chris@16: * References the underlying @c MPI_Status Chris@16: */ Chris@16: operator MPI_Status&() { return m_status; } Chris@16: Chris@16: /** Chris@16: * References the underlying @c MPI_Status Chris@16: */ Chris@16: operator const MPI_Status&() const { return m_status; } Chris@16: Chris@16: private: Chris@16: /** Chris@16: * INTERNAL ONLY Chris@16: */ Chris@16: template optional count_impl(mpl::true_) const; Chris@16: Chris@16: /** Chris@16: * INTERNAL ONLY Chris@16: */ Chris@16: template optional count_impl(mpl::false_) const; Chris@16: Chris@16: public: // friend templates are not portable Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: mutable MPI_Status m_status; Chris@16: mutable int m_count; Chris@16: Chris@16: friend class communicator; Chris@16: friend class request; Chris@16: }; Chris@16: Chris@16: Chris@16: } } // end namespace boost::mpi Chris@16: Chris@16: #endif // BOOST_MPI_STATUS_HPP