Arcane
v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ConfigurationPropertyReader.h
1
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2
//-----------------------------------------------------------------------------
3
// Copyright 2000-2022 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
/* ConfigurationPropertyReader.h (C) 2000-2020 */
9
/* */
10
/* Lecture de propriétés à partir d'un 'IConfiguration'. */
11
/*---------------------------------------------------------------------------*/
12
#ifndef ARCANE_CORE_CONFIGURATIONPROPERTYREADER_H
13
#define ARCANE_CORE_CONFIGURATIONPROPERTYREADER_H
14
/*---------------------------------------------------------------------------*/
15
/*---------------------------------------------------------------------------*/
16
/*
17
* NOTE: Les classes de ce fichier sont en cours de mise au point.
18
* NOTE: L'API peut changer à tout moment. Ne pas utiliser en dehors de Arcane.
19
*/
20
21
#include "arcane/IConfiguration.h"
22
#include "arcane/utils/Property.h"
23
24
/*---------------------------------------------------------------------------*/
25
/*---------------------------------------------------------------------------*/
26
27
namespace
Arcane::properties
28
{
29
30
/*---------------------------------------------------------------------------*/
31
/*---------------------------------------------------------------------------*/
32
33
template
<
typename
T>
34
class
ConfigurationPropertyReader
35
:
public
PropertyVisitor
<T>
36
{
37
public
:
38
ConfigurationPropertyReader
(
IConfigurationSection
*
cs
,T& instance)
39
: m_configuration_section(
cs
), m_instance(instance){}
40
private
:
41
IConfigurationSection
* m_configuration_section;
42
T& m_instance;
43
public
:
44
void
visit(
const
PropertySettingBase<T>
& s)
override
45
{
46
const
String
&
pname
= s.setting()->name();
47
String
value = m_configuration_section->value(
pname
,
String
());
48
if
(value.null())
49
return
;
50
s.setFromString(value,m_instance);
51
s.print(std::cout,m_instance);
52
}
53
};
54
55
/*---------------------------------------------------------------------------*/
56
/*---------------------------------------------------------------------------*/
63
template
<
typename
T>
inline
void
64
readFromConfiguration(
IConfiguration
*
c
,T& instance)
65
{
66
if
(!
c
)
67
return
;
68
const
char
*
instance_property_name
= T :: propertyClassName();
69
ScopedPtrT<IConfigurationSection>
cs
(
c
->createSection(
instance_property_name
));
70
ConfigurationPropertyReader
reader(
cs
.get(),instance);
71
T :: applyPropertyVisitor(reader);
72
}
73
74
/*---------------------------------------------------------------------------*/
75
/*---------------------------------------------------------------------------*/
76
77
}
// End namespace Arcane::properties
78
79
/*---------------------------------------------------------------------------*/
80
/*---------------------------------------------------------------------------*/
81
82
#endif
Arcane::IConfigurationSection
Interface d'une section de configuration.
Definition
Configuration.h:34
Arcane::IConfiguration
Interface d'une configuration.
Definition
Configuration.h:62
Arcane::LimaWrapper
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition
Lima.cc:120
Arcane::properties::ConfigurationPropertyReader
Definition
ConfigurationPropertyReader.h:36
Arcane::properties::PropertyVisitor
Classe de base d'un visiteur typé sur une propriété.
Definition
Property.h:193
Arccore::String
Chaîne de caractères unicode.
Definition
arccore/src/base/arccore/base/String.h:70
arcane
core
ConfigurationPropertyReader.h
Généré le Lundi 18 Novembre 2024 03:00:20 pour Arcane par
1.9.8