Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
SendReceiveInfo.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* MPMessage.h (C) 2000-2020 */
9/* */
10/* Message. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_MESSAGEPASSING_SENDRECEIVCEINFO_H
13#define ARCCORE_MESSAGEPASSING_MESSAGE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19#include <cstddef>
20#include <iosfwd>
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
26{
34class ARCCORE_MESSAGEPASSING_EXPORT MessageId
35{
36 union _Message
37 {
38 int i;
39 long l;
40 std::size_t st;
41 void* v;
42 const void* cv;
43 };
44
45 enum Type
46 {
47 T_Int,
48 T_Long,
49 T_SizeT,
50 T_Ptr,
51 T_Null
52 };
53
54 public:
55
56 MessageId()
57 : m_return_value(0)
58 {
59 m_type = T_Null;
60 m_message = null_message;
61 }
62
63 MessageId(int return_value,void* amessage)
64 : m_return_value(return_value)
65 {
66 m_type = T_Ptr;
67 m_message.v = amessage;
68 }
69
70 MessageId(int return_value,const void* amessage)
71 : m_return_value(return_value)
72 {
73 m_type = T_Ptr;
74 m_message.cv = amessage;
75 }
76
77 MessageId(int return_value,int amessage)
78 : m_return_value(return_value)
79 {
80 m_type = T_Int;
81 m_message.i = amessage;
82 }
83
84 MessageId(int return_value,long amessage)
85 : m_return_value(return_value)
86 {
87 m_type = T_Long;
88 m_message.l = amessage;
89 }
90
91 MessageId(int return_value,std::size_t amessage)
92 : m_return_value(return_value)
93 {
94 m_type = T_SizeT;
95 m_message.st = amessage;
96 }
97
98 MessageId(const MessageId& rhs)
99 : m_return_value(rhs.m_return_value), m_type(rhs.m_type)
100 {
101 m_message.cv = rhs.m_message.cv;
102 }
103
104 const MessageId& operator=(const MessageId& rhs)
105 {
106 m_return_value = rhs.m_return_value;
107 m_type = rhs.m_type;
108 m_message.cv = rhs.m_message.cv;
109 return (*this);
110 }
111
112 public:
113
114 template<typename T>
115 explicit operator const T*() const { return (const T*)m_message.cv; }
116 template<typename T>
117 explicit operator T*() const { return (T*)m_message.v; }
118 explicit operator int() const { return m_message.i; }
119 explicit operator long() const { return m_message.l; }
120 explicit operator size_t() const { return m_message.st; }
121
122 public:
123
124 //int returnValue() const { return m_return_value; }
125 bool isValid() const
126 {
127 if (m_type==T_Null)
128 return false;
129 if (m_type==T_Int)
130 return m_message.i!=null_message.i;
131 if (m_type==T_Long)
132 return m_message.l!=null_message.l;
133 if (m_type==T_SizeT)
134 return m_message.st!=null_message.st;
135 return m_message.cv!=null_message.cv;
136 }
137 void* messageAsVoidPtr() const { return m_message.v; }
138
139 static void setNullMessage(MessageId r) { null_message = r.m_message; }
140
141 void reset() {
142 m_message = null_message;
143 }
144
145 void print(std::ostream& o) const;
146
147 private:
148
149 int m_return_value;
150 int m_type;
151 _Message m_message;
152
153 static _Message null_message;
154};
155
156/*---------------------------------------------------------------------------*/
157/*---------------------------------------------------------------------------*/
158
159inline std::ostream&
160operator<<(std::ostream& o,const MessageId& pmessage)
161{
162 pmessage.print(o);
163 return o;
164}
165
166/*---------------------------------------------------------------------------*/
167/*---------------------------------------------------------------------------*/
168
169} // End namespace Arccore::MessagePassing
170
171/*---------------------------------------------------------------------------*/
172/*---------------------------------------------------------------------------*/
173
174#endif
175
Déclarations générales de la composante 'message_passing'.
std::ostream & operator<<(std::ostream &o, eExecutionPolicy exec_policy)
Affiche le nom de la politique d'exécution.
Espace de nommage contenant les types et déclarations qui gèrent le mécanisme de parallélisme par éch...
Type
Type of JSON value.
Definition rapidjson.h:665