Skip to content

Commit 5538107

Browse files
[arcane,utils+launcher] Dans les propriétés, découple la classe positionnant la propriété de l'instance modifiée.
Utilise cela pour 'ParallelLoopOPtions' et 'ApplicationInfo'.
1 parent efa1529 commit 5538107

11 files changed

+135
-38
lines changed

arcane/src/arcane/launcher/ArcaneLauncher.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ArcaneLauncher.cc (C) 2000-2023 */
8+
/* ArcaneLauncher.cc (C) 2000-2024 */
99
/* */
1010
/* Classe gérant le lancement de l'exécution. */
1111
/*---------------------------------------------------------------------------*/
@@ -26,6 +26,8 @@
2626
#include "arcane/utils/ParameterList.h"
2727
#include "arcane/utils/Ref.h"
2828
#include "arcane/utils/ConcurrencyUtils.h"
29+
#include "arcane/utils/internal/ParallelLoopOptionsProperties.h"
30+
#include "arcane/utils/internal/ApplicationInfoProperties.h"
2931

3032
#include "arcane/impl/ArcaneMain.h"
3133
#include "arcane/impl/ArcaneSimpleExecutor.h"
@@ -102,7 +104,7 @@ _checkReadConfigFile(StringView config_file_name)
102104
if (config.null())
103105
return;
104106
std::cout << "READING CONFIG\n";
105-
properties::readFromJSON(config,app_info);
107+
properties::readFromJSON<ApplicationInfo,ApplicationInfoProperties>(config,app_info);
106108
}
107109

108110
/*---------------------------------------------------------------------------*/
@@ -322,20 +324,22 @@ init(const CommandLineArguments& args)
322324
if (global_has_init_done)
323325
ARCANE_FATAL("ArcaneLauncher::init() has already been called");
324326
global_has_init_done = true;
325-
applicationInfo().setCommandLineArguments(args);
327+
auto& application_info = applicationInfo();
328+
application_info.setCommandLineArguments(args);
326329
bool do_list = false;
327330
if (do_list)
328331
_listPropertySettings();
329332
const CommandLineArguments& cargs = applicationInfo().commandLineArguments();
330333
String runtime_config_file_name = cargs.getParameter("RuntimeConfigFile");
331334
if (!runtime_config_file_name.empty())
332335
_checkReadConfigFile(runtime_config_file_name);
336+
properties::readFromParameterList<ApplicationInfo,ApplicationInfoProperties>(args.parameters(),application_info);
333337
auto& dotnet_info = ArcaneLauncher::dotNetRuntimeInitialisationInfo();
334338
properties::readFromParameterList(args.parameters(),dotnet_info);
335339
auto& accelerator_info = ArcaneLauncher::acceleratorRuntimeInitialisationInfo();
336340
properties::readFromParameterList(args.parameters(),accelerator_info);
337341
ParallelLoopOptions loop_options;
338-
properties::readFromParameterList(args.parameters(),loop_options);
342+
properties::readFromParameterList<ParallelLoopOptions,ParallelLoopOptionsProperties>(args.parameters(),loop_options);
339343
TaskFactory::setDefaultParallelLoopOptions(loop_options);
340344
}
341345
catch(const Exception& ex){

arcane/src/arcane/utils/ApplicationInfo.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ApplicationInfo.cc (C) 2000-2020 */
8+
/* ApplicationInfo.cc (C) 2000-2024 */
99
/* */
1010
/* Informations sur une application. */
1111
/*---------------------------------------------------------------------------*/
@@ -17,6 +17,7 @@
1717
#include "arcane/utils/PlatformUtils.h"
1818
#include "arcane/utils/List.h"
1919
#include "arcane/utils/Property.h"
20+
#include "arcane/utils/internal/ApplicationInfoProperties.h"
2021

2122
/*---------------------------------------------------------------------------*/
2223
/*---------------------------------------------------------------------------*/
@@ -443,7 +444,10 @@ addParameterLine(const String& line)
443444
/*---------------------------------------------------------------------------*/
444445
/*---------------------------------------------------------------------------*/
445446

446-
template<typename V> void ApplicationInfo::
447+
/*---------------------------------------------------------------------------*/
448+
/*---------------------------------------------------------------------------*/
449+
450+
template<typename V> void ApplicationInfoProperties::
447451
_applyPropertyVisitor(V& p)
448452
{
449453
auto b = p.builder();
@@ -486,7 +490,7 @@ _applyPropertyVisitor(V& p)
486490
/*---------------------------------------------------------------------------*/
487491
/*---------------------------------------------------------------------------*/
488492

489-
ARCANE_REGISTER_PROPERTY_CLASS(ApplicationInfo,());
493+
ARCANE_REGISTER_PROPERTY_CLASS(ApplicationInfoProperties,());
490494

491495
/*---------------------------------------------------------------------------*/
492496
/*---------------------------------------------------------------------------*/

arcane/src/arcane/utils/ApplicationInfo.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ApplicationInfo.h (C) 2000-2020 */
8+
/* ApplicationInfo.h (C) 2000-2024 */
99
/* */
1010
/* Informations sur une application. */
1111
/*---------------------------------------------------------------------------*/
@@ -17,7 +17,6 @@
1717
#include "arcane/utils/VersionInfo.h"
1818
#include "arcane/utils/String.h"
1919
#include "arcane/utils/UtilsTypes.h"
20-
#include "arcane/utils/PropertyDeclarations.h"
2120

2221
/*---------------------------------------------------------------------------*/
2322
/*---------------------------------------------------------------------------*/
@@ -38,7 +37,6 @@ class CommandLineArguments;
3837
*/
3938
class ARCANE_UTILS_EXPORT ApplicationInfo
4039
{
41-
ARCANE_DECLARE_PROPERTY_CLASS(ApplicationInfo);
4240
public:
4341

4442
ApplicationInfo();

arcane/src/arcane/utils/JSONPropertyReader.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* JSONPropertyReader.h (C) 2000-2020 */
8+
/* JSONPropertyReader.h (C) 2000-2024 */
99
/* */
1010
/* Lecture de propriétés au format JSON. */
1111
/*---------------------------------------------------------------------------*/
@@ -59,15 +59,15 @@ class JSONPropertyReader
5959
* Les valeurs de la propriété doivent être dans un élément fils de \a jv
6060
* dont le nom est celui de la classe \a T.
6161
*/
62-
template<typename T> inline void
62+
template<typename T, typename PropertyType = T> inline void
6363
readFromJSON(JSONValue jv,T& instance)
6464
{
65-
const char* instance_property_name = T :: propertyClassName();
65+
const char* instance_property_name = PropertyType :: propertyClassName();
6666
JSONValue child_value = jv.child(instance_property_name);
6767
if (child_value.null())
6868
return;
6969
JSONPropertyReader reader(child_value,instance);
70-
T :: applyPropertyVisitor(reader);
70+
PropertyType :: applyPropertyVisitor(reader);
7171
}
7272

7373
/*---------------------------------------------------------------------------*/

arcane/src/arcane/utils/ParallelLoopOptions.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ParallelLoopOptions.cc (C) 2000-2022 */
8+
/* ParallelLoopOptions.cc (C) 2000-2024 */
99
/* */
1010
/* Options de configuration pour les boucles parallèles en multi-thread. */
1111
/*---------------------------------------------------------------------------*/
@@ -15,6 +15,7 @@
1515

1616
#include "arcane/utils/Property.h"
1717
#include "arcane/utils/FatalErrorException.h"
18+
#include "arcane/utils/internal/ParallelLoopOptionsProperties.h"
1819

1920
/*---------------------------------------------------------------------------*/
2021
/*---------------------------------------------------------------------------*/
@@ -57,7 +58,7 @@ namespace
5758
/*---------------------------------------------------------------------------*/
5859
/*---------------------------------------------------------------------------*/
5960

60-
template <typename V> void ParallelLoopOptions::
61+
template <typename V> void ParallelLoopOptionsProperties::
6162
_applyPropertyVisitor(V& p)
6263
{
6364
auto b = p.builder();
@@ -77,7 +78,7 @@ _applyPropertyVisitor(V& p)
7778
/*---------------------------------------------------------------------------*/
7879
/*---------------------------------------------------------------------------*/
7980

80-
ARCANE_REGISTER_PROPERTY_CLASS(ParallelLoopOptions, ());
81+
ARCANE_REGISTER_PROPERTY_CLASS(ParallelLoopOptionsProperties, ());
8182

8283
/*---------------------------------------------------------------------------*/
8384
/*---------------------------------------------------------------------------*/

arcane/src/arcane/utils/ParallelLoopOptions.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ParallelLoopOptions.h (C) 2000-2022 */
8+
/* ParallelLoopOptions.h (C) 2000-2024 */
99
/* */
1010
/* Options de configuration pour les boucles parallèles en multi-thread. */
1111
/*---------------------------------------------------------------------------*/
@@ -15,7 +15,6 @@
1515
/*---------------------------------------------------------------------------*/
1616

1717
#include "arcane/utils/UtilsTypes.h"
18-
#include "arcane/utils/PropertyDeclarations.h"
1918

2019
/*---------------------------------------------------------------------------*/
2120
/*---------------------------------------------------------------------------*/
@@ -34,8 +33,6 @@ namespace Arcane
3433
*/
3534
class ARCANE_UTILS_EXPORT ParallelLoopOptions
3635
{
37-
ARCANE_DECLARE_PROPERTY_CLASS(ParallelLoopOptions);
38-
3936
private:
4037

4138
//! Drapeau pour indiquer quels champs ont été positionnés.

arcane/src/arcane/utils/ParameterListPropertyReader.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ParameterListPropertyReader.h (C) 2000-2021 */
8+
/* ParameterListPropertyReader.h (C) 2000-2024 */
99
/* */
1010
/* Lecture de propriétés au format JSON. */
1111
/*---------------------------------------------------------------------------*/
@@ -30,7 +30,7 @@ namespace Arcane::properties
3030
/*---------------------------------------------------------------------------*/
3131
/*---------------------------------------------------------------------------*/
3232
//! \internal
33-
template<typename T>
33+
template<typename T, typename PropertyType = T>
3434
class ParameterListPropertyVisitor
3535
: public properties::PropertyVisitor<T>
3636
{
@@ -61,11 +61,11 @@ class ParameterListPropertyVisitor
6161
/*!
6262
* \brief Remplit les valeurs de \a instance à partir des paramètres \a args.
6363
*/
64-
template<typename T> inline void
64+
template<typename T, typename PropertyType = T> inline void
6565
readFromParameterList(const ParameterList& args,T& instance)
6666
{
67-
ParameterListPropertyVisitor reader(args,instance);
68-
T :: applyPropertyVisitor(reader);
67+
ParameterListPropertyVisitor<T,PropertyType> reader(args,instance);
68+
PropertyType :: applyPropertyVisitor(reader);
6969
}
7070

7171
/*---------------------------------------------------------------------------*/

arcane/src/arcane/utils/PropertyDeclarations.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* PropertyDeclarations.h (C) 2000-2020 */
8+
/* PropertyDeclarations.h (C) 2000-2024 */
99
/* */
1010
/* Déclaration des types et macros pour la gestion des propriétés. */
1111
/*---------------------------------------------------------------------------*/
@@ -57,12 +57,13 @@ class PropertyDeclaration
5757
* class MyClass
5858
* {
5959
* public:
60-
* ARCANE_DECLARE_PROPERTY_CLASS(MyClass);
60+
* ARCANE_DECLARE_PROPERTY_CLASS(MyClass,InstanceType);
6161
* };
6262
* \endcode
6363
*/
64-
#define ARCANE_DECLARE_PROPERTY_CLASS(class_name)\
64+
#define ARCANE_DECLARE_PROPERTY_CLASS(class_name) \
6565
public:\
66+
using PropertyInstanceType = class_name; \
6667
static const char* propertyClassName() { return #class_name; }\
6768
template<typename V> static void _applyPropertyVisitor(V& visitor);\
6869
static void applyPropertyVisitor(Arcane::properties::PropertyVisitor<class_name>& p); \
@@ -109,7 +110,7 @@ namespace\
109110
}\
110111
}\
111112
void aclass :: \
112-
applyPropertyVisitor(Arcane::properties::PropertyVisitor<aclass>& p)\
113+
applyPropertyVisitor(Arcane::properties::PropertyVisitor<typename aclass :: PropertyInstanceType >& p) \
113114
{\
114115
aclass :: _applyPropertyVisitor(p);\
115116
}\
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2+
//-----------------------------------------------------------------------------
3+
// Copyright 2000-2024 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+
/* ApplicationInfoProperties.h (C) 2000-2024 */
9+
/* */
10+
/* Informations sur une application. */
11+
/*---------------------------------------------------------------------------*/
12+
#ifndef ARCANE_UTILS_INTERNAL_APPLICATIONINFOPROPERTIES_H
13+
#define ARCANE_UTILS_INTERNAL_APPLICATIONINFOPROPERTIES_H
14+
/*---------------------------------------------------------------------------*/
15+
/*---------------------------------------------------------------------------*/
16+
17+
#include "arcane/utils/ApplicationInfo.h"
18+
#include "arcane/utils/PropertyDeclarations.h"
19+
20+
/*---------------------------------------------------------------------------*/
21+
/*---------------------------------------------------------------------------*/
22+
23+
namespace Arcane
24+
{
25+
26+
/*---------------------------------------------------------------------------*/
27+
/*---------------------------------------------------------------------------*/
28+
/*!
29+
* \brief Informations sur une application.
30+
*/
31+
class ARCANE_UTILS_EXPORT ApplicationInfoProperties
32+
: public ApplicationInfo
33+
{
34+
ARCANE_DECLARE_PROPERTY_CLASS(ApplicationInfo);
35+
};
36+
37+
/*---------------------------------------------------------------------------*/
38+
/*---------------------------------------------------------------------------*/
39+
40+
} // namespace Arcane
41+
42+
/*---------------------------------------------------------------------------*/
43+
/*---------------------------------------------------------------------------*/
44+
45+
#endif

0 commit comments

Comments
 (0)