12#ifndef ARCANE_UTILS_PROPERTY_H
13#define ARCANE_UTILS_PROPERTY_H
22#include "arcane/utils/String.h"
23#include "arcane/utils/PropertyDeclarations.h"
31namespace Arcane::properties
37template <
typename T,
typename DataType>
57 static void print(std::ostream&
o,
InputType v);
58 static const char* typeName() {
return "String"; }
70 static const char* typeName() {
return "StringList"; }
81 static void print(std::ostream&
o,
InputType v);
82 static const char* typeName() {
return "Bool"; }
89 typedef Int32 InputType;
90 typedef Int32 OutputType;
92 static InputType fromString(
const String& v);
93 static void print(std::ostream&
o,InputType v);
94 static const char* typeName() {
return "Int32"; }
101 typedef Int64 InputType;
102 typedef Int64 OutputType;
104 static InputType fromString(
const String& v);
105 static void print(std::ostream&
o,InputType v);
106 static const char* typeName() {
return "Int64"; }
140 virtual void setFromJSON(
const JSONValue& v,T& instance)
const =0;
141 virtual void setFromString(
const String& v,T& instance)
const =0;
142 virtual void print(std::ostream&
o,
const T& instance)
const =0;
216 m_visitor->visit(
p.setting());
225template <
typename T,
typename DataType>
233 typedef typename SettingsTraits::InputType InputType;
234 typedef typename SettingsTraits::OutputType OutputType;
251 typedef std::function<OutputType(
GetterArg a)> GetterType;
258 IPropertySetting* setting()
final
262 const IPropertySetting* setting() const final
272 return m_command_line_argument;
276 return m_description;
280 return SettingsTraits::typeName();
282 ThatClass& addSetter(
const SetterType&
setter)
287 ThatClass& addGetter(
const GetterType&
getter)
292 ThatClass& addCommandLineArgument(
const String& arg)
294 m_command_line_argument = arg;
297 ThatClass& addDescription(
const String& arg)
302 void setInstanceValue(T& instance,InputType value)
const
304 m_setter(SetterArg(instance,value));
306 void setFromJSON(
const JSONValue& v,T& instance)
const override
308 InputType x1 = SettingsTraits::fromJSON(v);
309 setInstanceValue(instance,x1);
311 void setFromString(
const String& v,T& instance)
const override
313 InputType x1 = SettingsTraits::fromString(v);
314 setInstanceValue(instance,x1);
316 void print(std::ostream& o,
const T& instance)
const override
318 o <<
"PROP: name=" << m_name <<
" V=";
320 SettingsTraits::print(o,m_getter(GetterArg(instance)));
325 friend PropertyVisitor<T>& operator<<(PropertyVisitor<T>& o,
const ThatClass& me)
334 String m_command_line_argument;
335 String m_description;
376 T :: applyPropertyVisitor(
pv);
395 const char* name) ARCANE_NOEXCEPT;
403 static Integer nbRegisterer();
414 const char*
name()
const {
return m_name; }
424 void _setNextRegisterer(PropertySettingsRegisterer* s) { m_next = s; }
429 PropertySettingsRegisterer* m_previous =
nullptr;
431 PropertySettingsRegisterer* m_next =
nullptr;
438 CreateFunc m_create_func;
451extern "C++" ARCANE_UTILS_EXPORT
void
452visitAllRegisteredProperties(IPropertyVisitor* visitor);
Déclarations des types utilisés dans Arcane.
Interface d'un paramètre de propriété.
virtual String description() const =0
Description de la propriété
virtual String typeName() const =0
Type de la propriété
virtual String name() const =0
Nom de la propriété
virtual String commandLineArgument() const =0
Nom de l'argument de la ligne de commande (nul si aucun)
Interface d'un visiteur sur une propriété.
Classe de base d'une proriété typée par une classe.
String typeName() const final
Type de la propriété
String name() const final
Nom de la propriété
String commandLineArgument() const final
Nom de l'argument de la ligne de commande (nul si aucun)
String description() const final
Description de la propriété
Enregistreur de paramètres de propriétés.
PropertySettingsRegisterer * previousRegisterer() const
Enregistreur précédent (nullptr si le premier)
const char * name() const
Nom de classe associée.
PropertySettingsRegisterer * nextRegisterer() const
Enregistreur suivant (nullptr si le dernier)
Classe de base d'un visiteur typé sur une propriété.
Référence à une instance.
Vue sur une chaîne de caractères UTF-8.
Chaîne de caractères unicode.