14#include "arcane/utils/Property.h"
16#include "arcane/utils/Ref.h"
17#include "arcane/utils/JSONReader.h"
18#include "arcane/utils/List.h"
19#include "arcane/utils/FatalErrorException.h"
20#include "arcane/utils/ValueConvert.h"
21#include "arcane/utils/CheckedConvert.h"
28namespace Arcane::properties
34auto PropertySettingTraits<String>::
35fromJSON(
const JSONValue& jv) -> InputType
40auto PropertySettingTraits<String>::
41fromString(
const String& v) -> InputType
46void PropertySettingTraits<String>::
47print(std::ostream& o,InputType v)
55auto PropertySettingTraits<StringList>::
56fromJSON(
const JSONValue& jv) -> InputType
59 for(JSONValue jv2 : jv.valueAsArray())
60 string_list.
add(jv2.value());
64auto PropertySettingTraits<StringList>::
65fromString(
const String& v) -> InputType
72void PropertySettingTraits<StringList>::
75 bool is_not_first =
false;
87auto PropertySettingTraits<bool>::
88fromJSON(
const JSONValue& jv) -> InputType
90 return jv.valueAsInt64()!=0;
93auto PropertySettingTraits<bool>::
94fromString(
const String& v) -> InputType
96 if (v==
"0" || v==
"false")
98 if (v==
"1" || v==
"true")
101 "(valid values are '0', '1', 'true', 'false')",v);
104void PropertySettingTraits<bool>::
105print(std::ostream& o,InputType v)
113auto PropertySettingTraits<Int64>::
114fromJSON(
const JSONValue& jv) -> InputType
116 return jv.valueAsInt64();
119auto PropertySettingTraits<Int64>::
120fromString(
const String& v) -> InputType
122 Int64 read_value = 0;
123 bool is_bad = builtInGetValue(read_value,v);
125 ARCANE_FATAL(
"Can not convert '{0}' to type 'Int64' ",v);
129void PropertySettingTraits<Int64>::
130print(std::ostream& o,InputType v)
138auto PropertySettingTraits<Int32>::
139fromJSON(
const JSONValue& jv) -> InputType
144auto PropertySettingTraits<Int32>::
145fromString(
const String& v) -> InputType
147 Int32 read_value = 0;
148 bool is_bad = builtInGetValue(read_value,v);
150 ARCANE_FATAL(
"Can not convert '{0}' to type 'Int32' ",v);
154void PropertySettingTraits<Int32>::
155print(std::ostream& o,InputType v)
168PropertySettingsRegisterer* global_arcane_first_registerer =
nullptr;
169Integer global_arcane_nb_registerer = 0;
172PropertySettingsRegisterer::
173PropertySettingsRegisterer(CreateFunc func,CreateBuildInfoFunc,
const char* name) ARCANE_NOEXCEPT
183void PropertySettingsRegisterer::
186 if (global_arcane_first_registerer==
nullptr){
187 global_arcane_first_registerer =
this;
188 _setPreviousRegisterer(
nullptr);
189 _setNextRegisterer(
nullptr);
192 auto* next = global_arcane_first_registerer->nextRegisterer();
193 _setNextRegisterer(global_arcane_first_registerer);
194 global_arcane_first_registerer =
this;
196 next->_setPreviousRegisterer(
this);
198 ++global_arcane_nb_registerer;
201 auto* p = global_arcane_first_registerer;
202 Integer count = global_arcane_nb_registerer;
203 while (p && count > 0) {
204 p = p->nextRegisterer();
208 std::cerr <<
"Arcane Fatal Error: Registerer '" << m_name
209 <<
"' conflict in registerer registration\n";
212 else if (count > 0) {
213 cout <<
"Arcane Fatal Error: Registerer '" << m_name
214 <<
"' breaks registerer registration (inconsistent shortcut)\n";
226 return global_arcane_first_registerer;
235 return global_arcane_nb_registerer;
241Ref<IPropertySettingsInfo> PropertySettingsRegisterer::
242createSettingsInfoRef()
const
247 s = (m_create_func)(sbi);
259visitAllRegisteredProperties(IPropertyVisitor* visitor)
263 Ref<IPropertySettingsInfo> si = rs->createSettingsInfoRef();
264 si->applyVisitor(visitor);
265 rs = rs->nextRegisterer();
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Enregistreur de paramètres de propriétés.
static PropertySettingsRegisterer * firstRegisterer()
Accès au premier élément de la chaine d'enregistreur.
static Integer nbRegisterer()
Nombre d'enregisteur dans la chaîne.
Int32 toInt32(Int64 v)
Converti un Int64 en un Int32.
void add(ArrayView< T > lhs, ConstArrayView< T > copy_array)
Ajoute le tableau copy_array dans l'instance.
Collection< String > StringCollection
Collection de chaînes de caractères.
List< String > StringList
Tableau de chaînes de caractères unicode.
Int32 Integer
Type représentant un entier.