Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
VariableExpressionImpl.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/* VariableExpressionImpl.cc (C) 2000-2004 */
9/* */
10/* Expression traitant une variable. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14
15#include "arcane/utils/ArcanePrecomp.h"
16
17#include "arcane/IVariableAccessor.h"
18#include "arcane/ISubDomain.h"
19#include "arcane/ArcaneException.h"
20#include "arcane/VariableExpressionImpl.h"
21
22#include "arcane/expr/OperatorMng.h"
23#include "arcane/expr/BadOperationException.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28ARCANE_BEGIN_NAMESPACE
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33VariableExpressionImpl::
34VariableExpressionImpl(IVariable* var)
35: ExpressionImpl()
36, m_variable(var)
37{
38 VariantBase::eType type = VariantBase::fromDataType(m_variable->dataType());
39 m_op = m_op_mng->find(this, type);
40 if (!m_op)
41 throw BadOperationException("VariableExpressionImpl::VariableExpressionImpl","",type);
42}
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47void VariableExpressionImpl::
48assign(IExpressionImpl* expr)
49{
50 ExpressionResult result(m_variable);
51 expr->apply(&result);
52}
53
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
57void VariableExpressionImpl::
58assign(IExpressionImpl* expr, IntegerConstArrayView indices)
59{
60 ExpressionResult result(indices);
61 result.allocate(VariantBase::fromDataType(m_variable->dataType()));
62 expr->apply(&result);
63 m_op->assign(&result, m_variable);
64}
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69void VariableExpressionImpl::
70apply(ExpressionResult* result)
71{
72 m_op->evaluate(result, m_variable);
73}
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78Integer VariableExpressionImpl::
79vectorSize() const
80{
81 if (m_variable->dimension()!=1)
82 return 0;
83 return m_variable->nbElement();
84}
85
86/*---------------------------------------------------------------------------*/
87/*---------------------------------------------------------------------------*/
88
89ARCANE_END_NAMESPACE
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
Int32 Integer
Type représentant un entier.