1 // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
9 * This header defines the class @c status, which reports on the
10 * results of point-to-point communication.
12 #ifndef BOOST_MPI_STATUS_HPP
13 #define BOOST_MPI_STATUS_HPP
15 #include <boost/mpi/config.hpp>
16 #include <boost/optional.hpp>
18 namespace boost
{ namespace mpi
{
23 /** @brief Contains information about a message that has been or can
26 * This structure contains status information about messages that
27 * have been received (with @c communicator::recv) or can be received
28 * (returned from @c communicator::probe or @c
29 * communicator::iprobe). It permits access to the source of the
30 * message, message tag, error code (rarely used), or the number of
31 * elements that have been transmitted.
33 class BOOST_MPI_DECL status
36 status() : m_count(-1) { }
38 status(MPI_Status
const& s
) : m_status(s
), m_count(-1) {}
41 * Retrieve the source of the message.
43 int source() const { return m_status
.MPI_SOURCE
; }
46 * Retrieve the message tag.
48 int tag() const { return m_status
.MPI_TAG
; }
51 * Retrieve the error code.
53 int error() const { return m_status
.MPI_ERROR
; }
56 * Determine whether the communication associated with this object
57 * has been successfully cancelled.
59 bool cancelled() const;
62 * Determines the number of elements of type @c T contained in the
63 * message. The type @c T must have an associated data type, i.e.,
64 * @c is_mpi_datatype<T> must derive @c mpl::true_. In cases where
65 * the type @c T does not match the transmitted type, this routine
66 * will return an empty @c optional<int>.
68 * @returns the number of @c T elements in the message, if it can be
71 template<typename T
> optional
<int> count() const;
74 * References the underlying @c MPI_Status
76 operator MPI_Status
&() { return m_status
; }
79 * References the underlying @c MPI_Status
81 operator const MPI_Status
&() const { return m_status
; }
87 template<typename T
> optional
<int> count_impl(mpl::true_
) const;
92 template<typename T
> optional
<int> count_impl(mpl::false_
) const;
94 public: // friend templates are not portable
97 mutable MPI_Status m_status
;
100 friend class communicator
;
101 friend class request
;
105 } } // end namespace boost::mpi
107 #endif // BOOST_MPI_STATUS_HPP