Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ApplicationInfo.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/* ApplicationInfo.h (C) 2000-2024 */
9/* */
10/* Application information. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_APPLICATIONINFO_H
13#define ARCANE_UTILS_APPLICATIONINFO_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/VersionInfo.h"
18#include "arcane/utils/String.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36/*!
37 * \brief Application information.
38 */
39class ARCANE_UTILS_EXPORT ApplicationInfo
40{
41 public:
42
43 ApplicationInfo();
44 ApplicationInfo(int* argc, char*** argv, const String& name, const VersionInfo& version);
45 ApplicationInfo(const StringList& args, const String& name, const VersionInfo& version);
46 ApplicationInfo(const CommandLineArguments& args, const String& name, const VersionInfo& version);
47 ApplicationInfo(const ApplicationInfo& rhs);
48 ~ApplicationInfo();
49 ApplicationInfo& operator=(const ApplicationInfo& rhs);
50
51 public:
52
53 //! Application name
54 const String& applicationName() const;
55 //! Version number
56 ARCCORE_DEPRECATED_2020("use codeVersion() instead")
57 const VersionInfo& version() const { return codeVersion(); }
58 //! Version number
59 const VersionInfo& codeVersion() const;
60 //! Returns the path where OS-dependent data files are located
61 const String& dataOsDir() const;
62 //! Returns the path where data files are located.
63 const String& dataDir() const;
64
65 //! Returns the major version number of the application
66 ARCCORE_DEPRECATED_2020("use codeVersion().versionMajor() instead")
67 int versionMajor() const;
68 //! Returns the minor version number of the application
69 ARCCORE_DEPRECATED_2020("use codeVersion().versionMinor() instead")
70 int versionMinor() const;
71 //! Returns the patch version number of the application
72 ARCCORE_DEPRECATED_2020("use codeVersion().versionPatch() instead")
73 int versionPatch() const;
74
75 //! Returns \a true if running in debug mode.
76 bool isDebug() const;
77
78 //! Returns the name of the calculation code linked to the application
79 const String& codeName() const;
80 //! Returns the full target name
81 const String& targetFullName() const;
82
83 ARCCORE_DEPRECATED_2019("Use commandLineArguments().commandLineArgc() instead")
84 int* commandLineArgc() const;
85 ARCCORE_DEPRECATED_2019("Use commandLineArguments().commandLineArgv() instead")
86 char*** commandLineArgv() const;
87
88 //! Fills \a args with command line arguments.
89 void args(StringList& args) const;
90
91 //! Command line arguments
92 const CommandLineArguments& commandLineArguments() const;
93
94 public:
95
96 /*!
97 * \brief Adds the library \a lib_name to the list of dynamically loaded libraries.
98 *
99 * \a lib_name must be a name, without path and without extension. For example,
100 * \c my_lib is valid but not \c libtoto.so, nor \c /tmp/toto.
101 */
102 void addDynamicLibrary(const String& lib_name);
103
104 //! List of dynamic libraries.
105 StringCollection dynamicLibrariesName() const;
106
107 public:
108
109 //! Sets the path where OS-dependent data files are located
110 void setDataOsDir(const String& v);
111 //! Sets the path where data files are located.
112 void setDataDir(const String& v);
113 //! Sets the code version number
114 ARCCORE_DEPRECATED_2020("use setCodeVersion() instead")
115 void setVersionInfo(const VersionInfo& version_info)
116 {
117 setCodeVersion(version_info);
118 }
119 //! Sets the application name
120 void setApplicationName(const String& v);
121 //! Sets the version number
122 void setCodeVersion(const VersionInfo& version_info);
123 //! Sets the code name
124 void setCodeName(const String& code_name);
125 /*!
126 * \brief Sets the command line arguments.
127 *
128 * Calling this method modifies the values of \a m_argv and \a m_argc.
129 */
130 void setCommandLineArguments(const CommandLineArguments& args);
131 //! Sets the debug state.
132 void setIsDebug(bool v);
133
134 public:
135
136 //! Sets the application configuration file content
137 void setRuntimeConfigFileContent(ByteConstSpan content);
138 //! Application configuration file content
139 ByteConstSpan runtimeConfigFileContent() const;
140
141 public:
142
143 /*!
144 * \brief Adds an Arcane parameter to the command line.
145 * \sa ParameterList::addParameterLine().
146 */
147 void addParameterLine(const String& line);
148
149 public:
150
151 ARCCORE_DEPRECATED_2019("Use commandLineArguments().commandLineArgc() instead")
152 int* m_argc; //!< Number of command line arguments
153 ARCCORE_DEPRECATED_2019("Use commandLineArguments().commandLineArgv() instead")
154 char*** m_argv; //!< Array of command line arguments
155
156 private:
157
159
160 private:
161
162 void _init(const String& name);
163 void _setArgs();
164};
165
166/*---------------------------------------------------------------------------*/
167/*---------------------------------------------------------------------------*/
168
169} // End namespace Arcane
170
171/*---------------------------------------------------------------------------*/
172/*---------------------------------------------------------------------------*/
173
174#endif
Declarations of types used in Arcane.
int * m_argc
Number of command line arguments.
void setCodeVersion(const VersionInfo &version_info)
Sets the version number.
const String & applicationName() const
Application name.
void args(StringList &args) const
Fills args with command line arguments.
const VersionInfo & codeVersion() const
Version number.
const VersionInfo & version() const
Version number.
char *** m_argv
Array of command line arguments.
void setVersionInfo(const VersionInfo &version_info)
Sets the code version number.
Information about a version.
Definition VersionInfo.h:47
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Collection< String > StringCollection
Collection of strings.
Definition UtilsTypes.h:506
List< String > StringList
Unicode string list.
Definition UtilsTypes.h:509
Span< const std::byte > ByteConstSpan
Read-only view of a 1D array of characters.
Definition UtilsTypes.h:548