Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MessageRank.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MessageRank.h (C) 2000-2025 */
9/* */
10/* Rank of a message. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_MESSAGEPASSING_MESSAGERANK_H
13#define ARCCORE_MESSAGEPASSING_MESSAGERANK_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19#include <iosfwd>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
44class ARCCORE_MESSAGEPASSING_EXPORT MessageRank
45{
46 public:
47
55 : m_rank(A_NULL_RANK)
56 {}
57
58 explicit MessageRank(Int32 rank)
59 : m_rank(rank)
60 {}
61
62 friend bool operator==(const MessageRank& a, const MessageRank& b)
63 {
64 return a.m_rank == b.m_rank;
65 }
66 friend bool operator!=(const MessageRank& a, const MessageRank& b)
67 {
68 return a.m_rank != b.m_rank;
69 }
70 friend bool operator<(const MessageRank& a, const MessageRank& b)
71 {
72 return a.m_rank < b.m_rank;
73 }
74
76 Int32 value() const { return m_rank; }
77
79 void setValue(Int32 rank) { m_rank = rank; }
80
82 bool isNull() const { return m_rank == A_NULL_RANK; }
83
85 bool isAnySource() const { return m_rank == A_ANY_SOURCE_RANK; }
86
88 bool isProcNull() const { return m_rank == A_PROC_NULL_RANK; }
89
91 static MessageRank anySourceRank() { return MessageRank(A_ANY_SOURCE_RANK); }
92
94 static MessageRank procNullRank() { return MessageRank(A_PROC_NULL_RANK); }
95
96 void print(std::ostream& o) const;
97 friend inline std::ostream& operator<<(std::ostream& o, const MessageRank& tag)
98 {
99 tag.print(o);
100 return o;
101 }
102
103 private:
104
105 Int32 m_rank;
106};
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111} // namespace Arcane::MessagePassing
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116#endif
General declarations for the 'message_passing' component.
void setValue(Int32 rank)
Sets the rank value.
Definition MessageRank.h:79
static MessageRank procNullRank()
Rank corresponding to MPI_PROC_NULL.
Definition MessageRank.h:94
bool isProcNull() const
True if the rank corresponds to procNullRank().
Definition MessageRank.h:88
Int32 value() const
Rank value.
Definition MessageRank.h:76
static MessageRank anySourceRank()
Rank corresponding to MPI_ANY_SOURCE.
Definition MessageRank.h:91
bool isNull() const
True if the rank is uninitialized, corresponding to the default rank.
Definition MessageRank.h:82
bool isAnySource() const
True if the rank corresponds to anySourceRank().
Definition MessageRank.h:85
Declarations of types and methods used by message exchange mechanisms.
bool operator<(const Item &item1, const Item &item2)
Compare two entities.
Definition Item.h:566
std::int32_t Int32
Signed integer type of 32 bits.