Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ScalarVariant.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/* ScalarVariant.h (C) 2000-2022 */
9/* */
10/* Type de base polymorphe pour les scalaires (dimension 0). */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_DATATYPE_SCALARVARIANT_H
13#define ARCANE_DATATYPE_SCALARVARIANT_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
18#include "arcane/utils/Real2.h"
19#include "arcane/utils/Real3.h"
20#include "arcane/utils/Real2x2.h"
21#include "arcane/utils/Real3x3.h"
22
23#include "arcane/datatype/VariantBase.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33/*!
34 * \internal
35 * \brief Type de base polymorphe pour les scalaires (dimension 0).
36 */
37class ARCANE_DATATYPE_EXPORT ScalarVariant
38: public VariantBase
39{
40 private:
41
42 public:
45 ScalarVariant(Real v);
50 ScalarVariant(Int32 v);
51 ScalarVariant(Int64 v);
52 ScalarVariant(bool v);
53 ScalarVariant(const String& v);
55
56 ScalarVariant& operator= (const ScalarVariant& v);
57
58 bool isInteger() const { return m_type==TInt32 || m_type==TInt64; }
59
60 void setValue(Real v) { m_real_value = v; m_type = TReal; }
61 void setValue(Real2 v) { m_real2_value = v; m_type = TReal2; }
62 void setValue(Real3 v) { m_real3_value = v; m_type = TReal3; }
63 void setValue(Real2x2 v) { m_real2x2_value = v; m_type = TReal2x2; }
64 void setValue(Real3x3 v) { m_real3x3_value = v; m_type = TReal3x3; }
65 void setValue(Int32 v) { m_int32_value = v; m_type = TInt32; }
66 void setValue(Int64 v) { m_int64_value = v; m_type = TInt64; }
67 void setValue(bool v) { m_bool_value = v; m_type = TBool; }
68 void setValue(const String& v) { m_string_value = v; m_type = TString; }
69
70 void value(Real& v) const { v = m_real_value; }
71 void value(Real2& v) const { v = m_real2_value; }
72 void value(Real3& v) const { v = m_real3_value; }
73 void value(Real2x2& v) const { v = m_real2x2_value; }
74 void value(Real3x3& v) const { v = m_real3x3_value; }
75 void value(Int32& v) const { v = m_int32_value; }
76 void value(Int64& v) const { v = m_int64_value; }
77 void value(bool& v) const { v = m_bool_value; }
78 void value(String& v) const { v = m_string_value; }
79
80 Real asReal() const { return m_real_value; }
81 Real2 asReal2() const { return m_real2_value; }
82 Real3 asReal3() const { return m_real3_value; }
83 Real2x2 asReal2x2() const { return m_real2x2_value; }
84 Real3x3 asReal3x3() const { return m_real3x3_value; }
85 Integer asInteger() const;
86 Int32 asInt32() const { return m_int32_value; }
87 Int64 asInt64() const { return m_int64_value; }
88 bool asBool() const { return m_bool_value; }
89 const String& asString() const { return m_string_value; }
90
91 private:
92
93 Real m_real_value; //!< Valeur de type réel
94 Real2 m_real2_value; //!< Valeur de type vecteur de 2 réels
95 Real3 m_real3_value; //!< Valeur de type vecteur de 3 réel
96 Real2x2 m_real2x2_value; //!< Valeur de type matrice 2x2 de réels
97 Real3x3 m_real3x3_value; //!< Valeur de type matrice 3x3 de réels
98 Int32 m_int32_value; //!< Valeur de type entier 32 bits
99 Int64 m_int64_value; //!< Valeur de type eniter 64 bits
100 bool m_bool_value; //!< Valeur de type entier booléenne
101 String m_string_value; //!< Valeur de type chaîne de caractère.
102};
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107} // End namespace Arcane
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
112#endif
Classe gérant un vecteur de réel de dimension 2.
Definition Real2.h:121
Classe gérant une matrice de réel de dimension 2x2.
Definition Real2x2.h:53
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Classe gérant une matrice de réel de dimension 3x3.
Definition Real3x3.h:66
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-