]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/mpi/status.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / 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>
92f5a8d4 17#include <boost/mpl/bool.hpp>
7c673cae
FG
18
19namespace boost { namespace mpi {
20
21class request;
22class communicator;
23
24/** @brief Contains information about a message that has been or can
25 * be received.
26 *
27 * This structure contains status information about messages that
28 * have been received (with @c communicator::recv) or can be received
29 * (returned from @c communicator::probe or @c
30 * communicator::iprobe). It permits access to the source of the
31 * message, message tag, error code (rarely used), or the number of
32 * elements that have been transmitted.
33 */
34class BOOST_MPI_DECL status
35{
36 public:
37 status() : m_count(-1) { }
38
39 status(MPI_Status const& s) : m_status(s), m_count(-1) {}
40
41 /**
42 * Retrieve the source of the message.
43 */
44 int source() const { return m_status.MPI_SOURCE; }
45
46 /**
47 * Retrieve the message tag.
48 */
49 int tag() const { return m_status.MPI_TAG; }
50
51 /**
52 * Retrieve the error code.
53 */
54 int error() const { return m_status.MPI_ERROR; }
55
56 /**
57 * Determine whether the communication associated with this object
58 * has been successfully cancelled.
59 */
60 bool cancelled() const;
61
62 /**
63 * Determines the number of elements of type @c T contained in the
64 * message. The type @c T must have an associated data type, i.e.,
65 * @c is_mpi_datatype<T> must derive @c mpl::true_. In cases where
66 * the type @c T does not match the transmitted type, this routine
67 * will return an empty @c optional<int>.
68 *
69 * @returns the number of @c T elements in the message, if it can be
70 * determined.
71 */
72 template<typename T> optional<int> count() const;
73
74 /**
75 * References the underlying @c MPI_Status
76 */
77 operator MPI_Status&() { return m_status; }
78
79 /**
80 * References the underlying @c MPI_Status
81 */
82 operator const MPI_Status&() const { return m_status; }
83
84 private:
85 /**
86 * INTERNAL ONLY
87 */
88 template<typename T> optional<int> count_impl(mpl::true_) const;
89
90 /**
91 * INTERNAL ONLY
92 */
93 template<typename T> optional<int> count_impl(mpl::false_) const;
94
95 public: // friend templates are not portable
96
97 /// INTERNAL ONLY
98 mutable MPI_Status m_status;
99 mutable int m_count;
100
101 friend class communicator;
102 friend class request;
103};
104
105
106} } // end namespace boost::mpi
107
108#endif // BOOST_MPI_STATUS_HPP