12#ifndef ARCANE_CASEOPTIONSIMPLE_H
13#define ARCANE_CASEOPTIONSIMPLE_H
17#include "arcane/core/ICaseOptions.h"
18#include "arcane/core/CaseOptionBase.h"
34#define ARCANE_CASEOPTION_CHECK_IS_INITIALIZED _checkIsInitialized()
36#define ARCANE_CASEOPTION_CHECK_IS_INITIALIZED
42template <
typename Type>
47 using ContainerType = Type;
48 using ReferenceType = Type&;
49 using ConstReferenceType =
const Type&;
64template <
typename Type>
83class ARCANE_CORE_EXPORT CaseOptionSimple
84:
public CaseOptionBase
95 bool isPresent()
const {
return !m_element.null(); }
104 XmlNode element()
const {
return m_element; }
128 bool hasChangedSinceLastIteration()
const;
130 String xpathFullName()
const;
135 String defaultPhysicalUnit()
const;
137 String physicalUnit()
const;
165 void _search(
bool is_phase1)
override;
166 virtual bool _allowPhysicalUnit() = 0;
167 void _setChangedSinceLastIteration(
bool has_changed);
168 void _searchFunction(
XmlNode& velem);
169 void _setPhysicalUnit(
const String& value);
170 void _setHasValidValue(
bool v) { m_has_valid_value = v; }
171 XmlNode _element()
const {
return m_element; }
173 static String _convertFunctionRealToString(ICaseFunction* func, Real t);
174 static String _convertFunctionIntegerToString(ICaseFunction* func, Integer t);
179 ICaseFunction* m_function =
nullptr;
180 IStandardFunction* m_standard_function =
nullptr;
182 IPhysicalUnitConverter* m_unit_converter =
nullptr;
183 bool m_changed_since_last_iteration =
false;
184 bool m_is_optional =
false;
185 bool m_has_valid_value =
false;
186 String m_default_physical_unit;
187 String m_physical_unit;
210class CaseOptionSimpleT
211:
public CaseOptionSimple
215 typedef CaseOptionSimpleT<T> ThatClass;
217 typedef typename CaseOptionTraitsT<T>::ContainerType
Type;
228 ARCANE_CORE_EXPORT
virtual void print(
const String& lang, std::ostream& o)
const;
233 ARCANE_CASEOPTION_CHECK_IS_INITIALIZED;
251 operator ThatClass*() {
return this; }
252 operator const ThatClass*()
const {
return this; }
253 const ThatClass* operator->()
const {
return this; }
254 static Real castTo__Arcane_Real(
const ThatClass& v)
290 ARCANE_CASEOPTION_CHECK_IS_INITIALIZED;
291 return isPresent() ? m_value : arg_value;
296 ARCANE_CORE_EXPORT
virtual void _search(
bool is_phase1);
297 ARCANE_CORE_EXPORT
virtual bool _allowPhysicalUnit();
307class ARCANE_CORE_EXPORT CaseOptionMultiSimple
308:
public CaseOptionBase
313 : CaseOptionBase(cob)
330class CaseOptionMultiSimpleT
331:
public CaseOptionMultiSimple
332#ifdef ARCANE_HAS_PRIVATE_CASEOPTIONSMULTISIMPLE_BASE_CLASS
341 using Type =
typename CaseOptionTraitsT<T>::ContainerType;
342 using ReferenceType =
typename CaseOptionTraitsT<T>::ReferenceType;
343 using ConstReferenceType =
typename CaseOptionTraitsT<T>::ConstReferenceType;
353 ARCANE_CORE_EXPORT ~CaseOptionMultiSimpleT();
357 ARCCORE_DEPRECATED_2021(
"Use view() instead")
362 ARCCORE_DEPRECATED_2021(
"Use view() instead")
369 ARCCORE_DEPRECATED_2021(
"Use view() instead")
377 ARCCORE_DEPRECATED_2021(
"Use view() instead")
396 ReferenceType operator[](
Integer i) {
return m_view[i]; }
400 ARCANE_CORE_EXPORT
void print(
const String& lang, std::ostream& o)
const override;
409 const T& value(
Integer index)
const {
return this->operator[](index); }
411 ARCANE_CORE_EXPORT
void visit(ICaseDocumentVisitor* visitor)
const override;
412 bool isPresent()
const {
return !m_view.empty(); }
416 void _search(
bool is_phase1)
override;
417 virtual bool _allowPhysicalUnit();
Modifiable view of an array of type T.
constexpr ArrayView() noexcept
Constructs an empty view.
constexpr Integer size() const noexcept
Returns the size of the array.
Base class for 1D data vectors.
typename CaseOptionTraitsT< T >::ConstArrayViewType ConstArrayViewType
Type of the constant view on the option values.
ConstArrayViewType view() const
Constant view on the option elements.
typename CaseOptionTraitsT< T >::ContainerType Type
Type of the option value.
typename CaseOptionTraitsT< T >::ArrayViewType ArrayViewType
Type of the view on the option values.
void updateFromFunction(Real, Integer) override
Updates the option value from a function.
void print(const String &lang, std::ostream &o) const override
Prints the option value in the language lang, to the stream o.
ICaseFunction * function() const override
Returns the function linked to this option or nullptr if none exists.
void visit(ICaseDocumentVisitor *visitor) const override
Applies the visitor to this option.
void _search(bool is_phase1) override
Searches for the option value in the dataset.
ArrayViewType view()
View on the option elements.
Simple data set option (real, integer, boolean, ...).
const Type & valueIfPresentOrArgument(const Type &arg_value)
Returns the value of the option if isPresent()==true or otherwise arg_value.
virtual void _search(bool is_phase1)
Searches for the option value in the data set.
ARCANE_DEPRECATED Type operator()(Real t) const
Returns the value of the option for the real parameter t.
Type valueAtParameter(Real t) const
Returns the value of the option for the real parameter t.
CaseOptionTraitsT< T >::ContainerType Type
Option type.
virtual void print(const String &lang, std::ostream &o) const
Prints the option value in the language lang, to the stream o.
Type valueAtParameter(Integer t) const
Returns the value of the option for the integer parameter t.
const Type & value() const
Returns the value of the option.
const Type & operator()() const
Returns the value of the option.
ARCANE_DEPRECATED Type operator()(Integer t) const
Returns the value of the option for the integer parameter t.
virtual void updateFromFunction(Real current_time, Integer current_iteration)
void setDefaultValue(const Type &def_value)
Sets the default value of the option.
bool hasValidValue() const
Indicates if the option has an invalid value.
ICaseFunction * function() const override
Function associated with this option (0 if none).
bool isOptional() const
Indicates if the option is optional.
virtual IStandardFunction * standardFunction() const
Standard function associated with this option (0 if none).
ARCANE_DEPRECATED_LONG_TERM("Y2022: Do not access XML item from option") XmlNode element() const
Returns the element of the option.
IPhysicalUnitConverter * physicalUnitConverter() const
Physical unit converter.
bool isPresent() const
Returns true if the option is present.
Constant view of an array of type T.
Visitor interface for a dataset option.
Interface managing a standard function.
Unicode character string.
1D data vector with value semantics (STL style).
-- 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.