14#include "arcane/utils/ArcanePrecomp.h"
15#include "arcane/utils/TraceAccessor.h"
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/String.h"
18#include "arcane/utils/ValueConvert.h"
19#include "arcane/utils/FatalErrorException.h"
20#include "arcane/utils/TraceInfo.h"
21#include "arcane/utils/ScopedPtr.h"
22#include "arcane/utils/OStringStream.h"
24#include "arcane/Configuration.h"
25#include "arcane/XmlNode.h"
26#include "arcane/XmlNodeList.h"
76 : m_configuration(configuration), m_base_name(
base_name){}
118 : m_value(value), m_priority(priority){}
119 const String& value()
const {
return m_value; }
120 Integer priority()
const {
return m_priority; }
126 typedef std::map<String,ConfigValue> KeyValueMap;
141 void addValue(
const String& name,
const String& value,Integer priority)
override;
144 void dump()
const override;
145 void dump(std::ostream& o)
const override;
152 KeyValueMap::const_iterator i;
154 i = m_values.find(name);
158 if (i==m_values.end())
161 String value = i->second.value();
162 if (builtInGetValue(v,value))
163 throw FatalErrorException(A_FUNCINFO,String::format(
"Can not convert '{0}' to type '{1}'",value,_typeName((T*)0)));
170 static const char* _typeName(
Int32*) {
return "Int32"; }
171 static const char* _typeName(
Int64*) {
return "Int64"; }
172 static const char* _typeName(
Real*) {
return "Real"; }
173 static const char* _typeName(
bool*) {
return "bool"; }
174 static const char* _typeName(String*) {
return "String"; }
176 void _checkAdd(
const String& name,
const String& value,Integer priority)
178 KeyValueMap::iterator i = m_values.find(name);
180 if (i==m_values.end()){
182 m_values.insert(std::make_pair(name,ConfigValue(value,priority)));
185 Integer orig_priority = i->second.priority();
187 if (priority<orig_priority){
189 i->second = ConfigValue(value,priority);
196 ConfigurationMng* m_configuration_mng;
197 KeyValueMap m_values;
198 ScopedPtrT<IConfigurationSection> m_main_section;
207Int32 ConfigurationSection::
208value(
const String& name,
Int32 default_value)
const
210 return m_configuration->getValue(m_base_name,name,default_value);
213Int64 ConfigurationSection::
214value(
const String& name,
Int64 default_value)
const
216 return m_configuration->getValue(m_base_name,name,default_value);
219Real ConfigurationSection::
220value(
const String& name,
Real default_value)
const
222 return m_configuration->getValue(m_base_name,name,default_value);
225bool ConfigurationSection::
226value(
const String& name,
bool default_value)
const
228 return m_configuration->getValue(m_base_name,name,default_value);
231String ConfigurationSection::
232value(
const String& name,
const String& default_value)
const
234 return m_configuration->getValue(m_base_name,name,default_value);
237String ConfigurationSection::
238value(
const String& name,
const char* default_value)
const
240 return m_configuration->getValue(m_base_name,name,String(default_value));
250Configuration(ConfigurationMng* cm,ITraceMng* tm)
252 m_configuration_mng(cm),
253 m_main_section(new ConfigurationSection(this,String()))
265 for(
auto& i : m_values ){
266 cf->m_values.insert(std::make_pair(i.first,i.second));
287dump(std::ostream& o)
const
289 o <<
"Configuration:\n";
290 for(
auto& i : m_values ){
293 o <<
" name=" <<
s1 <<
" value=" <<
s2 <<
" (" << i.second.priority() <<
")\n";
304 for(
auto& i :
cc->m_values ){
308 _checkAdd(
s1,cv.value(),cv.priority());
320 _checkAdd(name,value,priority);
332, m_default_configuration(0)
334 m_default_configuration = _createConfiguration();
343 delete m_default_configuration;
349Configuration* ConfigurationMng::
350_createConfiguration()
352 return new Configuration(
this,
traceMng());
361 return m_default_configuration;
370 return _createConfiguration();
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
virtual IConfiguration * defaultConfiguration() const
Configuration par défaut.
virtual IConfiguration * createConfiguration()
Créé une nouvelle configuration.
void dump() const override
Affiche les valeurs des paramètres de configuration via le traceMng()
void merge(const IConfiguration *c) override
Fusionne cette configuration avec la configuration c.
IConfigurationSection * createSection(const String &name) const override
Créé une section de configuration.
IConfiguration * clone() const override
Clone cette configuration.
IConfigurationSection * mainSection() const override
Section principale.
void addValue(const String &name, const String &value, Integer priority) override
Ajout une valeur à la configuration.
Gestionnaire de configuration.
Interface d'une section de configuration.
Interface d'une configuration.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Flot de sortie lié à une String.
Exception lorsqu'une erreur fatale est survenue.
Interface du gestionnaire de traces.
Chaîne de caractères unicode.
Classe d'accès aux traces.
ITraceMng * traceMng() const
Gestionnaire de trace.
TraceMessage info() const
Flot pour un message d'information.
Int32 Integer
Type représentant un entier.