16#include "arcane/std/SimpleTableWriterHelper.h"
18#include "arcane/utils/StringBuilder.h"
20#include "arcane/core/Directory.h"
21#include "arcane/core/IParallelMng.h"
41 _computeOutputDirectory();
43 m_root =
Directory(root_directory, m_simple_table_reader_writer->fileType());
53 if (rank != -1 && m_simple_table_internal->m_parallel_mng->commRank() != rank)
55 m_simple_table_reader_writer->print();
66 _computeOutputDirectory();
74 Directory output_directory(root_directory, m_name_output_directory);
83 if (rank != -1 && m_simple_table_internal->m_parallel_mng->commRank() != rank)
91 return m_simple_table_reader_writer->writeTable(output_directory, m_simple_table_internal->m_table_name);
109 return m_simple_table_reader_writer->precision();
115 m_simple_table_reader_writer->setPrecision(
precision);
121 return m_simple_table_reader_writer->isFixed();
127 m_simple_table_reader_writer->setFixed(fixed);
133 return m_simple_table_reader_writer->isForcedToUseScientificNotation();
139 m_simple_table_reader_writer->setForcedToUseScientificNotation(use_scientific);
148 _computeOutputDirectory();
149 return m_name_output_directory;
155 return m_name_output_directory_without_computation;
161 m_name_output_directory = directory;
162 m_name_output_directory_without_computation = directory;
163 m_name_output_directory_computed =
false;
173 return m_simple_table_internal->m_table_name;
179 return m_name_table_without_computation;
185 m_simple_table_internal->m_table_name = name;
186 m_name_table_without_computation = name;
187 m_name_table_computed =
false;
197 return m_simple_table_internal->m_table_name +
"." + m_simple_table_reader_writer->fileType();
203 _computeOutputDirectory();
204 return Directory(m_root, m_name_output_directory);
217 _computeOutputDirectory();
219 return m_name_table_one_file_by_ranks_permited || m_name_output_directory_one_file_by_ranks_permited;
225 return m_simple_table_reader_writer->fileType();
234 return m_simple_table_internal;
240 return m_simple_table_reader_writer;
246 if (simple_table_reader_writer.
isNull())
247 ARCANE_FATAL(
"The reference passed as parameter is Null.");
248 m_simple_table_reader_writer = simple_table_reader_writer;
249 m_simple_table_internal = m_simple_table_reader_writer->internal();
255void SimpleTableWriterHelper::
258 if (!m_name_table_computed) {
259 m_simple_table_internal->m_table_name =
_computeName(m_name_table_without_computation, m_name_table_one_file_by_ranks_permited);
260 m_name_table_computed =
true;
264void SimpleTableWriterHelper::
265_computeOutputDirectory()
267 if (!m_name_output_directory_computed) {
268 m_name_output_directory =
_computeName(m_name_output_directory_without_computation, m_name_output_directory_one_file_by_ranks_permited);
269 m_name_output_directory_computed =
true;
285 one_file_by_ranks_permited =
false;
294 name.
split(string_splited,
'@');
297 if (string_splited.
size() > 1) {
299 std::optional<Integer> proc_id = string_splited.
span().findFirst(
"proc_id");
302 string_splited[proc_id.value()] = String::fromNumber(m_simple_table_internal->m_parallel_mng->commRank());
303 one_file_by_ranks_permited =
true;
307 one_file_by_ranks_permited =
false;
311 std::optional<Integer> num_procs = string_splited.
span().findFirst(
"num_procs");
314 string_splited[num_procs.value()] = String::fromNumber(m_simple_table_internal->m_parallel_mng->commSize());
320 for (
String str : string_splited) {
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Integer size() const
Number of elements in the vector.
Span< const T > span() const
Immutable view of this array.
Class managing a directory.
bool isNull() const
Indicates if the counter references a non-null instance.
Reference to an instance.
static bool createDirectoryOnlyProcess0(IParallelMng *parallel_mng, const Directory &directory)
Static method allowing the creation of a directory with multiple processes.
bool init(const Directory &root_directory, const String &table_name, const String &directory_name) override
Method to initialize the object. Specifically, the table name and the directory name that will contai...
String fileType() override
Method to know the file type that will be used.
void setPrecision(Integer precision) override
Method to modify the print precision.
String outputDirectory() override
Method to retrieve the directory name where the tables will be placed.
void setTableName(const String &name) override
Method to set the table name.
void setFixed(bool fixed) override
Method to set or unset the 'std::fixed' flag.
void print(Integer rank) override
Method to display the table.
void setForcedToUseScientificNotation(bool use_scientific) override
Method to set or unset the 'std::scientific' flag.
Ref< SimpleTableInternal > internal() override
Method to retrieve a reference to the SimpleTableInternal object used.
bool isForcedToUseScientificNotation() override
Method to check if the 'std::scientific' flag is active for writing values.
String fileName() override
Method to retrieve the file name.
String outputDirectoryWithoutComputation() override
Method to retrieve the directory name as it was previously provided.
Ref< ISimpleTableReaderWriter > readerWriter() override
Method to retrieve a reference to the ISimpleTableReaderWriter object used.
void setOutputDirectory(const String &directory) override
Method to set the directory where the tables should be saved.
bool writeFile(Integer rank) override
String tableName() override
Method to retrieve the table name.
String tableNameWithoutComputation() override
Method to retrieve the table name as it was previously provided.
void setReaderWriter(const Ref< ISimpleTableReaderWriter > &simple_table_reader_writer) override
Method to set a reference to an ISimpleTableReaderWriter.
Integer precision() override
Method to retrieve the precision currently used for writing values.
Directory rootPath() override
Method to retrieve the path where the implementation saves these tables.
bool isFixed() override
Method to check if the 'std::fixed' flag is active for writing values.
Directory outputPath() override
Method to retrieve the path where the tables will be saved.
String _computeName(String name, bool &one_file_by_ranks_permited)
Method allowing replacement of name symbols by their value.
bool isOneFileByRanksPermited() override
Method to check if the parameters currently held by the implementation allow it to write a file per p...
Unicode character string constructor.
StringBuilder & append(const String &str)
Appends str.
String toString() const
Returns the constructed character string.
Unicode character string.
bool startsWith(const String &s) const
Indicates if the string starts with the characters of s.
void split(StringContainer &str_array, char c) const
Splits the string based on the character c.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.