Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
OperatorMng.cc
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/* OperatorMng.cc (C) 2000-2003 */
9/* */
10/* Stocke tous les types d'opérateur possibles sur les expressions. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/expr/OperatorMng.h"
15
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19ARCANE_BEGIN_NAMESPACE
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24OperatorMng* OperatorMng::m_instance = 0;
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29#define CREATE_ALL_OP(map,name) \
30 map .insert(name##OpMap::value_type \
31 (VariantBase::TReal, new name##OperatorT<Real>())); \
32 map .insert(name##OpMap::value_type \
33 (VariantBase::TInt64, new name##OperatorT<Int64>())); \
34 map .insert(name##OpMap::value_type \
35 (VariantBase::TInt32, new name##OperatorT<Int32>())); \
36 map .insert(name##OpMap::value_type \
37 (VariantBase::TBool, new name##OperatorT<bool>())); \
38 map .insert(name##OpMap::value_type \
39 (VariantBase::TReal2, new name##OperatorT<Real2>())); \
40 map .insert(name##OpMap::value_type \
41 (VariantBase::TReal3, new name##OperatorT<Real3>())); \
42 map .insert(name##OpMap::value_type \
43 (VariantBase::TReal2x2, new name##OperatorT<Real2x2>())); \
44 map .insert(name##OpMap::value_type \
45 (VariantBase::TReal3x3, new name##OperatorT<Real3x3>()));
46
47#define CREATE_OP(map,var,maptype,varname,vartype,operator) \
48 map[var].insert( maptype ::value_type(VariantBase::varname, \
49 new operator##Operator<vartype>()));
50
51/*---------------------------------------------------------------------------*/
52/*---------------------------------------------------------------------------*/
53
54OperatorMng::
55OperatorMng()
56: m_unary_op()
57{
58 //
59 // construction des opérateurs unaires
60 //
61 UnaryExpressionImpl::eOperationType ut;
62 ut = UnaryExpressionImpl::UnarySubstract;
63 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,UnarySubstract)
64 ut = UnaryExpressionImpl::Inverse;
65 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Inverse)
66 ut = UnaryExpressionImpl::Acos;
67 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Acos)
68 ut = UnaryExpressionImpl::Asin;
69 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Asin)
70 ut = UnaryExpressionImpl::Atan;
71 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Atan)
72 ut = UnaryExpressionImpl::Ceil;
73 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Ceil)
74 ut = UnaryExpressionImpl::Cos;
75 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Cos)
76 ut = UnaryExpressionImpl::Cosh;
77 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Cosh)
78 ut = UnaryExpressionImpl::Exp;
79 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Exp)
80 ut = UnaryExpressionImpl::Fabs;
81 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Fabs)
82 ut = UnaryExpressionImpl::Floor;
83 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Floor)
84 ut = UnaryExpressionImpl::Log;
85 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Log)
86 ut = UnaryExpressionImpl::Log10;
87 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Log10)
88 ut = UnaryExpressionImpl::Sin;
89 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Sin)
90 ut = UnaryExpressionImpl::Sinh;
91 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Sinh)
92 ut = UnaryExpressionImpl::Sqrt;
93 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Sqrt)
94 ut = UnaryExpressionImpl::Tan;
95 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Tan)
96 ut = UnaryExpressionImpl::Tanh;
97 CREATE_OP(m_unary_op,ut,UnaryOpMap,TReal,Real,Tanh)
98
99 //
100 // construction des opérateurs binaires
101 //
102 BinaryExpressionImpl::eOperationType bt;
103 // add
104 bt = BinaryExpressionImpl::Add;
105 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,Add)
106 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,Add)
107 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,Add)
108 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2,Real2,Add)
109 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3,Real3,Add)
110 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2x2,Real2x2,Add)
111 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3x3,Real3x3,Add)
112 // substract
113 bt = BinaryExpressionImpl::Substract;
114 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,Substract)
115 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,Substract)
116 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,Substract)
117 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2,Real2,Substract)
118 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3,Real3,Substract)
119 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2x2,Real2x2,Substract)
120 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3x3,Real3x3,Substract)
121 // multiply
122 bt = BinaryExpressionImpl::Multiply;
123 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,Multiply)
124 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,Multiply)
125 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,Multiply)
126 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2,Real2,Multiply)
127 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3,Real3,Multiply)
128 //CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2x2,Real2x2,Multiply)
129 //CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3x3,Real3x3,Multiply)
130 // multiply
131 bt = BinaryExpressionImpl::Divide;
132 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,Divide)
133 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,Divide)
134 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,Divide)
135 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2,Real2,Divide)
136 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3,Real3,Divide)
137 //CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2x2,Real2x2,Divide)
138 //CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3x3,Real3x3,Divide)
139 // minimum (operator< defini sur Real2 et Real3)
140 bt = BinaryExpressionImpl::Minimum;
141 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,Minimum)
142 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,Minimum)
143 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,Minimum)
144 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2,Real2,Minimum)
145 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3,Real3,Minimum)
146 // maximum (operator> defini sur Real2 et Real3)
147 bt = BinaryExpressionImpl::Maximum;
148 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,Maximum)
149 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,Maximum)
150 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,Maximum)
151 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2,Real2,Maximum)
152 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3,Real3,Maximum)
153 // pow
154 bt = BinaryExpressionImpl::Pow;
155 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,Pow)
156 // equal than (defini sur Real2 et Real3)
157 bt = BinaryExpressionImpl::Equal;
158 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,EQ)
159 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,EQ)
160 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,EQ)
161 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2,Real2,EQ)
162 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3,Real3,EQ)
163 // less than (defini sur Real2 et Real3)
164 bt = BinaryExpressionImpl::LessThan;
165 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,LT)
166 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,LT)
167 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,LT)
168 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal2,Real2,LT)
169 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal3,Real3,LT)
170 // less or equal than
171 bt = BinaryExpressionImpl::LessOrEqualThan;
172 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,LOET)
173 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,LOET)
174 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,LOET)
175 // greater than
176 bt = BinaryExpressionImpl::GreaterThan;
177 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,GT)
178 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,GT)
179 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,GT)
180 // greater or equal than
181 bt = BinaryExpressionImpl::GreaterOrEqualThan;
182 CREATE_OP(m_binary_op,bt,BinaryOpMap,TReal,Real,GOET)
183 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt32,Integer,GOET)
184 CREATE_OP(m_binary_op,bt,BinaryOpMap,TInt64,Integer,GOET)
185 // or
186 bt = BinaryExpressionImpl::Or;
187 CREATE_OP(m_binary_op,bt,BinaryOpMap,TBool,bool,Or)
188 // and
189 bt = BinaryExpressionImpl::And;
190 CREATE_OP(m_binary_op,bt,BinaryOpMap,TBool,bool,And)
191
192 //
193 // construction des opérateurs "where"
194 //
195 CREATE_ALL_OP(m_where_op,Where)
196//%% ARCANE_EXPR_SUPPRESS_BEGIN
197 CREATE_ALL_OP(m_variable_op,Variable)
198//%% ARCANE_EXPR_SUPPRESS_END
199 CREATE_ALL_OP(m_litteral_op,Litteral)
200}
201
202OperatorMng::
203~OperatorMng()
204{
205 for (int i=0 ; i<UnaryExpressionImpl::NbOperationType ; i++)
206 {
207 UnaryOpMap& m = m_unary_op[i];
208 for (UnaryOpMap::iterator it=m.begin() ; it!=m.end() ; it++)
209 delete (*it).second;
210 }
211
212 for (int i=0 ; i<BinaryExpressionImpl::NbOperationType ; i++)
213 {
214 BinaryOpMap& m = m_binary_op[i];
215 for (BinaryOpMap::iterator it=m.begin() ; it!=m.end() ; it++)
216 delete (*it).second;
217 }
218
219 for (WhereOpMap::iterator it=m_where_op.begin();
220 it!=m_where_op.end();
221 it++)
222 delete (*it).second;
223
224//%% ARCANE_EXPR_SUPPRESS_BEGIN
225 for (VariableOpMap::iterator it=m_variable_op.begin();
226 it!=m_variable_op.end();
227 it++)
228 delete (*it).second;
229//%% ARCANE_EXPR_SUPPRESS_END
230
231 for (LitteralOpMap::iterator it=m_litteral_op.begin();
232 it!=m_litteral_op.end();
233 it++)
234 delete (*it).second;
235}
236
237/*---------------------------------------------------------------------------*/
238/*---------------------------------------------------------------------------*/
239
240OperatorMng* OperatorMng::
241instance()
242{
243 if (!m_instance)
244 m_instance = new OperatorMng();
245 return m_instance;
246}
247
248/*---------------------------------------------------------------------------*/
249/*---------------------------------------------------------------------------*/
250
251UnaryOperator* OperatorMng::
252find(UnaryExpressionImpl*, VariantBase::eType type,
253 UnaryExpressionImpl::eOperationType operation)
254{
255 UnaryOpMap::iterator it=m_unary_op[operation].find(type);
256 if (it == m_unary_op[operation].end())
257 return 0;
258 else
259 return (*it).second;
260}
261
262BinaryOperator* OperatorMng::
263find(BinaryExpressionImpl*, VariantBase::eType type,
264 BinaryExpressionImpl::eOperationType operation)
265{
266 BinaryOpMap::iterator it=m_binary_op[operation].find(type);
267 if (it == m_binary_op[operation].end())
268 return 0;
269 else
270 return (*it).second;
271}
272
273WhereOperator* OperatorMng::
274find(WhereExpressionImpl*, VariantBase::eType type)
275{
276 WhereOpMap::iterator it=m_where_op.find(type);
277 if (it == m_where_op.end())
278 return 0;
279 else
280 return (*it).second;
281}
282
283LitteralOperator* OperatorMng::
284find(LitteralExpressionImpl*, VariantBase::eType type)
285{
286 LitteralOpMap::iterator it=m_litteral_op.find(type);
287 if (it == m_litteral_op.end())
288 return 0;
289 else
290 return (*it).second;
291}
292
293//%% ARCANE_EXPR_SUPPRESS_BEGIN
294VariableOperator* OperatorMng::
295find(VariableExpressionImpl*, VariantBase::eType type)
296{
297 VariableOpMap::iterator it=m_variable_op.find(type);
298 if (it == m_variable_op.end())
299 return 0;
300 else
301 return (*it).second;
302}
303//%% ARCANE_EXPR_SUPPRESS_END
304
305/*---------------------------------------------------------------------------*/
306/*---------------------------------------------------------------------------*/
307
308ARCANE_END_NAMESPACE
309
310/*---------------------------------------------------------------------------*/
311/*---------------------------------------------------------------------------*/
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120