Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IItemFamilySerializeStep.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/* IItemFamilySerializeStep.h (C) 2000-2025 */
9/* */
10/* Interface for a step in the serialization of entity families. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IITEMFAMILYSERIALIZESTEP_H
13#define ARCANE_CORE_IITEMFAMILYSERIALIZESTEP_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \brief Interface for a step in the serialization of entity families.
30 *
31 * This interface is used by IItemFamilyExchanger to serialize
32 * and deserialize information. Serialization is done by message exchange
33 * and there is one message per rank with which we communicate.
34 *
35 * The call pseudo-code is as follows:
36 \code
37 * IItemFamilyExchanger* exchanger = ...;
38 * IItemFamilySerializeStep* step = ...;
39 * exchanger->computeExchangeInfos();
40 * step->initialize();
41 * // Some exchanger action
42 * ...
43 * step->notifyAction(AC_BeginPrepareSend);
44 * // Set serialize mode to ISerializer::ModeReserve
45 * for( Integer i=0; i<nb_message; ++i )
46 * step->serialize(i);
47 * // Set serialize mode to ISerializer::ModePut
48 * for( Integer i=0; i<nb_message; ++i )
49 * step->serialize(i);
50 * step->notifyAction(AC_EndPrepareSend);
51 * exchanger->processExchange();
52 * step->notifyAction(AC_BeginReceive);
53 * // Set serialize mode to ISerializer::ModeGet
54 * for( Integer i=0; i<nb_message; ++i )
55 * step->serialize(i);
56 * step->notifyAction(AC_EndReceive);
57 * step->finalize();
58 \endcode
59 *
60 * The serialize() method is called for each rank we communicate with.
61 *
62 * The step is called during the serialization phase specified by phase()
63 * as specified in the IItemFamilyExchanger documentation.
64 *
65 * For the specified phase, the call order is as follows:
66 \code
67 * IItemFamilySerializeStep* step = ...;
68 * ISerializer* sbuf = ...;
69 * sbuf->setMode(ISerializer::ModeReserve)
70 * step->beginSerialize(sbuf->mode())
71 \endcode
72 */
73class ARCANE_CORE_EXPORT IItemFamilySerializeStep
74{
75 public:
76
77 //! Serialization phase
78 enum ePhase
79 {
80 PH_Item,
81 PH_Group,
82 PH_Variable
83 };
84 //! Action during serialization
85 enum class eAction
86 {
87 //! Start of send preparation.
88 AC_BeginPrepareSend,
89 //! End of send preparation.
90 AC_EndPrepareSend,
91 //! Start of data reception.
92 AC_BeginReceive,
93 //! End of data reception.
94 AC_EndReceive,
95 };
96
97 public:
98
99 class NotifyActionArgs
100 {
101 public:
102
103 NotifyActionArgs(eAction aaction, Integer nb_message)
104 : m_action(aaction)
105 , m_nb_message(nb_message)
106 {}
107
108 public:
109
110 eAction action() const { return m_action; }
111 //! Number of serialization messages
112 Integer nbMessage() const { return m_nb_message; }
113
114 private:
115
116 eAction m_action;
117 Integer m_nb_message;
118 };
119
120 public:
121
122 virtual ~IItemFamilySerializeStep() = default;
123
124 public:
125
126 //! Initializes the instance before the start of exchanges.
127 virtual void initialize() = 0;
128
129 //! Notifies the instance that we are entering a certain phase of the exchange.
130 virtual void notifyAction(const NotifyActionArgs& args) = 0;
131
132 /*!
133 * \brief Serializes into/from \a buf.
134 *
135 * \a args.rank() contains the rank of the subdomain with which we
136 * communicate. \a args.messageIndex() is the message number index and
137 * \a args.nbMessageIndex() is the number of messages that will be sent.
138 *
139 * During serialization, these are the local indices of the entities sent to
140 * rank \a rank(). During deserialization, these are the local indices
141 * received by rank \a rank().
142 */
143 virtual void serialize(const ItemFamilySerializeArgs& args) = 0;
144
145 //! Performs end-of-exchange processing.
146 virtual void finalize() = 0;
147
148 //! Serialization phase where this instance is involved.
149 virtual ePhase phase() const = 0;
150
151 //! Associated family
152 virtual IItemFamily* family() const = 0;
153};
154
155/*---------------------------------------------------------------------------*/
156/*---------------------------------------------------------------------------*/
157
158/*!
159 * \brief Factory for creating a step in the serialization of
160 * entity families.
161 */
162class ARCANE_CORE_EXPORT IItemFamilySerializeStepFactory
163{
164 public:
165
166 virtual ~IItemFamilySerializeStepFactory() = default;
167
168 public:
169
170 /*!
171 * \brief Creates a step for the family \a family.
172 *
173 * May return nullptr in which case no step is added for this
174 * factory.
175 */
177};
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
182} // namespace Arcane
183
184/*---------------------------------------------------------------------------*/
185/*---------------------------------------------------------------------------*/
186
187#endif
Declarations of Arcane's general types.
Factory for creating a step in the serialization of entity families.
virtual IItemFamilySerializeStep * createStep(IItemFamily *family)=0
Creates a step for the family family.
Integer nbMessage() const
Number of serialization messages.
Interface for a step in the serialization of entity families.
virtual void initialize()=0
Initializes the instance before the start of exchanges.
virtual IItemFamily * family() const =0
Associated family.
virtual void finalize()=0
Performs end-of-exchange processing.
virtual void notifyAction(const NotifyActionArgs &args)=0
Notifies the instance that we are entering a certain phase of the exchange.
virtual ePhase phase() const =0
Serialization phase where this instance is involved.
virtual void serialize(const ItemFamilySerializeArgs &args)=0
Serializes into/from buf.
Interface of an entity family.
Definition IItemFamily.h:83
Arguments for the serialization callbacks of entity families.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.