Chris@16
|
1 // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
|
Chris@16
|
2
|
Chris@16
|
3 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6
|
Chris@16
|
7 /** @file status.hpp
|
Chris@16
|
8 *
|
Chris@16
|
9 * This header defines the class @c status, which reports on the
|
Chris@16
|
10 * results of point-to-point communication.
|
Chris@16
|
11 */
|
Chris@16
|
12 #ifndef BOOST_MPI_STATUS_HPP
|
Chris@16
|
13 #define BOOST_MPI_STATUS_HPP
|
Chris@16
|
14
|
Chris@16
|
15 #include <boost/mpi/config.hpp>
|
Chris@16
|
16 #include <boost/optional.hpp>
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost { namespace mpi {
|
Chris@16
|
19
|
Chris@16
|
20 class request;
|
Chris@16
|
21 class communicator;
|
Chris@16
|
22
|
Chris@16
|
23 /** @brief Contains information about a message that has been or can
|
Chris@16
|
24 * be received.
|
Chris@16
|
25 *
|
Chris@16
|
26 * This structure contains status information about messages that
|
Chris@16
|
27 * have been received (with @c communicator::recv) or can be received
|
Chris@16
|
28 * (returned from @c communicator::probe or @c
|
Chris@16
|
29 * communicator::iprobe). It permits access to the source of the
|
Chris@16
|
30 * message, message tag, error code (rarely used), or the number of
|
Chris@16
|
31 * elements that have been transmitted.
|
Chris@16
|
32 */
|
Chris@16
|
33 class BOOST_MPI_DECL status
|
Chris@16
|
34 {
|
Chris@16
|
35 public:
|
Chris@16
|
36 status() : m_count(-1) { }
|
Chris@16
|
37
|
Chris@16
|
38 status(MPI_Status const& s) : m_status(s), m_count(-1) {}
|
Chris@16
|
39
|
Chris@16
|
40 /**
|
Chris@16
|
41 * Retrieve the source of the message.
|
Chris@16
|
42 */
|
Chris@16
|
43 int source() const { return m_status.MPI_SOURCE; }
|
Chris@16
|
44
|
Chris@16
|
45 /**
|
Chris@16
|
46 * Retrieve the message tag.
|
Chris@16
|
47 */
|
Chris@16
|
48 int tag() const { return m_status.MPI_TAG; }
|
Chris@16
|
49
|
Chris@16
|
50 /**
|
Chris@16
|
51 * Retrieve the error code.
|
Chris@16
|
52 */
|
Chris@16
|
53 int error() const { return m_status.MPI_ERROR; }
|
Chris@16
|
54
|
Chris@16
|
55 /**
|
Chris@16
|
56 * Determine whether the communication associated with this object
|
Chris@16
|
57 * has been successfully cancelled.
|
Chris@16
|
58 */
|
Chris@16
|
59 bool cancelled() const;
|
Chris@16
|
60
|
Chris@16
|
61 /**
|
Chris@16
|
62 * Determines the number of elements of type @c T contained in the
|
Chris@16
|
63 * message. The type @c T must have an associated data type, i.e.,
|
Chris@16
|
64 * @c is_mpi_datatype<T> must derive @c mpl::true_. In cases where
|
Chris@16
|
65 * the type @c T does not match the transmitted type, this routine
|
Chris@16
|
66 * will return an empty @c optional<int>.
|
Chris@16
|
67 *
|
Chris@16
|
68 * @returns the number of @c T elements in the message, if it can be
|
Chris@16
|
69 * determined.
|
Chris@16
|
70 */
|
Chris@16
|
71 template<typename T> optional<int> count() const;
|
Chris@16
|
72
|
Chris@16
|
73 /**
|
Chris@16
|
74 * References the underlying @c MPI_Status
|
Chris@16
|
75 */
|
Chris@16
|
76 operator MPI_Status&() { return m_status; }
|
Chris@16
|
77
|
Chris@16
|
78 /**
|
Chris@16
|
79 * References the underlying @c MPI_Status
|
Chris@16
|
80 */
|
Chris@16
|
81 operator const MPI_Status&() const { return m_status; }
|
Chris@16
|
82
|
Chris@16
|
83 private:
|
Chris@16
|
84 /**
|
Chris@16
|
85 * INTERNAL ONLY
|
Chris@16
|
86 */
|
Chris@16
|
87 template<typename T> optional<int> count_impl(mpl::true_) const;
|
Chris@16
|
88
|
Chris@16
|
89 /**
|
Chris@16
|
90 * INTERNAL ONLY
|
Chris@16
|
91 */
|
Chris@16
|
92 template<typename T> optional<int> count_impl(mpl::false_) const;
|
Chris@16
|
93
|
Chris@16
|
94 public: // friend templates are not portable
|
Chris@16
|
95
|
Chris@16
|
96 /// INTERNAL ONLY
|
Chris@16
|
97 mutable MPI_Status m_status;
|
Chris@16
|
98 mutable int m_count;
|
Chris@16
|
99
|
Chris@16
|
100 friend class communicator;
|
Chris@16
|
101 friend class request;
|
Chris@16
|
102 };
|
Chris@16
|
103
|
Chris@16
|
104
|
Chris@16
|
105 } } // end namespace boost::mpi
|
Chris@16
|
106
|
Chris@16
|
107 #endif // BOOST_MPI_STATUS_HPP
|