12#ifndef ARCCORE_COMMON_INTERNAL_PROPERTY_H
13#define ARCCORE_COMMON_INTERNAL_PROPERTY_H
17#include "arccore/base/String.h"
19#include "arccore/common/internal/PropertyDeclarations.h"
27namespace Arcane::properties
33template <
typename T,
typename DataType>
53 static InputType fromJSON(
const JSONValue& jv);
54 static InputType fromString(
const String& v);
55 static void print(std::ostream& o, InputType v);
56 static const char* typeName() {
return "String"; }
66 static InputType fromJSON(
const JSONValue& jv);
67 static InputType fromString(
const String& v);
69 static const char* typeName() {
return "StringList"; }
77 typedef bool InputType;
78 typedef bool OutputType;
79 static InputType fromJSON(
const JSONValue& jv);
80 static InputType fromString(
const String& v);
81 static void print(std::ostream& o, InputType v);
82 static const char* typeName() {
return "Bool"; }
90 typedef Int32 InputType;
91 typedef Int32 OutputType;
92 static InputType fromJSON(
const JSONValue& jv);
93 static InputType fromString(
const String& v);
94 static void print(std::ostream& o, InputType v);
95 static const char* typeName() {
return "Int32"; }
103 typedef Int64 InputType;
104 typedef Int64 OutputType;
105 static InputType fromJSON(
const JSONValue& jv);
106 static InputType fromString(
const String& v);
107 static void print(std::ostream& o, InputType v);
108 static const char* typeName() {
return "Int64"; }
146 virtual void setFromJSON(
const JSONValue& v, T& instance)
const = 0;
147 virtual void setFromString(
const String& v, T& instance)
const = 0;
148 virtual void print(std::ostream& o,
const T& instance)
const = 0;
218class GenericPropertyVisitorWrapper
231 m_visitor->visit(p.setting());
242template <
typename T,
typename DataType>
249 typedef PropertySetting<T, DataType> ThatClass;
251 typedef typename SettingsTraits::InputType InputType;
252 typedef typename SettingsTraits::OutputType OutputType;
260 SetterArg(T&
ax, InputType av)
271 GetterArg(
const T&
ax)
279 typedef std::function<void(
SetterArg a)> SetterType;
280 typedef std::function<OutputType(
GetterArg a)> GetterType;
284 PropertySetting(
StringView name, GetterType getter, SetterType setter)
297 IPropertySetting* setting() final
301 const IPropertySetting* setting() const final
311 return m_command_line_argument;
315 return m_description;
319 return SettingsTraits::typeName();
321 ThatClass& addSetter(
const SetterType& setter)
326 ThatClass& addGetter(
const GetterType& getter)
331 ThatClass& addCommandLineArgument(
const String& arg)
333 m_command_line_argument = arg;
336 ThatClass& addDescription(
const String& arg)
341 void setInstanceValue(T& instance, InputType value)
const
345 void setFromJSON(
const JSONValue& v, T& instance)
const override
347 InputType x1 = SettingsTraits::fromJSON(v);
348 setInstanceValue(instance, x1);
350 void setFromString(
const String& v, T& instance)
const override
352 InputType x1 = SettingsTraits::fromString(v);
353 setInstanceValue(instance, x1);
355 void print(std::ostream& o,
const T& instance)
const override
357 o <<
"PROP: name=" << m_name <<
" V=";
359 SettingsTraits::print(o, m_getter(
GetterArg(instance)));
364 friend PropertyVisitor<T>& operator<<(PropertyVisitor<T>& o,
const ThatClass& me)
375 String m_command_line_argument;
376 String m_description;
400template <
typename T>
class PropertySettingsInfo
411 static PropertySettingsInfo*
413 [[maybe_unused]]
int line)
415 auto x =
new PropertySettingsInfo<T>(sbi);
423 T ::applyPropertyVisitor(pv);
432class ARCCORE_COMMON_EXPORT PropertySettingsRegisterer
441 PropertySettingsRegisterer(CreateFunc func, CreateBuildInfoFunc build_info_func,
442 const char*
name) ARCCORE_NOEXCEPT;
478 PropertySettingsRegisterer*
m_next =
nullptr;
498extern "C++" ARCCORE_COMMON_EXPORT
void
Gestion des références à une classe C++.
Classe de base d'une collection fortement typée.
Représente une valeur JSON.
Référence à une instance.
Vue sur une chaîne de caractères UTF-8.
Chaîne de caractères unicode.
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é
PropertySettingsRegisterer * previousRegisterer() const
Enregistreur précédent (nullptr si le premier)
PropertySettingsRegisterer * m_previous
Enregistreur précédent.
const char * m_name
Nom de l'enregistreur.
static PropertySettingsRegisterer * firstRegisterer()
Accès au premier élément de la chaine d'enregistreur.
void _setPreviousRegisterer(PropertySettingsRegisterer *s)
Positionne l'enregistreur précédent.
PropertySettingsRegisterer * m_next
Enregistreur suivant.
const char * name() const
Nom de classe associée.
static Integer nbRegisterer()
Nombre d'enregisteur dans la chaîne.
PropertySettingsRegisterer * nextRegisterer() const
Enregistreur suivant (nullptr si le dernier)
CreateFunc m_create_func
Fonction de création.
void _setNextRegisterer(PropertySettingsRegisterer *s)
Positionne l'enregistreur suivant.
Classe de base d'un visiteur typé sur une propriété.
Espace de nom pour l'utilisation des accélérateurs.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
List< String > StringList
Tableau de chaînes de caractères unicode.
std::int32_t Int32
Type entier signé sur 32 bits.