Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ISimpleTableWriterHelper.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/* ISimpleTableWriterHelper.h (C) 2000-2025 */
9/* */
10/* Interface representing a simple writer using an */
11/* ISimpleTableReaderWriter. */
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_CORE_ISIMPLETABLEWRITERHELPER_H
14#define ARCANE_CORE_ISIMPLETABLEWRITERHELPER_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18#include "arcane/core/ISimpleTableInternalMng.h"
19#include "arcane/core/ISimpleTableReaderWriter.h"
20
21#include "arcane/core/Directory.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33/**
34 * \brief Class interface for writing a file
35 * using ISimpleTableReaderWriter.
36 * Provides methods for managing parallel writing
37 * and name symbols.
38 *
39 * This class is, in a way, a wrapper around
40 * ISimpleTableReaderWriter, which is quite basic.
41 * ISimpleTableWriterHelper is here to simplify
42 * the use of ISimpleTableReaderWriter.
43 *
44 * In the SimpleTable part, name symbols are keywords surrounded by
45 * at signs (@) that will be replaced by their meaning during execution.
46 * In the SimpleTableWriterHelper implementation, there are
47 * currently two supported name symbols:
48 * - \@proc_id\@: Will be replaced by the process ID.
49 * - \@num_procs\@: Will be replaced by the number of processes.
50 * And in SimpleTableWriterHelper, these symbols are only replaced
51 * in the table name.
52 */
53class ARCANE_CORE_EXPORT ISimpleTableWriterHelper
54{
55 public:
56
57 virtual ~ISimpleTableWriterHelper() = default;
58
59 public:
60
61 /**
62 * \brief Method to initialize the object.
63 * Specifically, the table name and the directory name that will contain
64 * the files (the tables directory/directory_name).
65 *
66 * \param table_name The table name (and the output file name).
67 * \param directory_name The folder name where the tables will be saved.
68 */
69 virtual bool init(const Directory& root_directory, const String& table_name, const String& directory_name) = 0;
70
71 /*---------------------------------------------------------------------------*/
72 /*---------------------------------------------------------------------------*/
73
74 /**
75 * \brief Method to display the table.
76 *
77 * \param rank The process ID that should display the table (-1 to
78 * signify "all processes").
79 */
80 virtual void print(Integer rank = 0) = 0;
81
82 /**
83 * \brief Method to write the table to a file.
84 * If rank != -1, processes other than rank return true.
85 *
86 * For example, in the SimpleTableWriterHelper implementation,
87 * the file(s) will be written in the directory:
88 * root_directory/[directory_name]/[table_name].[ISimpleTableReaderWriter.fileType()]
89 *
90 * \param root_directory The root directory where the tables directory should be created.
91 * \param rank The process ID that should write the table to a file
92 * (-1 to signify "all processes").
93 * \return true If the file was written correctly.
94 * \return false If the file was not written correctly.
95 */
96 virtual bool writeFile(const Directory& root_directory, Integer rank) = 0;
97
98 /**
99 * \brief Method to write the table to a file.
100 * If rank != -1, processes other than rank return true.
101 *
102 * For example, in the SimpleTableWriterHelper implementation,
103 * the file(s) will be written in the directory:
104 * ./[output]/[directory_name]/[table_name].[ISimpleTableReaderWriter.fileType()]
105 *
106 * \param rank The process ID that should write the table to a file
107 * (-1 to signify "all processes").
108 * \return true If the file was written correctly.
109 * \return false If the file was not written correctly.
110 */
111 virtual bool writeFile(Integer rank = -1) = 0;
112
113 /*---------------------------------------------------------------------------*/
114 /*---------------------------------------------------------------------------*/
115
116 /**
117 * \brief Method to retrieve the precision currently
118 * used for writing values.
119 *
120 * \return Integer The precision.
121 */
122 virtual Integer precision() = 0;
123 /**
124 * \brief Method to modify the print precision.
125 *
126 * Applicable to both the 'print()' method and the 'writeFile()' methods.
127 *
128 * \warning The "std::fixed" flag modifies the behavior of "setPrecision()";
129 * if the "std::fixed" flag is disabled, the precision defines the
130 * total number of digits (before and after the comma);
131 * if the "std::fixed" flag is enabled, the precision defines the
132 * number of digits after the comma. Be careful when using
133 * "std::numeric_limits<Real>::max_digits10"
134 * (for writing) or "std::numeric_limits<Real>::digits10"
135 * (for reading), which should be used without the "std::fixed" flag.
136 *
137 * \param precision The new precision.
138 */
139 virtual void setPrecision(Integer precision) = 0;
140
141 /**
142 * \brief Method to check if the 'std::fixed' flag is
143 * active for writing values.
144 *
145 * \return true If yes.
146 * \return false If no.
147 */
148 virtual bool isFixed() = 0;
149 /**
150 * \brief Method to set or unset the 'std::fixed' flag.
151 *
152 * Applicable to both the 'print()' method and the 'writeFile()' methods.
153 *
154 * This flag allows 'forcing' the number of digits after the comma to
155 * the desired precision. For example, if 'setPrecision(4)' was called,
156 * and 'setFixed(true)' is called, the print of '6.1' will output '6.1000'.
157 *
158 * \warning The "std::fixed" flag modifies the behavior of "setPrecision()";
159 * if the "std::fixed" flag is disabled, the precision defines the
160 * total number of digits (before and after the comma);
161 * if the "std::fixed" flag is enabled, the precision defines the
162 * number of digits after the comma. Be careful when using
163 * "std::numeric_limits<Real>::max_digits10"
164 * (for writing) or "std::numeric_limits<Real>::digits10"
165 * (for reading), which should be used without the "std::fixed" flag.
166 *
167 * \param fixed Whether the 'std::fixed' flag should be set or not.
168 */
169 virtual void setFixed(bool fixed) = 0;
170
171 /**
172 * \brief Method to check if the 'std::scientific' flag is
173 * active for writing values.
174 *
175 * \return true If yes.
176 * \return false If no.
177 */
179 /**
180 * \brief Method to set or unset the 'std::scientific' flag.
181 *
182 * Applicable to both the 'print()' method and the 'writetable()' method.
183 *
184 * This flag allows 'forcing' the display of values in scientific
185 * notation.
186 *
187 * \param use_scientific Whether the 'std::scientific' flag should be set or not.
188 */
189 virtual void setForcedToUseScientificNotation(bool use_scientific) = 0;
190
191 /**
192 * \brief Method to retrieve the directory name as it
193 * was previously provided.
194 *
195 * Name symbols are still present here.
196 *
197 * \return String The directory.
198 */
200
201 /**
202 * \brief Method to retrieve the directory name where the tables will be
203 * placed.
204 *
205 * May be different for each process (depending on the implementation).
206 *
207 * Name symbols have been resolved here.
208 *
209 * \return String The directory.
210 */
211 virtual String outputDirectory() = 0;
212 /**
213 * \brief Method to set the directory
214 * where the tables should be saved.
215 *
216 * May be different for each process (depending on the implementation).
217 *
218 * \param directory The directory.
219 */
220 virtual void setOutputDirectory(const String& directory) = 0;
221
222 /**
223 * \brief Method to retrieve the table name as it
224 * was previously provided.
225 *
226 * Name symbols are still present here.
227 *
228 * \return String The name.
229 */
231
232 /**
233 * \brief Method to retrieve the table name.
234 *
235 * May be different for each process (depending on the implementation).
236 *
237 * Name symbols have been resolved here.
238 *
239 * \return String The name.
240 */
241 virtual String tableName() = 0;
242 /**
243 * \brief Method to set the table name.
244 *
245 * \param name The name.
246 */
247 virtual void setTableName(const String& name) = 0;
248
249 /**
250 * \brief Method to retrieve the file name.
251 *
252 * May be different for each process (depending on the implementation).
253 *
254 * Name symbols have been resolved and the extension is added here.
255 *
256 * \return String The name.
257 */
258 virtual String fileName() = 0;
259
260 /**
261 * \brief Method to retrieve the path where
262 * the tables will be saved.
263 *
264 * Example (relative):
265 * ./output/csv/[directory_name]/
266 *
267 * \return String The path.
268 */
269 virtual Directory outputPath() = 0;
270
271 /**
272 * \brief Method to retrieve the path where the implementation
273 * saves these tables.
274 *
275 * Example (relative):
276 * ./output/csv/
277 *
278 * \return String The path.
279 */
280 virtual Directory rootPath() = 0;
281
282 /**
283 * \brief Method to check if the parameters currently held
284 * by the implementation allow it to write a file per process, especially
285 * thanks to name symbols.
286 *
287 * \return true If yes, the implementation can write a file per process.
288 * \return false Otherwise, only one file can be written.
289 */
290 virtual bool isOneFileByRanksPermited() = 0;
291
292 /**
293 * \brief Method to know the file type that will be used.
294 *
295 * \return String The output file type (= the extension).
296 */
297 virtual String fileType() = 0;
298
299 /**
300 * \brief Method to retrieve a reference to the
301 * SimpleTableInternal object used.
302 *
303 * \return Ref<SimpleTableInternal> A copy of the reference.
304 */
306
307 /**
308 * \brief Method to retrieve a reference to the
309 * ISimpleTableReaderWriter object used.
310 *
311 * \return Ref<ISimpleTableReaderWriter> A copy of the reference.
312 */
314
315 /**
316 * \brief Method to set a reference to an
317 * ISimpleTableReaderWriter.
318 *
319 * \param simple_table_reader_writer The reference to an ISimpleTableReaderWriter.
320 */
321 virtual void setReaderWriter(const Ref<ISimpleTableReaderWriter>& simple_table_reader_writer) = 0;
322};
323
324/*---------------------------------------------------------------------------*/
325/*---------------------------------------------------------------------------*/
326
327} // End namespace Arcane
328
329/*---------------------------------------------------------------------------*/
330/*---------------------------------------------------------------------------*/
331
332#endif
Declarations of types on entities.
Class managing a directory.
Definition Directory.h:36
Class interface for writing a file using ISimpleTableReaderWriter. Provides methods for managing para...
virtual String outputDirectory()=0
Method to retrieve the directory name where the tables will be placed.
virtual bool isForcedToUseScientificNotation()=0
Method to check if the 'std::scientific' flag is active for writing values.
virtual Directory rootPath()=0
Method to retrieve the path where the implementation saves these tables.
virtual Ref< ISimpleTableReaderWriter > readerWriter()=0
Method to retrieve a reference to the ISimpleTableReaderWriter object used.
virtual String fileName()=0
Method to retrieve the file name.
virtual void setForcedToUseScientificNotation(bool use_scientific)=0
Method to set or unset the 'std::scientific' flag.
virtual void setOutputDirectory(const String &directory)=0
Method to set the directory where the tables should be saved.
virtual void print(Integer rank=0)=0
Method to display the table.
virtual void setPrecision(Integer precision)=0
Method to modify the print precision.
virtual bool writeFile(Integer rank=-1)=0
Method to write the table to a file. If rank != -1, processes other than rank return true.
virtual String tableNameWithoutComputation()=0
Method to retrieve the table name as it was previously provided.
virtual String tableName()=0
Method to retrieve the table name.
virtual Integer precision()=0
Method to retrieve the precision currently used for writing values.
virtual Ref< SimpleTableInternal > internal()=0
Method to retrieve a reference to the SimpleTableInternal object used.
virtual bool init(const Directory &root_directory, const String &table_name, const String &directory_name)=0
Method to initialize the object. Specifically, the table name and the directory name that will contai...
virtual Directory outputPath()=0
Method to retrieve the path where the tables will be saved.
virtual bool writeFile(const Directory &root_directory, Integer rank)=0
Method to write the table to a file. If rank != -1, processes other than rank return true.
virtual String fileType()=0
Method to know the file type that will be used.
virtual void setReaderWriter(const Ref< ISimpleTableReaderWriter > &simple_table_reader_writer)=0
Method to set a reference to an ISimpleTableReaderWriter.
virtual String outputDirectoryWithoutComputation()=0
Method to retrieve the directory name as it was previously provided.
virtual void setTableName(const String &name)=0
Method to set the table name.
virtual bool isOneFileByRanksPermited()=0
Method to check if the parameters currently held by the implementation allow it to write a file per p...
virtual void setFixed(bool fixed)=0
Method to set or unset the 'std::fixed' flag.
virtual bool isFixed()=0
Method to check if the 'std::fixed' flag is active for writing values.
Reference to an instance.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.