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/core/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(); }
77:
public ICFParamSetter
78,
private VariantGetterT<Type>
82 using VariantGetterT<
Type>::asType;
84 CFParamSetterT(Params* v)
96 void removeValue(
Integer id)
override;
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));
141 if (_checkConvert(
id, s, avalue))
143 return _setIfValid(
id, avalue);
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::
272 m_setter =
new CFParamSetterT<Real>(&m_param_list);
274 m_setter =
new CFParamSetterT<Integer>(&m_param_list);
276 ARCANE_THROW(NotSupportedException,
"Invalid type '{0}'", (
int)type);
299bool CaseTableParams::
308 return m_p->m_param_list.size();
311void CaseTableParams::
314 m_p->m_setter->value(
id, v);
317void CaseTableParams::
320 m_p->m_setter->value(
id, v);
324appendValue(
const String& avalue)
326 return m_p->m_setter->appendValue(avalue);
330setValue(
Integer id,
const String& avalue)
332 return m_p->m_setter->setValue(
id, avalue);
338 return m_p->m_setter->setValue(
id, v);
344 return m_p->m_setter->setValue(
id, v);
347void CaseTableParams::
350 m_p->m_setter->removeValue(
id);
353void CaseTableParams::
354toString(
Integer id, String& str)
const
356 m_p->m_setter->toString(
id, str);
359void CaseTableParams::
362 m_p->setType(new_type);
370 template <
typename T>
375 bool operator()(
const SmallVariant& a,
const SmallVariant& b)
const
389template <
typename T>
void CaseTableParams::
394 const Int32 max_end = nbElement();
399 ConstArrayView<SmallVariant> params = m_p->m_param_list;
400 auto iter = std::lower_bound(params.begin(), params.end(), v2, comp);
401 Int32 pos =
static_cast<Int32>(iter - params.begin());
406 begin = std::clamp(begin, 0, max_end);
407 end = std::clamp(end, 0, max_end);
413void CaseTableParams::
416 _getRange(v, begin, end);
422void CaseTableParams::
425 _getRange(v, begin, end);
431template class CFParamSetterT<Real>;
432template class CFParamSetterT<Integer>;
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
Params m_param_list
List of values.
eError
Types of errors returned by the class.
@ ErrCanNotConvertParamToRightType
Indicates that converting the parameter to the desired type is impossible.
@ ErrNotGreaterThanPrevious
Indicates that the parameter is not greater than the previous one.
@ ErrNotLesserThanNext
Indicates that the parameter is not less than the next one.
eParamType
Type of a function parameter.
@ ParamUnknown
Unknown parameter type.
@ ParamReal
Real type parameter.
@ ParamInteger
Integer type parameter.
Class managing a polymorphic type.
Unicode character string.
1D data vector with value semantics (STL style).
Integer toInteger(Real r)
Converts a Real to Integer.
double toDouble(Real r)
Converts a Real to double.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.