Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
BasicSerializeMessage.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/* BasicSerialize.h (C) 2000-2025 */
9/* */
10/* Message using a BasicSerializer. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_MESSAGEPASSING_BASICSERIALIZEMESSAGE_H
13#define ARCCORE_MESSAGEPASSING_BASICSERIALIZEMESSAGE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/serialize/BasicSerializer.h"
18#include "arccore/message_passing/ISerializeMessage.h"
19#include "arccore/message_passing/MessageRank.h"
20#include "arccore/message_passing/MessageTag.h"
21#include "arccore/message_passing/MessageId.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane::MessagePassing::internal
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
49class ARCCORE_MESSAGEPASSING_EXPORT BasicSerializeMessage
50: public ISerializeMessage
51{
52 public:
53
54 static const Int32 DEFAULT_SERIALIZE_TAG_VALUE = 101;
55
57 static MessageTag defaultTag() { return MessageTag(DEFAULT_SERIALIZE_TAG_VALUE); }
58
59 protected:
60 public:
61
62 ~BasicSerializeMessage() override;
63 BasicSerializeMessage& operator=(const BasicSerializeMessage&) = delete;
65
66 protected:
67
74 BasicSerializer* serializer);
77 BasicSerializer* serializer);
78
79 BasicSerializeMessage(MessageRank orig_rank, MessageId message_id,
80 BasicSerializer* serializer);
81
82 public:
83
85 create(MessageRank source, MessageRank destination, ePointToPointMessageType type);
87 create(MessageRank source, MessageRank destination, MessageTag tag,
90 create(MessageRank source, MessageId message_id);
91
92 public:
93
94 bool isSend() const override { return m_is_send; }
95 eMessageType messageType() const override { return m_old_message_type; }
96 Int32 destRank() const override { return m_dest_rank.value(); }
97 Int32 origRank() const override { return m_orig_rank.value(); }
98 MessageRank destination() const override { return m_dest_rank; }
99 MessageRank source() const override { return m_orig_rank; }
100 ISerializer* serializer() override { return m_buffer; }
101 bool finished() const override { return m_finished; }
102 void setFinished(bool v) override { m_finished = v; }
103 void setTag(Int32 tag) override { m_tag = MessageTag(tag); }
104 Int32 tag() const override { return m_tag.value(); }
105 void setInternalTag(MessageTag tag) override { m_tag = tag; }
106 MessageTag internalTag() const override { return m_tag; }
107 MessageId _internalMessageId() const override { return m_message_id; }
108 void setStrategy(eStrategy strategy) override;
109 eStrategy strategy() const override { return m_strategy; }
110 bool isProcessed() const override { return m_is_processed; }
111
112 public:
113
114 BasicSerializer& buffer() { return *m_buffer; }
115 BasicSerializer* trueSerializer() const { return m_buffer; }
116 Int32 messageNumber() const { return m_message_number; }
117 void setMessageNumber(Int32 v) { m_message_number = v; }
118 void setIsProcessed(bool v) { m_is_processed = v; }
119 ePointToPointMessageType _internalMessageType() const { return m_message_type; }
120
121 protected:
122
123 static ePointToPointMessageType _toP2PType(eMessageType mtype);
124 static eMessageType _toMessageType(ePointToPointMessageType mtype);
125
126 private:
127
130 MessageTag m_tag = defaultTag();
131 eMessageType m_old_message_type;
133 eStrategy m_strategy = eStrategy::Default;
136 bool m_finished = false;
138 Int32 m_message_number = 0;
139 bool m_is_processed = false;
140
141 private:
142
143 void _init();
144};
145
146/*---------------------------------------------------------------------------*/
147/*---------------------------------------------------------------------------*/
148
149} // namespace Arcane::MessagePassing::internal
150
151/*---------------------------------------------------------------------------*/
152/*---------------------------------------------------------------------------*/
153
154#endif
Basic implementation of 'ISerializer'.
Serializing message using a BasicSerializer.
void setFinished(bool v) override
Sets the 'finished' state of the message.
Int32 destRank() const override
Destination rank (if isSend() is true) or sender.
MessageId _internalMessageId() const override
Message identifier.
eStrategy strategy() const override
Strategy used for sends/receives.
MessageRank source() const override
Message sender rank.
MessageId m_message_id
Associated MessageId (can be null).
void setInternalTag(MessageTag tag) override
Sets an internal tag for the message.
bool isSend() const override
true if it should send, false if it should receive
BasicSerializer * m_buffer
Buffer containing the info.
bool isProcessed() const override
Indicates if the message has already been processed.
MessageRank destination() const override
Destination rank (if isSend() is true) or sender.
MessageRank m_dest_rank
Rank of the message recipient.
static MessageTag defaultTag()
Default tag for serialization messages.
bool finished() const override
true if the message is finished
eMessageType messageType() const override
Message type.
MessageTag internalTag() const override
Internal tag of the message.
bool m_is_processed
Message number when using multiple messages.
Int32 origRank() const override
Message sender rank See also destRank() for interpretation based on the value of isSend().
Int32 tag() const override
Internal tag of the message.
Reference to an instance.
ePointToPointMessageType
Point-to-point message type.
eMessageType
Stream on which messages are sent.
std::int32_t Int32
Signed integer type of 32 bits.