14#include "arcane/utils/ValueConvert.h"
15#include "arcane/utils/String.h"
16#include "arcane/utils/NotSupportedException.h"
18#include "arcane/datatype/SmallVariant.h"
20#include "arcane/CaseTableParams.h"
41 ICFParamSetter(Params* v)
44 virtual ~ICFParamSetter() {}
54 virtual void removeValue(
Integer id) = 0;
63 Params& params() {
return *m_param_list; }
65 Integer nbElement()
const {
return m_param_list->size(); }
33class ICFParamSetter {
…};
77:
public ICFParamSetter
78,
private VariantGetterT<Type>
82 using VariantGetterT<Type>::asType;
84 CFParamSetterT(Params* v)
96 void removeValue(
Integer id)
override;
101 bool _checkConvert(
Integer id,
const String& str, Type& value)
const;
76class CFParamSetterT {
…};
112 v = (
Real)(asType(param(
id)));
114template <
class Type>
void CFParamSetterT<Type>::
122 s = String::fromNumber(asType(param(
id)));
134 return _setIfValid(
id, (Type)(v));
140 Type avalue = Type();
141 if (_checkConvert(
id, s, avalue))
143 return _setIfValid(
id, avalue);
149 Type avalue = Type();
151 if (_checkConvert(
id, s, avalue))
154 if (err == CaseTable::ErrNo) {
156 v.setValueAll(avalue);
165 params().remove(index);
172 if (err == CaseTable::ErrNo)
173 param(
id).setValueAll(avalue);
183 if (builtInGetValue(avalue, str))
192 Integer nb_param = nbElement();
194 if (nb_param != 0 &&
id > 0) {
195 Type previous_value = asType(param(
id - 1));
196 if (avalue < previous_value)
201 if (nb_param != 0 && (
id + 1) < nb_param) {
202 Type next_value = asType(param(
id + 1));
203 if (avalue > next_value)
207 return CaseTable::ErrNo;
217 friend class CaseTableParams;
240CaseTableParams::Impl::
251CaseTableParams::Impl::
260void CaseTableParams::Impl::
273 m_setter =
new CFParamSetterT<Real>(&m_param_list);
275 m_setter =
new CFParamSetterT<Integer>(&m_param_list);
277 ARCANE_THROW(NotSupportedException,
"Invalid type '{0}'", (
int)type);
300bool CaseTableParams::
309 return m_p->m_param_list.size();
312void CaseTableParams::
315 m_p->m_setter->value(
id, v);
318void CaseTableParams::
321 m_p->m_setter->value(
id, v);
325appendValue(
const String& avalue)
327 return m_p->m_setter->appendValue(avalue);
331setValue(
Integer id,
const String& avalue)
333 return m_p->m_setter->setValue(
id, avalue);
339 return m_p->m_setter->setValue(
id, v);
345 return m_p->m_setter->setValue(
id, v);
348void CaseTableParams::
351 m_p->m_setter->removeValue(
id);
354void CaseTableParams::
355toString(
Integer id, String& str)
const
357 m_p->m_setter->toString(
id, str);
360void CaseTableParams::
363 m_p->setType(new_type);
371 template <
typename T>
376 bool operator()(
const SmallVariant& a,
const SmallVariant& b)
const
390template <
typename T>
void CaseTableParams::
396 const Int32 max_end = nbElement();
401 ConstArrayView<SmallVariant> params = m_p->m_param_list;
402 auto iter = std::lower_bound(params.begin(), params.end(), v2, comp);
403 Int32 pos =
static_cast<Int32>(iter - params.begin());
408 begin = std::clamp(begin, 0, max_end);
409 end = std::clamp(end, 0, max_end);
415void CaseTableParams::
418 _getRange(v, begin, end);
424void CaseTableParams::
427 _getRange(v, begin, end);
433template class CFParamSetterT<Real>;
434template class CFParamSetterT<Integer>;
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
eError
Type des erreurs retournées par la classe.
@ ErrCanNotConvertParamToRightType
Indique que la conversion du paramètre vers le type souhaité est impossible.
@ ErrNotGreaterThanPrevious
Indique que le paramètre n'est pas supérieur au précédent.
@ ErrNotLesserThanNext
Indique que le paramètre n'est pas inférieur au suivant.
eParamType
Type d'un paramètre d'une fonction.
@ ParamUnknown
Type de paramètre inconnu.
@ ParamReal
Paramètre de type Real.
@ ParamInteger
Paramètre de type Integer.
Classe gérant un type polymorphe.
Chaîne de caractères unicode.
Vecteur 1D de données avec sémantique par valeur (style STL).
Integer toInteger(Real r)
Converti un Real en Integer.
double toDouble(Real r)
Converti un Real en double.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
double Real
Type représentant un réel.
std::int32_t Int32
Type entier signé sur 32 bits.