Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
CaseOptionSimple.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* CaseOptionSimple.cc (C) 2000-2025 */
9/* */
10/* Simple data set option. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/CaseOptionSimple.h"
15
16#include "arcane/utils/ValueConvert.h"
17#include "arcane/utils/ITraceMng.h"
18#include "arcane/utils/FatalErrorException.h"
19#include "arcane/utils/StringBuilder.h"
20#include "arcane/utils/internal/ParameterCaseOption.h"
21
22#include "arcane/core/CaseOptionException.h"
23#include "arcane/core/CaseOptionBuildInfo.h"
24#include "arcane/core/XmlNodeList.h"
25#include "arcane/core/ICaseFunction.h"
26#include "arcane/core/ICaseMng.h"
27#include "arcane/core/ICaseDocument.h"
28#include "arcane/core/CaseNodeNames.h"
29#include "arcane/core/CaseOptionError.h"
30#include "arcane/core/IPhysicalUnitConverter.h"
31#include "arcane/core/IPhysicalUnitSystem.h"
32#include "arcane/core/IStandardFunction.h"
33#include "arcane/core/ICaseDocumentVisitor.h"
34#include "arcane/core/internal/StringVariableReplace.h"
35#include "arcane/core/internal/ICaseMngInternal.h"
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40namespace Arcane
41{
42
43/*---------------------------------------------------------------------------*/
44/*---------------------------------------------------------------------------*/
45
46template <typename T> void
47_copyCaseOptionValue(T& out, const T& in);
48
49template <> void _copyCaseOptionValue(String& out, const String& in)
50{
51 out = in;
52}
53template <> void _copyCaseOptionValue(bool& out, const bool& in)
54{
55 out = in;
56}
57template <> void _copyCaseOptionValue(Real& out, const Real& in)
58{
59 out = in;
60}
61template <> void _copyCaseOptionValue(Int16& out, const Int16& in)
62{
63 out = in;
64}
65template <> void _copyCaseOptionValue(Int32& out, const Int32& in)
66{
67 out = in;
68}
69template <> void _copyCaseOptionValue(Int64& out, const Int64& in)
70{
71 out = in;
72}
73template <> void _copyCaseOptionValue(Real2& out, const Real2& in)
74{
75 out = in;
76}
77template <> void _copyCaseOptionValue(Real3& out, const Real3& in)
78{
79 out = in;
80}
81template <> void _copyCaseOptionValue(Real2x2& out, const Real2x2& in)
82{
83 out = in;
84}
85template <> void _copyCaseOptionValue(Real3x3& out, const Real3x3& in)
86{
87 out = in;
88}
89
90template <typename T> void
91_copyCaseOptionValue(UniqueArray<T>& out, const Array<T>& in)
92{
93 out.copy(in);
94}
95
96template <typename T> void
97_copyCaseOptionValue(UniqueArray<T>& out, const UniqueArray<T>& in)
98{
99 out.copy(in);
100}
101
102template <typename T> void
103_copyCaseOptionValue(Array<T>& out, const Array<T>& in)
104{
105 out.copy(in);
106}
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111CaseOptionSimple::
112CaseOptionSimple(const CaseOptionBuildInfo& cob)
113: CaseOptionBase(cob)
114, m_is_optional(cob.isOptional())
115, m_has_valid_value(true)
116{
117}
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
121
122CaseOptionSimple::
123CaseOptionSimple(const CaseOptionBuildInfo& cob, const String& physical_unit)
124: CaseOptionBase(cob)
125, m_is_optional(cob.isOptional())
126, m_has_valid_value(true)
127, m_default_physical_unit(physical_unit)
128{
129}
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
133
134CaseOptionSimple::
135~CaseOptionSimple()
136{
137 delete m_unit_converter;
138}
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143void CaseOptionSimple::
144_search(bool is_phase1)
145{
146 if (!is_phase1)
147 return;
148
149 //ITraceMng* msg = caseMng()->traceMng();
150 const String& velem_name = name();
151 XmlNodeList velems = rootElement().children(velem_name);
152 XmlNode velem;
153 Integer nb_elem = velems.size();
154 ICaseDocumentFragment* doc = caseDocumentFragment();
155 if (nb_elem >= 1) {
156 velem = velems[0];
157 if (nb_elem >= 2) {
158 CaseOptionError::addWarning(doc, A_FUNCINFO, velem.xpathFullName(),
159 String::format("Only one token of the element is allowed (nb_occur={0})",
160 nb_elem));
161 }
162 }
163
164 // List of command line options.
165 {
166 const ParameterListWithCaseOption& params = caseMng()->_internalImpl()->parameters();
167 const ParameterCaseOption pco{ params.getParameterCaseOption(doc->language()) };
168
169 String reference_input = pco.getParameterOrNull(String::format("{0}/{1}", rootElement().xpathFullName(), velem_name), 1, false);
170 if (!reference_input.null()) {
171 // If the user specified an option that is not present in the
172 // data set, we must create it.
173 if (velem.null()) {
174 velem = rootElement().createElement(name());
175 }
176 velem.setValue(reference_input);
177 }
178 if (!velem.null()) {
179 velem.setValue(StringVariableReplace::replaceWithCmdLineArgs(params, velem.value(), true));
180 }
181 }
182
183 m_element = velem;
184 m_function = 0;
185
186 _searchFunction(velem);
187
188 String physical_unit = m_element.attrValue("unit");
189 if (!physical_unit.null()) {
190 _setPhysicalUnit(physical_unit);
191 if (_allowPhysicalUnit()) {
192 //TODO: CHECK IF THERE IS A DEFAULT_PHYSICAL_UNIT.
193 m_unit_converter = caseMng()->physicalUnitSystem()->createConverter(physical_unit, defaultPhysicalUnit());
194 }
195 else
196 CaseOptionError::addError(doc, A_FUNCINFO, velem.xpathFullName(),
197 String::format("Usage of a physic unit ('{0}') is not allowed for this kind of option",
198 physical_unit));
199 }
200}
201
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
204
205void CaseOptionSimple::
206_setPhysicalUnit(const String& value)
207{
208 m_physical_unit = value;
209}
210
211/*---------------------------------------------------------------------------*/
212/*---------------------------------------------------------------------------*/
213
214String CaseOptionSimple::
215physicalUnit() const
216{
217 return m_physical_unit;
218}
219
220/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
222
223void CaseOptionSimple::
224_searchFunction(XmlNode& velem)
225{
226 if (velem.null())
227 return;
228
229 // Search for a possible associated function
230 String fname = caseDocumentFragment()->caseNodeNames()->function_ref;
231 String func_name = velem.attrValue(fname);
232 if (func_name.null())
233 return;
234
235 ICaseFunction* func = caseMng()->findFunction(func_name);
236 ITraceMng* msg = caseMng()->traceMng();
237 if (!func) {
238 msg->pfatal() << "In element <" << velem.name()
239 << ">: no function named <" << func_name << ">";
240 }
241
242 // Check if it is a standard function
243 IStandardFunction* sf = dynamic_cast<IStandardFunction*>(func);
244 if (sf) {
245 msg->info() << "Use standard function: " << func_name;
246 m_standard_function = sf;
247 }
248 else {
249 msg->info() << "Use function: " << func_name;
250 m_function = func;
251 }
252}
253
254/*---------------------------------------------------------------------------*/
255/*---------------------------------------------------------------------------*/
256
257void CaseOptionSimple::
258_setChangedSinceLastIteration(bool has_changed)
259{
260 m_changed_since_last_iteration = has_changed;
261}
262
263/*---------------------------------------------------------------------------*/
264/*---------------------------------------------------------------------------*/
265
266bool CaseOptionSimple::
267hasChangedSinceLastIteration() const
268{
269 return m_changed_since_last_iteration;
270}
271
272/*---------------------------------------------------------------------------*/
273/*---------------------------------------------------------------------------*/
274
275String CaseOptionSimple::
276xpathFullName() const
277{
278 if (!m_element.null())
279 return m_element.xpathFullName();
280 String fn = rootElement().xpathFullName() + "/" + name();
281 return fn;
282}
283
284/*---------------------------------------------------------------------------*/
285/*---------------------------------------------------------------------------*/
286
287String CaseOptionSimple::
288defaultPhysicalUnit() const
289{
290 return m_default_physical_unit;
291}
292
293/*---------------------------------------------------------------------------*/
294/*---------------------------------------------------------------------------*/
295
296void CaseOptionSimple::
297visit(ICaseDocumentVisitor* visitor) const
298{
299 visitor->applyVisitor(this);
300}
301
302/*---------------------------------------------------------------------------*/
303/*---------------------------------------------------------------------------*/
304
305/*---------------------------------------------------------------------------*/
306/*---------------------------------------------------------------------------*/
307
308/*
309 * Taking into account the unit system but only for
310 * 'Real' or 'RealArray' type options.
311 * TODO: see if it is interesting for other types
312 * like Real2, Real3.
313 * For integer types like 'Integer', it is better not to support conversions because this risks resulting in values
314 * that are too large or zero if the conversion results in a number less than 1
315 * (for example, 5 centimeters converted to meters gives 0).
316 */
317template <typename DataType> static void
318_checkPhysicalConvert(IPhysicalUnitConverter* converter, DataType& value)
319{
320 ARCANE_UNUSED(converter);
321 ARCANE_UNUSED(value);
322}
323
324static void
325_checkPhysicalConvert(IPhysicalUnitConverter* converter, Real& value)
326{
327 if (converter) {
328 Real new_value = converter->convert(value);
329 value = new_value;
330 }
331}
332
333static void
334_checkPhysicalConvert(IPhysicalUnitConverter* converter, RealUniqueArray& values)
335{
336 if (converter) {
337 //TODO use local array to avoid allocation
338 RealUniqueArray input_values(values);
339 converter->convert(input_values, values);
340 }
341}
342
343template <typename DataType> static bool
344_allowConvert(const DataType& value)
345{
346 ARCANE_UNUSED(value);
347 return false;
348}
349
350static bool
351_allowConvert(const Real& value)
352{
353 ARCANE_UNUSED(value);
354 return true;
355}
356
357static bool
358_allowConvert(const RealUniqueArray& value)
359{
360 ARCANE_UNUSED(value);
361 return true;
362}
363
364/*---------------------------------------------------------------------------*/
365/*---------------------------------------------------------------------------*/
366
367template <typename T> CaseOptionSimpleT<T>::
368CaseOptionSimpleT(const CaseOptionBuildInfo& cob)
369: CaseOptionSimple(cob)
370{
371 _copyCaseOptionValue(m_value, Type());
372}
373
374/*---------------------------------------------------------------------------*/
375/*---------------------------------------------------------------------------*/
376
377template <typename T> CaseOptionSimpleT<T>::
378CaseOptionSimpleT(const CaseOptionBuildInfo& cob, const String& physical_unit)
379: CaseOptionSimple(cob, physical_unit)
380{
381 _copyCaseOptionValue(m_value, Type());
382}
383
384/*---------------------------------------------------------------------------*/
385/*---------------------------------------------------------------------------*/
386
387template <typename T> bool CaseOptionSimpleT<T>::
389{
390 using Type = typename CaseOptionTraitsT<T>::ContainerType;
391 return _allowConvert(Type());
392}
393
394namespace
395{
396 // This class aims to remove whitespace at the beginning and end of
397 // a string unless the Type is a 'String'.
398 // If the expected type is not a 'String', we consider that leading and trailing whitespace
399 // is not significant.
400 template <typename Type>
401 class StringCollapser
402 {
403 public:
404
405 static String collapse(const String& str)
406 {
407 return String::collapseWhiteSpace(str);
408 }
409 };
410 template <>
411 class StringCollapser<String>
412 {
413 public:
414
415 static String collapse(const String& str)
417 return str;
418 }
419 };
420} // namespace
421
422/*---------------------------------------------------------------------------*/
423/*---------------------------------------------------------------------------*/
424
433template <typename T> void CaseOptionSimpleT<T>::
434_search(bool is_phase1)
435{
436 CaseOptionSimple::_search(is_phase1);
437 if (!is_phase1)
438 return;
440
441 // If the option is not present in the data set, we take
442 // the default option, unless the option is optional
443 String str_val = (_element().null()) ? _defaultValue() : _element().value();
444 bool has_valid_value = true;
445 if (str_val.null()) {
446 if (!isOptional()) {
448 name(), rootElement());
449 return;
450 }
451 else
452 has_valid_value = false;
453 }
454 _setHasValidValue(has_valid_value);
455 if (has_valid_value) {
456 Type val = Type();
457 str_val = StringCollapser<Type>::collapse(str_val);
458 bool is_bad = builtInGetValue(val, str_val);
459 //cerr << "** TRY CONVERT " << str_val << ' ' << val << ' ' << is_bad << endl;
460 if (is_bad) {
462 name(), rootElement(), str_val, typeToName(val));
463 return;
464 }
465 _checkPhysicalConvert(physicalUnitConverter(), val);
466 m_value = val;
467 }
468 _setIsInitialized();
469}
470
471/*---------------------------------------------------------------------------*/
472/*---------------------------------------------------------------------------*/
473
474template <typename T> void CaseOptionSimpleT<T>::
475setDefaultValue(const Type& def_value)
476{
477 // If a value is provided by the user, we do nothing.
478 if (isPresent())
479 return;
480
481 // Value already initialized. In this case, we also replace the current value.
482 if (_isInitialized())
483 m_value = def_value;
484
485 String s;
486 bool is_bad = builtInPutValue(def_value, s);
487 if (is_bad)
488 ARCANE_FATAL("Can not set default value");
489 _setDefaultValue(s);
490}
491
492/*---------------------------------------------------------------------------*/
493/*---------------------------------------------------------------------------*/
494
495namespace
496{
497 template <typename T>
498 class FunctionConverterT
499 {
500 public:
501
502 void convert(ICaseFunction& tbl, Real t, T& value)
503 {
504 ARCANE_UNUSED(tbl);
505 ARCANE_UNUSED(t);
506 ARCANE_UNUSED(value);
507 throw CaseOptionException("FunctionConverter", "Invalid type");
508 }
509 };
510
511 template <>
512 class FunctionConverterT<Real>
513 {
514 public:
515
516 void convert(ICaseFunction& tbl, Real t, Real& value)
517 {
518 tbl.value(t, value);
519 }
520 };
521
522 template <>
523 class FunctionConverterT<Real3>
524 {
525 public:
526
527 void convert(ICaseFunction& tbl, Real t, Real3& value)
528 {
529 tbl.value(t, value);
530 }
531 };
532
533 template <>
534 class FunctionConverterT<bool>
535 {
536 public:
537
538 void convert(ICaseFunction& tbl, Real t, bool& value)
539 {
540 tbl.value(t, value);
541 }
542 };
543
544 template <>
545 class FunctionConverterT<Integer>
546 {
547 public:
548
549 void convert(ICaseFunction& tbl, Real t, Integer& value)
550 {
551 tbl.value(t, value);
552 }
553 };
554
555 template <>
556 class FunctionConverterT<String>
557 {
558 public:
559
560 void convert(ICaseFunction& tbl, Real t, String& value)
561 {
562 tbl.value(t, value);
563 }
564 };
565
566 /*---------------------------------------------------------------------------*/
567 /*---------------------------------------------------------------------------*/
568
569 template <typename ParamType, typename ValueType>
570 class ComputeFunctionValue
571 {
572 public:
573
574 static void convert(ICaseFunction* func, ParamType t, ValueType& new_value)
575 {
576 FunctionConverterT<ValueType>().convert(*func, t, new_value);
577 }
578 };
579
580} // namespace
581
582/*---------------------------------------------------------------------------*/
583/*---------------------------------------------------------------------------*/
584
586valueAtParameter(Real t) const
587{
588 ICaseFunction* func = function();
589 Type new_value(m_value);
590 if (func) {
591 ComputeFunctionValue<Real, T>::convert(func, t, new_value);
592 _checkPhysicalConvert(physicalUnitConverter(), new_value);
593 }
594 return new_value;
595}
596
597/*---------------------------------------------------------------------------*/
598/*---------------------------------------------------------------------------*/
599
602{
603 ICaseFunction* func = function();
604 Type new_value(m_value);
605 if (func) {
606 ComputeFunctionValue<Integer, T>::convert(func, t, new_value);
607 _checkPhysicalConvert(physicalUnitConverter(), new_value);
608 }
609 return new_value;
610}
611
612/*---------------------------------------------------------------------------*/
613/*---------------------------------------------------------------------------*/
614
615template <typename T> void CaseOptionSimpleT<T>::
616updateFromFunction(Real current_time, Integer current_iteration)
617{
618 _checkIsInitialized();
619 ICaseFunction* func = function();
620 if (!func)
621 return;
622 Type new_value(m_value);
623 switch (func->paramType()) {
625 ComputeFunctionValue<Real, T>::convert(func, current_time, new_value);
626 break;
628 ComputeFunctionValue<Integer, T>::convert(func, current_iteration, new_value);
629 break;
631 break;
632 }
633 _checkPhysicalConvert(physicalUnitConverter(), new_value);
634 this->_setChangedSinceLastIteration(m_value != new_value);
635 ITraceMng* msg = caseMng()->traceMng();
636 msg->debug() << "New value for option <" << name() << "> " << new_value;
637 _copyCaseOptionValue(m_value, new_value);
638}
639
640/*---------------------------------------------------------------------------*/
641/*---------------------------------------------------------------------------*/
642
643template <typename T> void CaseOptionSimpleT<T>::
644print(const String& lang, std::ostream& o) const
645{
646 ARCANE_UNUSED(lang);
647 _checkIsInitialized();
648 if (hasValidValue())
649 o << m_value;
650 else
651 o << "undefined";
652}
653
654/*---------------------------------------------------------------------------*/
655/*---------------------------------------------------------------------------*/
656
657/*---------------------------------------------------------------------------*/
658/*---------------------------------------------------------------------------*/
659
660template <typename T> CaseOptionMultiSimpleT<T>::
663{
664}
665
666/*---------------------------------------------------------------------------*/
667/*---------------------------------------------------------------------------*/
668
669template <typename T> CaseOptionMultiSimpleT<T>::
670CaseOptionMultiSimpleT(const CaseOptionBuildInfo& cob,
671 const String& /*physical_unit*/)
672: CaseOptionMultiSimple(cob)
673{
674}
675
676/*---------------------------------------------------------------------------*/
677/*---------------------------------------------------------------------------*/
678
679template <typename T> CaseOptionMultiSimpleT<T>::
681{
682 const T* avalue = m_view.data();
683 delete[] avalue;
684}
685
686/*---------------------------------------------------------------------------*/
687/*---------------------------------------------------------------------------*/
688
689template <typename T> bool CaseOptionMultiSimpleT<T>::
691{
692 using Type = typename CaseOptionTraitsT<T>::ContainerType;
693 return _allowConvert(Type());
694}
695
696/*---------------------------------------------------------------------------*/
697/*---------------------------------------------------------------------------*/
698
707template <typename T>
709_search(bool is_phase1)
710{
711 if (!is_phase1)
712 return;
713
714 const ParameterListWithCaseOption& params = caseMng()->_internalImpl()->parameters();
715 const ParameterCaseOption pco{ params.getParameterCaseOption(caseDocumentFragment()->language()) };
716
717 String full_xpath = String::format("{0}/{1}", rootElement().xpathFullName(), name());
718 // !!! In XML, we start at 1 and not 0.
719 UniqueArray<Integer> option_in_param;
720 pco.indexesInParam(full_xpath, option_in_param, false);
721
722 XmlNodeList elem_list = rootElement().children(name());
723 Integer asize = elem_list.size();
724
725 bool is_optional = isOptional();
726
727 if (asize == 0 && option_in_param.empty() && is_optional) {
728 return;
729 }
730
731 Integer min_occurs = minOccurs();
732 Integer max_occurs = maxOccurs();
733
734 Integer max_in_param = 0;
735
736 if (!option_in_param.empty()) {
737 max_in_param = option_in_param[0];
738 for (Integer index : option_in_param) {
739 if (index > max_in_param)
740 max_in_param = index;
741 }
742 if (max_occurs >= 0) {
743 if (max_in_param > max_occurs) {
744 StringBuilder msg = "Bad number of occurences in command line (greater than max)";
745 msg += " index_max_in_param=";
746 msg += max_in_param;
747 msg += " max_occur=";
748 msg += max_occurs;
749 msg += " option=";
750 msg += full_xpath;
751 throw CaseOptionException(A_FUNCINFO, msg.toString(), true);
752 }
753 }
754 }
755
756 if (max_occurs >= 0) {
757 if (asize > max_occurs) {
758 StringBuilder msg = "Bad number of occurences (greater than max)";
759 msg += " nb_occur=";
760 msg += asize;
761 msg += " max_occur=";
762 msg += max_occurs;
763 msg += " option=";
764 msg += full_xpath;
765 throw CaseOptionException(A_FUNCINFO, msg.toString(), true);
766 }
767 }
768 // There will always be at least min_occurs options.
769 // If there are not enough options in the dataset and in the command line parameters, we add default values (if there is no default, there will be a crash).
770 Integer final_size = std::max(asize, std::max(min_occurs, max_in_param));
771
772 const Type* old_value = m_view.data();
773 delete[] old_value;
774 using Type = typename CaseOptionTraitsT<T>::ContainerType;
775 Type* ptr_value = new Type[final_size];
776 m_view = ArrayViewType(final_size, ptr_value);
777 this->_setArray(ptr_value, final_size);
778
779 // First, we will have the dataset options: since we cannot define an index
780 // for options in the dataset, they will necessarily be at the beginning and will be contiguous.
781 // Then, if options are missing to reach min_occurs, we add default options.
782 // If there is no default option, there will be an exception.
783 // Finally, the user may have added options from the command line. We add them then.
784 // If the user wants to modify dataset values from the command line, we
785 // replace the options as we read them.
786 for (Integer i = 0; i < final_size; ++i) {
787 String str_val;
788
789 // Command line parameters part.
790 if (option_in_param.contains(i + 1)) {
791 str_val = pco.getParameterOrNull(full_xpath, i + 1, false);
792 }
793
794 // Dataset part.
795 else if (i < asize) {
796 XmlNode velem = elem_list[i];
797 if (!velem.null()) {
798 str_val = velem.value();
799 }
800 }
801
802 // Default value.
803 if (str_val.null()) {
804 str_val = _defaultValue();
805 }
806 else {
807 // In an else: Symbol replacement does not apply to default values in the .axl.
808 str_val = StringVariableReplace::replaceWithCmdLineArgs(params, str_val, true);
809 }
810
811 // Now, this crash also concerns the case where there are no default values and there
812 // are not enough options to reach min_occurs.
813 if (str_val.null())
815 name(), rootElement());
816 Type val = Type();
817 str_val = StringCollapser<Type>::collapse(str_val);
818 bool is_bad = builtInGetValue(val, str_val);
819 if (is_bad)
821 name(), rootElement(), str_val, typeToName(val));
822 //throw CaseOptionException("get_value",name(),rootElement(),str_val,typeToName(val));
823 //ptr_value[i] = val;
824 _copyCaseOptionValue(ptr_value[i], val);
825 }
826}
827
828/*---------------------------------------------------------------------------*/
829/*---------------------------------------------------------------------------*/
830
831template <typename T> void CaseOptionMultiSimpleT<T>::
832print(const String& lang, std::ostream& o) const
833{
834 ARCANE_UNUSED(lang);
835 for (Integer i = 0; i < this->size(); ++i)
836 o << this->_ptr()[i] << " ";
837}
838
839/*---------------------------------------------------------------------------*/
840/*---------------------------------------------------------------------------*/
841
842template <typename T> void CaseOptionMultiSimpleT<T>::
843visit(ICaseDocumentVisitor* visitor) const
844{
845 visitor->applyVisitor(this);
846}
847
848/*---------------------------------------------------------------------------*/
849/*---------------------------------------------------------------------------*/
850
851String CaseOptionSimple::
852_convertFunctionRealToString(ICaseFunction* func, Real t)
853{
854 String v;
855 ComputeFunctionValue<Real, String>::convert(func, t, v);
856 return v;
857}
858
859/*---------------------------------------------------------------------------*/
860/*---------------------------------------------------------------------------*/
861
862String CaseOptionSimple::
863_convertFunctionIntegerToString(ICaseFunction* func, Integer t)
864{
865 String v;
866 ComputeFunctionValue<Integer, String>::convert(func, t, v);
867 return v;
868}
869
870/*---------------------------------------------------------------------------*/
871/*---------------------------------------------------------------------------*/
872
873template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real>;
874template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real2>;
875template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real3>;
876template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real2x2>;
877template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real3x3>;
878template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<bool>;
879template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Int16>;
880template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Int32>;
881template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Int64>;
882template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<String>;
883
884template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<RealArray>;
885template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real2Array>;
886template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real3Array>;
887template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real2x2Array>;
888template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Real3x3Array>;
889template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<BoolArray>;
890template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Int16Array>;
891template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Int32Array>;
892template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<Int64Array>;
893template class ARCANE_TEMPLATE_EXPORT CaseOptionSimpleT<StringArray>;
894
895template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real>;
896template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real2>;
897template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real3>;
898template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real2x2>;
899template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real3x3>;
900template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<bool>;
901template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Int16>;
902template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Int32>;
903template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Int64>;
904template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<String>;
905
906template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<RealArray>;
907template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real2Array>;
908template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real3Array>;
909template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real2x2Array>;
910template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Real3x3Array>;
911template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<BoolArray>;
912template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Int16Array>;
913template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Int32Array>;
914template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<Int64Array>;
915template class ARCANE_TEMPLATE_EXPORT CaseOptionMultiSimpleT<StringArray>;
916
917/*---------------------------------------------------------------------------*/
918/*---------------------------------------------------------------------------*/
919
920} // End namespace Arcane
921
922/*---------------------------------------------------------------------------*/
923/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
bool empty() const
Capacity (number of allocated elements) of the vector.
bool contains(ConstReferenceType v) const
True if the array contains the value element v.
constexpr pointer _ptr() noexcept
Returns a pointer to the array.
constexpr const_pointer data() const noexcept
Pointer to the start of the view.
void _setArray(pointer v, Integer s) noexcept
Modifies the pointer and size of the array.
Base class for 1D data vectors.
Base class for a data set option.
String name() const
Returns the option name corresponding to the data set language.
String _defaultValue() const
Returns the default value of the option or 0 if none exists.
ICaseMng * caseMng() const
Case manager.
ICaseDocumentFragment * caseDocumentFragment() const
Returns the document associated with this option.
bool isOptional() const
Allows knowing if an option is optional.
Integer maxOccurs() const
Maximum number of occurrences (for a multiple option) (-1 == unbounded).
XmlNode rootElement() const
Returns the root element of the DOM.
Integer minOccurs() const
Minimum number of occurrences (for a multiple option).
Information for building a dataset option.
static void addInvalidTypeError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const XmlNode &parent, const String &value, const String &expected_type)
Error when a dataset value is not of the correct type. This error is collective.
static void addOptionNotFoundError(ICaseDocumentFragment *document, const TraceInfo &where, const String &node_name, const XmlNode &parent)
Error when a dataset option is not found. This error is collective.
Exception related to the dataset.
Data set option of simple type list (real, integer, boolean, ...).
typename CaseOptionTraitsT< T >::ContainerType Type
Type of the option value.
typename CaseOptionTraitsT< T >::ArrayViewType ArrayViewType
Type of the view on the option values.
void print(const String &lang, std::ostream &o) const override
Prints the option value in the language lang, to the stream o.
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.
Simple data set option (real, integer, boolean, ...).
virtual void _search(bool is_phase1)
Searches for the option value in the data set.
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.
virtual void updateFromFunction(Real current_time, Integer current_iteration)
void setDefaultValue(const Type &def_value)
Sets the default value of the option.
Base class for simple options (single value).
XmlNode m_element
Option element.
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.
IPhysicalUnitConverter * physicalUnitConverter() const
Physical unit converter.
bool isPresent() const
Returns true if the option is present.
Interface of a part of a dataset.
Visitor interface for a dataset option.
Interface of a dataset function.
@ ParamUnknown
Unknown parameter type.
@ ParamReal
Real type parameter.
@ ParamInteger
Integer type parameter.
virtual eParamType paramType() const =0
Function parameter type.
Interface of a unit converter.
virtual TraceMessage pfatal()=0
Stream for a parallel fatal error message.
virtual TraceMessage info()=0
Stream for an information message.
virtual TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium)=0
Stream for a debug message.
Class representing the set of parameters that can modify the dataset options.
void indexesInParam(const String &xpath_before_index, const String &xpath_after_index, UniqueArray< Integer > &indexes) const
Method allowing retrieval of the index or indices of the option.
String getParameterOrNull(const String &xpath_before_index, const String &xpath_after_index, Integer index) const
Method allowing retrieval of an option's value.
Parameter list with information to override dataset options.
ParameterCaseOption getParameterCaseOption(const String &language) const
Method to retrieve an object of type ParameterCaseOption.
Class managing a 2-dimensional real vector.
Definition Real2.h:122
Class managing a 2x2 matrix of reals.
Definition Real2x2.h:55
Class managing a 3-dimensional real vector.
Definition Real3.h:132
Class managing a 3x3 real matrix.
Definition Real3x3.h:67
Unicode character string constructor.
String toString() const
Returns the constructed character string.
bool null() const
Returns true if the string is null.
Definition String.cc:306
static String collapseWhiteSpace(const String &rhs)
Performs whitespace character normalization.
Definition String.cc:454
1D data vector with value semantics (STL style).
List of nodes of a DOM tree.
Definition XmlNodeList.h:36
Node of a DOM tree.
Definition XmlNode.h:51
String attrValue(const String &name, bool throw_exception=false) const
Value of attribute name.
Definition XmlNode.cc:234
String value() const
Node value.
Definition XmlNode.cc:208
bool null() const
True if the node is null.
Definition XmlNode.h:303
String name() const
Node name.
Definition XmlNode.cc:141
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
bool builtInPutValue(const String &v, String &s)
Converti la valeur v dans la chaîne s.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
UniqueArray< Real > RealUniqueArray
Dynamic 1D array of reals.
Definition UtilsTypes.h:349
std::int16_t Int16
Signed integer type of 16 bits.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.
Type
Type of JSON value.
Definition rapidjson.h:730