Arcane  v4.1.4.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ArccoreApplicationBuildInfo.cc
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/* ArccoreApplicationBuildInfo.cc (C) 2000-2026 */
9/* */
10/* Informations pour construire une instance de IApplication. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/common/ArccoreApplicationBuildInfo.h"
15#include "arccore/common/CommandLineArguments.h"
16#include "arccore/common/internal/FieldProperty.h"
17#include "arccore/common/internal/ArccoreApplicationBuildInfoImpl.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace
29{
30 void _clamp(Int32& x, Int32 min_value, Int32 max_value)
31 {
32 x = std::min(std::max(x, min_value), max_value);
33 }
34} // namespace
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39ArccoreApplicationBuildInfoImpl::ArccoreApplicationBuildInfoImpl()
40: m_nb_task_thread(-1)
41{
42 // Fixe une limite pour le nombre de tâches
43 m_nb_task_thread.setValidator([](Int32& x) { _clamp(x, -1, 512); });
44}
45
46String ArccoreApplicationBuildInfoImpl::
47getValue(const UniqueArray<String>& env_values, const String& param_name,
48 const String& default_value)
49{
50 return m_property_key_values.getValue(env_values, param_name, default_value);
51}
52
53void ArccoreApplicationBuildInfoImpl::
54addKeyValue(const String& name, const String& value)
55{
56 m_property_key_values.add(name, value);
57}
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62ArccoreApplicationBuildInfo::
63ArccoreApplicationBuildInfo()
64: m_core(new ArccoreApplicationBuildInfoImpl())
65{
66}
67
68ArccoreApplicationBuildInfo::
69ArccoreApplicationBuildInfo(const ArccoreApplicationBuildInfo& rhs)
70: m_core(new ArccoreApplicationBuildInfoImpl(*rhs.m_core))
71{
72}
73
74ArccoreApplicationBuildInfo& ArccoreApplicationBuildInfo::
75operator=(const ArccoreApplicationBuildInfo& rhs)
76{
77 if (&rhs != this) {
78 delete m_core;
79 m_core = new ArccoreApplicationBuildInfoImpl(*(rhs.m_core));
80 }
81 return (*this);
82}
83
84ArccoreApplicationBuildInfo::
85~ArccoreApplicationBuildInfo()
86{
87 delete m_core;
88}
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
96void ArccoreApplicationBuildInfo::
97setDefaultValues()
98{
99 {
100 String str = m_core->getValue({ "ARCANE_NB_TASK" }, "T", String());
101 PropertyImpl::checkSet(m_core->m_nb_task_thread, str);
102 }
103}
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
107
108void ArccoreApplicationBuildInfo::
109setDefaultServices()
110{
111 {
112 String str = m_core->getValue({ "ARCANE_TASK_IMPLEMENTATION" }, "TaskService", "TBB");
113 String service_name = str + "TaskImplementation";
114 PropertyImpl::checkSet(m_core->m_task_implementation_services, service_name);
115 }
116 {
117 StringList list1;
118 String thread_str = m_core->getValue({ "ARCANE_THREAD_IMPLEMENTATION" }, "ThreadService", "Std");
119 list1.add(thread_str + "ThreadImplementationService");
120 list1.add("TBBThreadImplementationService");
121 PropertyImpl::checkSet(m_core->m_thread_implementation_services, list1);
122 }
123}
124
125/*---------------------------------------------------------------------------*/
126/*---------------------------------------------------------------------------*/
127
128void ArccoreApplicationBuildInfo::
129setTaskImplementationService(const String& name)
130{
131 StringList s;
132 s.add(name);
133 m_core->m_task_implementation_services = s;
134}
135void ArccoreApplicationBuildInfo::
136setTaskImplementationServices(const StringList& names)
137{
138 m_core->m_task_implementation_services = names;
139}
140StringList ArccoreApplicationBuildInfo::
141taskImplementationServices() const
142{
143 return m_core->m_task_implementation_services;
144}
145
146/*---------------------------------------------------------------------------*/
147/*---------------------------------------------------------------------------*/
148
149void ArccoreApplicationBuildInfo::
150setThreadImplementationService(const String& name)
151{
152 StringList s;
153 s.add(name);
154 m_core->m_thread_implementation_services = s;
155}
156void ArccoreApplicationBuildInfo::
157setThreadImplementationServices(const StringList& names)
158{
159 m_core->m_thread_implementation_services = names;
160}
161StringList ArccoreApplicationBuildInfo::
162threadImplementationServices() const
163{
164 return m_core->m_thread_implementation_services;
165}
166
167/*---------------------------------------------------------------------------*/
168/*---------------------------------------------------------------------------*/
169
170Int32 ArccoreApplicationBuildInfo::
171nbTaskThread() const
172{
173 return m_core->m_nb_task_thread;
174}
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
179void ArccoreApplicationBuildInfo::
180setNbTaskThread(Int32 v)
181{
182 m_core->m_nb_task_thread = v;
183}
184
185/*---------------------------------------------------------------------------*/
186/*---------------------------------------------------------------------------*/
187
188void ArccoreApplicationBuildInfo::
189addParameter(const String& name, const String& value)
190{
191 m_core->addKeyValue(name, value);
192}
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
197void ArccoreApplicationBuildInfo::
198parseArgumentsAndSetDefaultsValues(const CommandLineArguments& command_line_args)
199{
200 // On ne récupère que les arguments du style:
201 // -A,x=b,y=c
202 StringList names;
203 StringList values;
204 command_line_args.fillParameters(names, values);
205 for (Integer i = 0, n = names.count(); i < n; ++i) {
206 addParameter(names[i], values[i]);
207 }
208 setDefaultValues();
209}
210
211/*---------------------------------------------------------------------------*/
212/*---------------------------------------------------------------------------*/
213
214} // namespace Arcane
215
216/*---------------------------------------------------------------------------*/
217/*---------------------------------------------------------------------------*/
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
List< String > StringList
Tableau de chaînes de caractères unicode.
Definition UtilsTypes.h:509
std::int32_t Int32
Type entier signé sur 32 bits.