]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpi/include/boost/mpi/status.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpi / include / boost / mpi / status.hpp
CommitLineData
7c673cae
FG
1// Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
2
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)
6
7/** @file status.hpp
8 *
9 * This header defines the class @c status, which reports on the
10 * results of point-to-point communication.
11 */
12#ifndef BOOST_MPI_STATUS_HPP
13#define BOOST_MPI_STATUS_HPP
14
15#include <boost/mpi/config.hpp>
16#include <boost/optional.hpp>
17
18namespace boost { namespace mpi {
19
20class request;
21class communicator;
22
23/** @brief Contains information about a message that has been or can
24 * be received.
25 *
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.
32 */
33class BOOST_MPI_DECL status
34{
35 public:
36 status() : m_count(-1) { }
37
38 status(MPI_Status const& s) : m_status(s), m_count(-1) {}
39
40 /**
41 * Retrieve the source of the message.
42 */
43 int source() const { return m_status.MPI_SOURCE; }
44
45 /**
46 * Retrieve the message tag.
47 */
48 int tag() const { return m_status.MPI_TAG; }
49
50 /**
51 * Retrieve the error code.
52 */
53 int error() const { return m_status.MPI_ERROR; }
54
55 /**
56 * Determine whether the communication associated with this object
57 * has been successfully cancelled.
58 */
59 bool cancelled() const;
60
61 /**
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>.
67 *
68 * @returns the number of @c T elements in the message, if it can be
69 * determined.
70 */
71 template<typename T> optional<int> count() const;
72
73 /**
74 * References the underlying @c MPI_Status
75 */
76 operator MPI_Status&() { return m_status; }
77
78 /**
79 * References the underlying @c MPI_Status
80 */
81 operator const MPI_Status&() const { return m_status; }
82
83 private:
84 /**
85 * INTERNAL ONLY
86 */
87 template<typename T> optional<int> count_impl(mpl::true_) const;
88
89 /**
90 * INTERNAL ONLY
91 */
92 template<typename T> optional<int> count_impl(mpl::false_) const;
93
94 public: // friend templates are not portable
95
96 /// INTERNAL ONLY
97 mutable MPI_Status m_status;
98 mutable int m_count;
99
100 friend class communicator;
101 friend class request;
102};
103
104
105} } // end namespace boost::mpi
106
107#endif // BOOST_MPI_STATUS_HPP