Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Configuration.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* Configuration.h (C) 2000-2020 */
9/* */
10/* Management of execution configuration options. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CONFIGURATION_H
13#define ARCANE_CONFIGURATION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \brief Interface for a configuration section.
30 *
31 * This interface allows retrieving the values of a configuration option.
32 */
33class ARCANE_CORE_EXPORT IConfigurationSection
34{
35 public:
36
37 virtual ~IConfigurationSection() {} //!< Frees resources
38
39 public:
40
41 virtual Int32 value(const String& name, Int32 default_value) const = 0;
42 virtual Int64 value(const String& name, Int64 default_value) const = 0;
43 virtual Real value(const String& name, Real default_value) const = 0;
44 virtual bool value(const String& name, bool default_value) const = 0;
45 virtual String value(const String& name, const String& default_value) const = 0;
46 virtual String value(const String& name, const char* default_value) const = 0;
47
48 virtual Integer valueAsInteger(const String& name, Integer default_value) const = 0;
49 virtual Int32 valueAsInt32(const String& name, Int32 default_value) const = 0;
50 virtual Int64 valueAsInt64(const String& name, Int64 default_value) const = 0;
51 virtual Real valueAsReal(const String& name, Real default_value) const = 0;
52 virtual bool valueAsBool(const String& name, bool default_value) const = 0;
53 virtual String valueAsString(const String& name, const String& default_value) const = 0;
54};
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58/*!
59 * \brief Interface for a configuration.
60 */
61class ARCANE_CORE_EXPORT IConfiguration
62{
63 public:
64
65 virtual ~IConfiguration() {} //!< Frees resources
66
67 public:
68
69 /*!
70 * \brief Creates a configuration section.
71 *
72 * The returned instance must be destroyed by the delete operator.
73 */
74 virtual IConfigurationSection* createSection(const String& name) const = 0;
75
76 /*!
77 * \brief Main section.
78 *
79 * The returned instance remains the property of this instance
80 * and should not be destroyed.
81 */
82 virtual IConfigurationSection* mainSection() const = 0;
83
84 /*!
85 * \brief Adds a value to the configuration.
86 *
87 * Adds the value \a value for the name \a name to the configuration.
88 * The new value will have priority \a priority. If a value for name
89 * \a name already exists, it is replaced by \a value if \a priority
90 * is lower than the current priority.
91 */
92 virtual void addValue(const String& name, const String& value, Integer priority) = 0;
93
94 /*!
95 * \brief Clones this configuration.
96 */
97 virtual IConfiguration* clone() const = 0;
98
99 /*!
100 * \brief Merges this configuration with configuration \a c.
101 *
102 * If an option exists in both this configuration and \a c, the one
103 * with the lowest priority is kept.
104 */
105 virtual void merge(const IConfiguration* c) = 0;
106
107 //! Displays the values of the configuration parameters via traceMng()
108 virtual void dump() const = 0;
109
110 //! Displays the values of the configuration parameters to the stream o
111 virtual void dump(std::ostream& ostr) const = 0;
112};
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117/*!
118 * \brief Configuration manager.
119 */
120class ARCANE_CORE_EXPORT IConfigurationMng
121{
122 public:
123
124 virtual ~IConfigurationMng() {} //!< Frees resources
125
126 public:
127
128 //! Default configuration.
130
131 /*!
132 * \brief Creates a new configuration.
133 *
134 * The returned instance must be destroyed by the delete operator.
135 */
137};
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142} // End namespace Arcane
143
144/*---------------------------------------------------------------------------*/
145/*---------------------------------------------------------------------------*/
146
147#endif
Arcane configuration file.
Configuration manager.
virtual IConfiguration * createConfiguration()=0
Creates a new configuration.
virtual IConfiguration * defaultConfiguration() const =0
Default configuration.
virtual ~IConfigurationMng()
Frees resources.
Interface for a configuration section.
virtual ~IConfigurationSection()
Frees resources.
Interface for a configuration.
virtual ~IConfiguration()
Frees resources.
virtual IConfiguration * clone() const =0
Clones this configuration.
virtual IConfigurationSection * mainSection() const =0
Main section.
virtual void merge(const IConfiguration *c)=0
Merges this configuration with configuration c.
virtual void dump() const =0
Displays the values of the configuration parameters via traceMng().
virtual void dump(std::ostream &ostr) const =0
Displays the values of the configuration parameters to the stream o.
virtual IConfigurationSection * createSection(const String &name) const =0
Creates a configuration section.
virtual void addValue(const String &name, const String &value, Integer priority)=0
Adds a value to the configuration.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.