Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
PointToPointMessageInfo.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/* PointToPointMessageInfo.h (C) 2000-2025 */
9/* */
10/* Information for point-to-point messages. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_MESSAGEPASSING_POINTTOPOINTINFO_H
13#define ARCCORE_MESSAGEPASSING_POINTTOPOINTINFO_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/message_passing/MessageId.h"
18#include "arccore/message_passing/MessageTag.h"
19#include "arccore/message_passing/MessageRank.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
55class ARCCORE_MESSAGEPASSING_EXPORT PointToPointMessageInfo
56{
57 public:
58
59 enum class Type
60 {
61 T_RankTag,
62 T_MessageId,
63 T_Null
64 };
65
66 public:
67
70
73 : m_destination_rank(dest_rank)
74 , m_type(Type::T_RankTag)
75 {}
76
78 //mode \a blocking_type
80 : m_destination_rank(dest_rank)
81 , m_is_blocking(blocking_type == Blocking)
82 , m_type(Type::T_RankTag)
83 {}
84
87 : m_destination_rank(dest_rank)
88 , m_tag(tag)
89 , m_type(Type::T_RankTag)
90 {}
91
93 //mode \a blocking_type
95 : m_destination_rank(dest_rank)
96 , m_tag(tag)
97 , m_is_blocking(blocking_type == Blocking)
98 , m_type(Type::T_RankTag)
99 {}
100
103 : m_message_id(message_id)
104 , m_type(Type::T_MessageId)
105 {
106 _setInfosFromMessageId();
107 }
108
111 : m_message_id(message_id)
112 , m_is_blocking(blocking_type == Blocking)
113 , m_type(Type::T_MessageId)
114 {
115 _setInfosFromMessageId();
116 }
117
118 public:
119
124 ARCCORE_DEPRECATED_REASON("Y2022: This constructor is internal to Arcane and deprecated")
125 PointToPointMessageInfo(MessageRank emiter_rank, MessageRank dest_rank, eBlockingType blocking_type)
126 : m_emiter_rank(emiter_rank)
127 , m_destination_rank(dest_rank)
128 , m_is_blocking(blocking_type == Blocking)
129 , m_type(Type::T_RankTag)
130 {}
131
133 ARCCORE_DEPRECATED_REASON("Y2022: This constructor is internal to Arcane and deprecated")
135 : m_emiter_rank(emiter_rank)
136 , m_destination_rank(dest_rank)
137 , m_tag(tag)
138 , m_type(Type::T_RankTag)
139 {}
140
142 ARCCORE_DEPRECATED_REASON("Y2022: This constructor is internal to Arcane and deprecated")
144 : m_emiter_rank(emiter_rank)
145 , m_destination_rank(dest_rank)
146 , m_type(Type::T_RankTag)
147 {}
148
149 public:
150
157 : m_emiter_rank(emiter_rank)
158 , m_destination_rank(dest_rank)
159 , m_tag(tag)
160 , m_is_blocking(blocking_type == Blocking)
161 , m_type(Type::T_RankTag)
162 {}
163
164 public:
165
166 PointToPointMessageInfo& setBlocking(bool is_blocking)
167 {
168 m_is_blocking = is_blocking;
169 return (*this);
170 }
172 bool isBlocking() const { return m_is_blocking; }
174 bool isMessageId() const { return m_type == Type::T_MessageId; }
176 bool isRankTag() const { return m_type == Type::T_RankTag; }
178 MessageId messageId() const { return m_message_id; }
180 void setMessageId(const MessageId& message_id)
181 {
182 m_type = Type::T_MessageId;
183 m_message_id = message_id;
184 _setInfosFromMessageId();
185 }
186
188 {
189 m_type = Type::T_RankTag;
190 // Attention to properly call the methods to update
191 // the associated values of `m_message_id`
192 setDestinationRank(rank);
193 setTag(tag);
194 }
195
196 MessageRank destinationRank() const { return m_destination_rank; }
199 {
200 m_destination_rank = rank;
201 MessageId::SourceInfo si = m_message_id.sourceInfo();
202 si.setRank(rank);
203 m_message_id.setSourceInfo(si);
204 }
205
207 MessageRank emiterRank() const { return m_emiter_rank; }
209 void setEmiterRank(MessageRank rank) { m_emiter_rank = rank; }
210
212 MessageTag tag() const { return m_tag; }
215 {
216 m_tag = tag;
217 MessageId::SourceInfo si = m_message_id.sourceInfo();
218 si.setTag(tag);
219 m_message_id.setSourceInfo(si);
220 }
221
222 void print(std::ostream& o) const;
223
224 friend std::ostream& operator<<(std::ostream& o, const PointToPointMessageInfo& pmessage)
225 {
226 pmessage.print(o);
227 return o;
228 }
229
230 public:
231
232 // Indicates if the message is valid (i.e.: it was initialized with a valid message)
233 bool isValid() const
234 {
235 if (m_type == Type::T_Null)
236 return false;
237 if (m_type == Type::T_MessageId)
238 return m_message_id.isValid();
239 if (m_type == Type::T_RankTag)
240 return true;
241 return false;
242 }
243
244 public:
245
247 ARCCORE_DEPRECATED_REASON("Y2022: Use emiterRank() instead")
248 MessageRank sourceRank() const { return m_emiter_rank; }
249
251 ARCCORE_DEPRECATED_REASON("Y2022: Use setEmiterRank() instead")
252 void setSourceRank(MessageRank rank) { m_emiter_rank = rank; }
253
254 private:
255
256 MessageRank m_emiter_rank;
257 MessageRank m_destination_rank;
259 MessageId m_message_id;
260 bool m_is_blocking = true;
261 Type m_type = Type::T_Null;
262
263 void _setInfosFromMessageId()
264 {
265 m_destination_rank = m_message_id.sourceInfo().rank();
266 m_tag = m_message_id.sourceInfo().tag();
267 }
268};
269
270/*---------------------------------------------------------------------------*/
271/*---------------------------------------------------------------------------*/
272
273} // namespace Arcane::MessagePassing
274
275/*---------------------------------------------------------------------------*/
276/*---------------------------------------------------------------------------*/
277
278#endif
MessageSourceInfo sourceInfo() const
Information about the message source;.
Definition MessageId.h:160
MessageRank rank() const
Source rank.
Information for sending/receiving a point-to-point message.
PointToPointMessageInfo(MessageRank emiter_rank, MessageRank dest_rank, MessageTag tag, eBlockingType blocking_type)
Message with tag tag, source emiter_rank, destination dest_rank, and blocking mode blocking_type.
MessageRank emiterRank() const
Message sender rank.
PointToPointMessageInfo(MessageId message_id, eBlockingType blocking_type)
Message associated with message_id with blocking mode blocking_type.
void setEmiterRank(MessageRank rank)
Positions the message sender rank.
PointToPointMessageInfo(MessageRank dest_rank, MessageTag tag)
Blocking message with tag tag and destination rank.
MessageRank sourceRank() const
Message origin rank.
void setDestinationRank(MessageRank rank)
Positions the message destination rank.
void setMessageId(const MessageId &message_id)
Positions the message identifier and changes the message type.
void print(std::ostream &o) const
Prints the message.
bool isBlocking() const
Indicates if the message is blocking.
void setSourceRank(MessageRank rank)
Positions the message origin rank.
void setRankTag(MessageRank rank, MessageTag tag)
Positions the message destination rank and tag and changes the message type.
bool isRankTag() const
True if the instance was created with a pair (rank,tag). In this case rank() and tag() are valid.
void setTag(MessageTag tag)
Positions the message tag.
PointToPointMessageInfo(MessageRank dest_rank, eBlockingType blocking_type)
Message with default tag, destination dest_rank, and blocking.
PointToPointMessageInfo(MessageRank dest_rank)
Blocking message with default tag and destination rank rank.
PointToPointMessageInfo(MessageId message_id)
Blocking message associated with message_id.
bool isMessageId() const
True if the instance was created with a MessageId. In this case messageId() is valid.
MessageRank destinationRank() const
Message destination rank.
PointToPointMessageInfo(MessageRank dest_rank, MessageTag tag, eBlockingType blocking_type)
Message with tag tag, destination dest_rank, and blocking.
static MessageTag defaultTag()
Default tag for send/receive without tag argument.
Definition MessageTag.h:82
Declarations of types and methods used by message exchange mechanisms.
eBlockingType
Type indicating whether a message is blocking or not.
Type
Type of JSON value.
Definition rapidjson.h:730