Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
SimpleCsvComparatorService.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/* SimpleCsvComparatorService.h (C) 2000-2022 */
9/* */
10/* Service for comparing an ISimpleTableOutput with a reference file in */
11/* CSV format. */
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_STD_SIMPLECSVCOMPARATORSERVICE_H
14#define ARCANE_STD_SIMPLECSVCOMPARATORSERVICE_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18#include "arcane/core/ISimpleTableComparator.h"
19#include "arcane/core/ISimpleTableInternalMng.h"
20#include "arcane/core/ISimpleTableOutput.h"
21
22#include "arcane/std/SimpleCsvReaderWriter.h"
23#include "arcane/std/SimpleTableInternalComparator.h"
24
25#include "arcane/core/Directory.h"
26#include "arcane/core/IMesh.h"
27
28#include "arcane/std/SimpleCsvComparator_axl.h"
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace Arcane
34{
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39class SimpleCsvComparatorService
41{
42 public:
43
44 explicit SimpleCsvComparatorService(const ServiceBuildInfo& sbi)
46 , m_simple_table_output_ptr(nullptr)
47 , m_reference_path()
48 , m_root_path()
49 , m_output_directory("_ref")
50 , m_file_name("")
51 , m_table_name("")
52 , m_is_file_open(false)
53 , m_is_file_read(false)
54 , m_is_already_init(false)
55 {
56 }
57
58 virtual ~SimpleCsvComparatorService() = default;
59
60 public:
61
62 void init(ISimpleTableOutput* simple_table_output_ptr) override;
63 void clear() override;
64 void editRootDirectory(const Directory& root_directory) override;
65 void print(Integer rank) override;
66 bool writeReferenceFile(Integer rank) override;
67 bool readReferenceFile(Integer rank) override;
68 bool isReferenceExist(Integer rank) override;
69 bool compareWithReference(Integer rank, bool compare_dimension_too) override;
70
71 bool compareElemWithReference(const String& column_name, const String& row_name, Integer rank) override;
72 bool compareElemWithReference(Real elem, const String& column_name, const String& row_name, Integer rank) override;
73
74 bool addColumnForComparing(const String& column_name) override;
75 bool addRowForComparing(const String& row_name) override;
76
77 void isAnArrayExclusiveColumns(bool is_exclusive) override;
78 void isAnArrayExclusiveRows(bool is_exclusive) override;
79
80 void editRegexColumns(const String& regex_column) override;
81 void editRegexRows(const String& regex_row) override;
82
83 void isARegexExclusiveColumns(bool is_exclusive) override;
84 void isARegexExclusiveRows(bool is_exclusive) override;
85
86 bool addEpsilonColumn(const String& column_name, Real epsilon) override;
87 bool addEpsilonRow(const String& row_name, Real epsilon) override;
88
89 private:
90
91 bool _exploreColumn(Integer position);
92 bool _exploreRows(Integer position);
93
94 private:
95
96 ISimpleTableOutput* m_simple_table_output_ptr;
97
98 Directory m_reference_path;
99 Directory m_root_path;
100
101 String m_output_directory;
102 String m_file_name;
103 String m_table_name;
104
105 std::ifstream m_ifstream;
106 bool m_is_file_open;
107 bool m_is_file_read;
108
109 Ref<SimpleTableInternal> m_simple_table_internal_reference;
110 Ref<SimpleTableInternal> m_simple_table_internal_to_compare;
111
112 SimpleTableInternalComparator m_simple_table_internal_comparator;
113 SimpleCsvReaderWriter m_simple_csv_reader_writer;
114
115 bool m_is_already_init;
116};
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121} // End namespace Arcane
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
125
126#endif
ArcaneSimpleCsvComparatorObject(const Arcane::ServiceBuildInfo &sbi)
Constructeur.
Class managing a directory.
Definition Directory.h:36
Interface representing a simple table output.
Reference to an instance.
Structure containing the information to create a service.
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 &regex_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...
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 &regex_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...
-- 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.