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"; }
148 virtual void setFromJSON(
const JSONValue& v, T& instance)
const = 0;
149 virtual void setFromString(
const String& v, T& instance)
const = 0;
150 virtual void print(std::ostream& o,
const T& instance)
const = 0;
222class GenericPropertyVisitorWrapper
235 m_visitor->visit(p.setting());
246template <
typename T,
typename DataType>
253 typedef PropertySetting<T, DataType> ThatClass;
255 typedef typename SettingsTraits::InputType InputType;
256 typedef typename SettingsTraits::OutputType OutputType;
264 SetterArg(T&
ax, InputType av)
275 GetterArg(
const T&
ax)
283 typedef std::function<void(
SetterArg a)> SetterType;
284 typedef std::function<OutputType(
GetterArg a)> GetterType;
288 PropertySetting(
StringView name, GetterType getter, SetterType setter)
301 IPropertySetting* setting() final
305 const IPropertySetting* setting() const final
315 return m_command_line_argument;
319 return m_description;
323 return SettingsTraits::typeName();
325 ThatClass& addSetter(
const SetterType& setter)
330 ThatClass& addGetter(
const GetterType& getter)
335 ThatClass& addCommandLineArgument(
const String& arg)
337 m_command_line_argument = arg;
340 ThatClass& addDescription(
const String& arg)
345 void setInstanceValue(T& instance, InputType value)
const
349 void setFromJSON(
const JSONValue& v, T& instance)
const override
351 InputType x1 = SettingsTraits::fromJSON(v);
352 setInstanceValue(instance, x1);
354 void setFromString(
const String& v, T& instance)
const override
356 InputType x1 = SettingsTraits::fromString(v);
357 setInstanceValue(instance, x1);
359 void print(std::ostream& o,
const T& instance)
const override
361 o <<
"PROP: name=" << m_name <<
" V=";
363 SettingsTraits::print(o, m_getter(
GetterArg(instance)));
368 friend PropertyVisitor<T>& operator<<(PropertyVisitor<T>& o,
const ThatClass& me)
379 String m_command_line_argument;
380 String m_description;
404template <
typename T>
class PropertySettingsInfo
415 static PropertySettingsInfo*
417 [[maybe_unused]]
int line)
419 auto x =
new PropertySettingsInfo<T>(sbi);
427 T ::applyPropertyVisitor(pv);
437class ARCCORE_COMMON_EXPORT PropertySettingsRegisterer
446 PropertySettingsRegisterer(CreateFunc func, CreateBuildInfoFunc build_info_func,
447 const char*
name) ARCCORE_NOEXCEPT;
483 PropertySettingsRegisterer*
m_next =
nullptr;
504extern "C++" ARCCORE_COMMON_EXPORT
void
Management of references to a C++ class.
Base class for a strongly typed collection.
Reference to an instance.
View of a UTF-8 character string.
Unicode character string.
Property parameter interface.
virtual String description() const =0
Property description.
virtual String typeName() const =0
Property type.
virtual String name() const =0
Property name.
virtual String commandLineArgument() const =0
Command line argument name (null if none).
Property visitor interface.
Base class of a property typed by a class.
String typeName() const final
Property type.
String name() const final
Property name.
String commandLineArgument() const final
Command line argument name (null if none).
String description() const final
Property description.
PropertySettingsRegisterer * previousRegisterer() const
Previous registrar (nullptr if the first).
PropertySettingsRegisterer * m_previous
Previous registrar.
const char * m_name
Registrar name.
static PropertySettingsRegisterer * firstRegisterer()
Access to the first element of the registrar chain.
void _setPreviousRegisterer(PropertySettingsRegisterer *s)
Positions the previous registrar.
PropertySettingsRegisterer * m_next
Next registrar.
const char * name() const
Associated class name.
static Integer nbRegisterer()
Number of registrars in the chain.
PropertySettingsRegisterer * nextRegisterer() const
Next registrar (nullptr if the last).
CreateFunc m_create_func
Creation function.
void _setNextRegisterer(PropertySettingsRegisterer *s)
Positions the next registrar.
Base class of a typed visitor on a property.
Namespace for accelerator usage.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
List< String > StringList
Unicode string list.
std::int32_t Int32
Signed integer type of 32 bits.