Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ISimpleTableComparator.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/* ISimpleTableComparator.h (C) 2000-2025 */
9/* */
10/* Interface for services allowing the comparison of an ISimpleTableOutput */
11/* and a reference file. */
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_CORE_ISIMPLETABLECOMPARATOR_H
14#define ARCANE_CORE_ISIMPLETABLECOMPARATOR_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18#include "arcane/core/ISimpleTableOutput.h"
19
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31/**
32 * \ingroup StandardService
33 * \brief Class interface representing a table comparator. To be used with
34 * a service implementing ISimpleTableOutput.
35 *
36 * The difference with ISimpleTableInternalComparator is
37 * that we compare a SimpleTableInternal contained in
38 * an ISimpleTableOutput with a SimpleTableInternal
39 * generated from a reference file.
40 *
41 * This interface also allows generating the reference files
42 * using the directory name and
43 * the table name of the ISimpleTableOutput, facilitating
44 * the process.
45 */
46class ARCANE_CORE_EXPORT ISimpleTableComparator
47{
48 public:
49
50 virtual ~ISimpleTableComparator() = default;
51
52 public:
53
54 /**
55 * \brief Method allowing the service to be initialized.
56 *
57 * The pointer to an ISimpleTableOutput implementation
58 * must contain the values to be compared or written as
59 * reference values and the destination location of the
60 * output files, so that the location of the reference files
61 * is automatically determined.
62 *
63 * \param simple_table_output_ptr An implementation of ISimpleTableOutput.
64 */
65 virtual void init(ISimpleTableOutput* simple_table_output_ptr) = 0;
66
67 /**
68 * \brief Method allowing the data read by readReferenceFile() to be cleared.
69 * \note Clears the comparator's SimpleTableInternal without affecting that of the
70 * SimpleTableOutput.
71 */
72 virtual void clear() = 0;
73
74 /**
75 * \brief Method allowing the read table to be displayed.
76 *
77 * \param rank The process that must display its table (-1 for all processes).
78 */
79 virtual void print(Integer rank = 0) = 0;
80
81 /**
82 * \brief Method allowing the root directory to be modified.
83 * This allows writing or searching for reference files
84 * elsewhere than in the directory determined by the implementation.
85 *
86 * By default, for the csv implementation, the root directory is:
87 * ./output/csv_ref/
88 *
89 * \param root_directory The new root directory.
90 */
91 virtual void editRootDirectory(const Directory& root_directory) = 0;
92
93 /**
94 * \brief Method allowing reference files to be written.
95 *
96 * \warning (For now), this method uses the object pointed to by
97 * the pointer given during init(), so the writing will occur
98 * in the format desired by the ISimpleTableOutput implementation.
99 * If the reading and writing formats do not match,
100 * a call to "compareWithReference()" will necessarily return
101 * false.
102 *
103 * \param rank The process that must write its file (-1 for all processes).
104 * \return true If the writing was successful (and if calling process != rank).
105 * \return false If the writing did not occur.
106 */
107 virtual bool writeReferenceFile(Integer rank = -1) = 0;
108
109 /**
110 * \brief Method allowing reference files to be read.
111 *
112 * The type of the reference files must correspond to the implementation
113 * of this chosen interface (example: .csv file -> SimpleCsvComparatorService).
114 *
115 * \param rank The process that must read its file (-1 for all processes).
116 * \return true If the file was read (and if calling process != rank).
117 * \return false If the file was not read.
118 */
119 virtual bool readReferenceFile(Integer rank = -1) = 0;
120
121 /**
122 * \brief Method allowing to check if the reference files exist.
123 *
124 * \param rank The process that must look for its file (-1 for all processes).
125 * \return true If the file was found (and if calling process != rank).
126 * \return false If the file was not found.
127 */
128 virtual bool isReferenceExist(Integer rank = -1) = 0;
129
130 /**
131 * \brief Method allowing the ISimpleTableOutput object to be compared
132 * to the reference files.
133 *
134 * \param rank The process that must compare its results (-1 for all processes).
135 * \param compare_dimension_too Whether the dimensions of the value tables should also be compared.
136 * \return true If there are no differences (and if calling process != rank).
137 * \return false If there is at least one difference.
138 */
139 virtual bool compareWithReference(Integer rank = -1, bool compare_dimension_too = false) = 0;
140
141 /**
142 * \brief Method allowing only an element to be compared.
143 * Both SimpleTableInternals are represented by Refs,
144 * so they are always up to date.
145 * This method can be used during calculation, allowing
146 * to compare values as the calculation progresses,
147 * instead of performing a final comparison at the end (it is
148 * still possible to do both).
149 *
150 * \param column_name The name of the column where the element is located.
151 * \param row_name The name of the row where the element is located.
152 * \param rank The process that must compare its results (-1 for all processes).
153 * \return true If the two values are equal.
154 * \return false If the two values are different.
155 */
156 virtual bool compareElemWithReference(const String& column_name, const String& row_name, Integer rank = -1) = 0;
157
158 /**
159 * \brief Method allowing a value to be compared with
160 * a value from the reference table.
161 * This method does not need an internal 'toCompare'
162 * (setInternalToCompare() unnecessary).
163 *
164 * \param elem The value to be compared.
165 * \param column_name The name of the column where the reference element is located.
166 * \param row_name The name of the row where the reference element is located.
167 * \param rank The process that must compare its results (-1 for all processes).
168 * \return true If the two values are equal.
169 * \return false If the two values are different.
170 */
171 virtual bool compareElemWithReference(Real elem, const String& column_name, const String& row_name, Integer rank = -1) = 0;
172
173 /**
174 * \brief Method allowing a column to be added to the list of columns
175 * to be compared.
176 *
177 * \param column_name The name of the column to compare.
178 * \return true If the name was successfully added.
179 * \return false Otherwise.
180 */
181 virtual bool addColumnForComparing(const String& column_name) = 0;
182 /**
183 * \brief Method allowing a row to be added to the list of rows
184 * to be compared.
185 *
186 * \param row_name The name of the row to compare.
187 * \return true If the name was successfully added.
188 * \return false Otherwise.
189 */
190 virtual bool addRowForComparing(const String& row_name) = 0;
191
192 /**
193 * \brief Method allowing definition whether the array of
194 * columns represents the columns to include in the
195 * comparison (false/default) or represents the columns
196 * to exclude from the comparison (true).
197 *
198 * \param is_exclusive true if the columns must be
199 * excluded.
200 */
201 virtual void isAnArrayExclusiveColumns(bool is_exclusive) = 0;
202
203 /**
204 * \brief Method allowing definition whether the array of
205 * rows represents the rows to include in the
206 * comparison (false/default) or represents the rows
207 * to exclude from the comparison (true).
208 *
209 * \param is_exclusive true if the rows must be
210 * excluded.
211 */
212 virtual void isAnArrayExclusiveRows(bool is_exclusive) = 0;
213
214 /**
215 * \brief Method allowing a regular expression to be added
216 * to determine the columns to compare.
217 *
218 * \param regex_column The regular expression (ECMAScript format).
219 */
220 virtual void editRegexColumns(const String& regex_column) = 0;
221 /**
222 * \brief Method allowing a regular expression to be added
223 * to determine the rows to compare.
224 *
225 * \param regex_row The regular expression (ECMAScript format).
226 */
227 virtual void editRegexRows(const String& regex_row) = 0;
228
229 /**
230 * \brief Method allowing to request that the regular expression
231 * excludes columns instead of including them.
232 *
233 * \param is_exclusive If the regular expression is exclusive.
234 */
235 virtual void isARegexExclusiveColumns(bool is_exclusive) = 0;
236 /**
237 * \brief Method allowing to request that the regular expression
238 * excludes rows instead of including them.
239 *
240 * \param is_exclusive If the regular expression is exclusive.
241 */
242 virtual void isARegexExclusiveRows(bool is_exclusive) = 0;
243
244 /**
245 * \brief Method allowing an epsilon to be defined for a given column.
246 * This epsilon must be positive to be taken into account.
247 * If there is a conflict with a row epsilon (defined with addEpsilonRow()),
248 * the largest epsilon is taken into account.
249 * \note If an epsilon has already been defined on this column, then the old
250 * epsilon will be replaced.
251 *
252 * \param column_name The name of the column where the epsilon will be taken into account.
253 * \param epsilon The epsilon error margin.
254 * \return true If the epsilon could be defined.
255 * \return false If the epsilon could not be defined.
256 */
257 virtual bool addEpsilonColumn(const String& column_name, Real epsilon) = 0;
258
259 /**
260 * \brief Method allowing an epsilon to be defined for a given row.
261 * This epsilon must be positive to be taken into account.
262 * If there is a conflict with a column epsilon (defined with addEpsilonColumn()),
263 * the largest epsilon is taken into account.
264 * \note If an epsilon has already been defined on this row, then the old
265 * epsilon will be replaced.
266 *
267 * \param column_name The name of the row where the epsilon will be taken into account.
268 * \param epsilon The epsilon error margin.
269 * \return true If the epsilon could be defined.
270 * \return false If the epsilon could not be defined.
271 */
272 virtual bool addEpsilonRow(const String& row_name, Real epsilon) = 0;
273};
274
275/*---------------------------------------------------------------------------*/
276/*---------------------------------------------------------------------------*/
277
278} // End namespace Arcane
279
280/*---------------------------------------------------------------------------*/
281/*---------------------------------------------------------------------------*/
282
283#endif
Declarations of types on entities.
Class managing a directory.
Definition Directory.h:36
Class interface representing a table comparator. To be used with a service implementing ISimpleTableO...
virtual bool readReferenceFile(Integer rank=-1)=0
Method allowing reference files to be read.
virtual void editRegexRows(const String &regex_row)=0
Method allowing a regular expression to be added to determine the rows to compare.
virtual void isAnArrayExclusiveRows(bool is_exclusive)=0
Method allowing definition whether the array of rows represents the rows to include in the comparison...
virtual void editRootDirectory(const Directory &root_directory)=0
Method allowing the root directory to be modified. This allows writing or searching for reference fil...
virtual bool compareWithReference(Integer rank=-1, bool compare_dimension_too=false)=0
Method allowing the ISimpleTableOutput object to be compared to the reference files.
virtual bool addEpsilonColumn(const String &column_name, Real epsilon)=0
Method allowing an epsilon to be defined for a given column. This epsilon must be positive to be take...
virtual void isARegexExclusiveColumns(bool is_exclusive)=0
Method allowing to request that the regular expression excludes columns instead of including them.
virtual void clear()=0
Method allowing the data read by readReferenceFile() to be cleared.
virtual bool addColumnForComparing(const String &column_name)=0
Method allowing a column to be added to the list of columns to be compared.
virtual void editRegexColumns(const String &regex_column)=0
Method allowing a regular expression to be added to determine the columns to compare.
virtual bool isReferenceExist(Integer rank=-1)=0
Method allowing to check if the reference files exist.
virtual bool writeReferenceFile(Integer rank=-1)=0
Method allowing reference files to be written.
virtual void isAnArrayExclusiveColumns(bool is_exclusive)=0
Method allowing definition whether the array of columns represents the columns to include in the comp...
virtual bool compareElemWithReference(Real elem, const String &column_name, const String &row_name, Integer rank=-1)=0
Method allowing a value to be compared with a value from the reference table. This method does not ne...
virtual bool addRowForComparing(const String &row_name)=0
Method allowing a row to be added to the list of rows to be compared.
virtual void isARegexExclusiveRows(bool is_exclusive)=0
Method allowing to request that the regular expression excludes rows instead of including them.
virtual void print(Integer rank=0)=0
Method allowing the read table to be displayed.
virtual void init(ISimpleTableOutput *simple_table_output_ptr)=0
Method allowing the service to be initialized.
virtual bool compareElemWithReference(const String &column_name, const String &row_name, Integer rank=-1)=0
Method allowing only an element to be compared. Both SimpleTableInternals are represented by Refs,...
virtual bool addEpsilonRow(const String &row_name, Real epsilon)=0
Method allowing an epsilon to be defined for a given row. This epsilon must be positive to be taken i...
Interface representing a simple table output.
-- 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.