15#include "arcane/std/SimpleCsvComparatorService.h"
17#include "arcane/utils/Iostream.h"
19#include "arcane/core/Directory.h"
20#include "arcane/core/IMesh.h"
21#include "arcane/core/IParallelMng.h"
40 ARCANE_CHECK_PTR(simple_table_output_ptr);
41 m_simple_table_output_ptr = simple_table_output_ptr;
43 if (!m_is_already_init) {
44 m_is_already_init =
true;
48 m_simple_table_internal_comparator.setInternalRef(m_simple_table_internal_reference);
49 m_simple_csv_reader_writer.setInternal(m_simple_table_internal_reference);
52 m_simple_table_internal_to_compare = m_simple_table_output_ptr->
internal();
53 m_simple_table_internal_comparator.setInternalToCompare(m_simple_table_internal_to_compare);
56 m_output_directory = m_simple_table_output_ptr->outputDirectory();
57 m_root_path =
Directory(subDomain()->exportDirectory(), m_simple_table_output_ptr->fileType() +
"_refs");
58 m_reference_path =
Directory(m_root_path, m_output_directory);
59 m_table_name = m_simple_table_output_ptr->tableName();
60 m_file_name = m_table_name +
"." + m_simple_table_output_ptr->fileType();
69 m_simple_table_internal_comparator.clearComparator();
70 m_is_file_read =
false;
72 if (m_is_already_init) {
73 m_simple_table_internal_reference->clear();
83 m_root_path = root_directory;
84 m_reference_path =
Directory(m_root_path, m_output_directory);
93 if (rank != -1 && subDomain()->parallelMng()->commRank() != rank)
95 m_simple_csv_reader_writer.print();
107 ARCANE_CHECK_PTR(m_simple_table_output_ptr);
109 Integer save_preci = m_simple_table_output_ptr->precision();
110 bool save_scientific = m_simple_table_output_ptr->isForcedToUseScientificNotation();
111 bool save_fixed = m_simple_table_output_ptr->isFixed();
114 m_simple_table_output_ptr->setPrecision(std::numeric_limits<Real>::max_digits10);
115 m_simple_table_output_ptr->setForcedToUseScientificNotation(
true);
116 m_simple_table_output_ptr->setFixed(
false);
119 bool fin = m_simple_table_output_ptr->writeFile(m_root_path, rank);
122 m_simple_table_output_ptr->setPrecision(save_preci);
123 m_simple_table_output_ptr->setForcedToUseScientificNotation(save_scientific);
124 m_simple_table_output_ptr->setFixed(save_fixed);
135 if (rank != -1 && subDomain()->parallelMng()->commRank() != rank)
138 m_is_file_read = m_simple_csv_reader_writer.readTable(m_reference_path, m_table_name);
140 return m_is_file_read;
149 if (rank != -1 && subDomain()->parallelMng()->commRank() != rank)
162 if (rank != -1 && subDomain()->parallelMng()->commRank() != rank) {
167 error() <<
"Error with the file reader: invalid file";
171 return m_simple_table_internal_comparator.compare(compare_dimension_too);
181 if (rank != -1 && subDomain()->parallelMng()->commRank() != rank) {
186 error() <<
"Error with the file reader: invalid file";
190 return m_simple_table_internal_comparator.compareElem(column_name, row_name);
200 if (rank != -1 && subDomain()->parallelMng()->commRank() != rank) {
205 error() <<
"Error with the file reader: invalid file";
209 return m_simple_table_internal_comparator.compareElem(elem, column_name, row_name);
218 return m_simple_table_internal_comparator.addColumnForComparing(column_name);
227 return m_simple_table_internal_comparator.addRowForComparing(row_name);
236 m_simple_table_internal_comparator.isAnArrayExclusiveColumns(is_exclusive);
245 m_simple_table_internal_comparator.isAnArrayExclusiveRows(is_exclusive);
254 m_simple_table_internal_comparator.editRegexColumns(regex_column);
263 m_simple_table_internal_comparator.editRegexRows(regex_row);
272 m_simple_table_internal_comparator.isARegexExclusiveColumns(is_exclusive);
281 m_simple_table_internal_comparator.isARegexExclusiveRows(is_exclusive);
290 return m_simple_table_internal_comparator.addEpsilonColumn(column_name, epsilon);
299 return m_simple_table_internal_comparator.addEpsilonRow(row_name, epsilon);
Class managing a directory.
Interface representing a simple table output.
virtual Ref< SimpleTableInternal > internal()=0
Method allowing retrieval of a reference to the SimpleTableInternal object used.
void init(ISimpleTableOutput *simple_table_output_ptr) override
Method allowing the service to be initialized.
bool addColumnForComparing(const String &column_name) override
Method allowing a column to be added to the list of columns to be compared.
void editRegexColumns(const String ®ex_column) override
Method allowing a regular expression to be added to determine the columns to compare.
bool addRowForComparing(const String &row_name) override
Method allowing a row to be added to the list of rows to be compared.
void isAnArrayExclusiveColumns(bool is_exclusive) override
Method allowing definition whether the array of columns represents the columns to include in the comp...
bool addEpsilonRow(const String &row_name, Real epsilon) override
Method allowing an epsilon to be defined for a given row. This epsilon must be positive to be taken i...
bool writeReferenceFile(Integer rank) override
void isARegexExclusiveColumns(bool is_exclusive) override
Method allowing to request that the regular expression excludes columns instead of including them.
void clear() override
Method allowing the data read by readReferenceFile() to be cleared.
void print(Integer rank) override
Method allowing the read table to be displayed.
bool isReferenceExist(Integer rank) override
Method allowing to check if the reference files exist.
void isAnArrayExclusiveRows(bool is_exclusive) override
Method allowing definition whether the array of rows represents the rows to include in the comparison...
bool compareWithReference(Integer rank, bool compare_dimension_too) override
Method allowing the ISimpleTableOutput object to be compared to the reference files.
void editRegexRows(const String ®ex_row) override
Method allowing a regular expression to be added to determine the rows to compare.
bool readReferenceFile(Integer rank) override
Method allowing reference files to be read.
bool addEpsilonColumn(const String &column_name, Real epsilon) override
Method allowing an epsilon to be defined for a given column. This epsilon must be positive to be take...
void isARegexExclusiveRows(bool is_exclusive) override
Method allowing to request that the regular expression excludes rows instead of including them.
bool compareElemWithReference(const String &column_name, const String &row_name, Integer rank) override
Method allowing only an element to be compared. Both SimpleTableInternals are represented by Refs,...
void editRootDirectory(const Directory &root_directory) override
Method allowing the root directory to be modified. This allows writing or searching for reference fil...
static bool isFileExist(const Directory &directory, const String &file)
Static method allowing verification of file existence.
Unicode character string.
TraceMessage error() const
Flow for an error message.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
Structure representing a simple table.