Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
SimpleTableInternalComparator.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/* SimpleTableInternalComparator.h (C) 2000-2022 */
9/* */
10/* SimpleTableInternal Comparator. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_STD_SIMPLETABLEINTERNALCOMPARATOR_H
13#define ARCANE_STD_SIMPLETABLEINTERNALCOMPARATOR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/ISimpleTableInternalComparator.h"
18#include "arcane/core/ISimpleTableInternalMng.h"
19#include "arcane/core/ISimpleTableReaderWriter.h"
20
21#include "arcane/std/SimpleTableInternalMng.h"
22#include "arcane/utils/Array.h"
23#include "arcane/utils/FatalErrorException.h"
24
25#include <map>
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arcane
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36class SimpleTableInternalComparator
38{
39 public:
40
41 SimpleTableInternalComparator(const Ref<SimpleTableInternal>& sti_ref, const Ref<SimpleTableInternal>& sti_to_compare)
42 : m_simple_table_internal_reference(sti_ref)
43 , m_simple_table_internal_to_compare(sti_to_compare)
44 , m_simple_table_internal_mng_reference(m_simple_table_internal_reference)
45 , m_simple_table_internal_mng_to_compare(m_simple_table_internal_to_compare)
46 , m_regex_rows("")
47 , m_is_excluding_regex_rows(false)
48 , m_regex_columns("")
49 , m_is_excluding_regex_columns(false)
50 , m_is_excluding_array_rows(false)
51 , m_is_excluding_array_columns(false)
52 , m_epsilons_column()
53 , m_epsilons_row()
54 {
55 if (sti_ref.isNull() || sti_to_compare.isNull())
56 ARCANE_FATAL("The reference passed as a parameter is Null.");
57 }
58
59 SimpleTableInternalComparator()
60 : m_simple_table_internal_reference()
61 , m_simple_table_internal_to_compare()
62 , m_simple_table_internal_mng_reference()
63 , m_simple_table_internal_mng_to_compare()
64 , m_regex_rows("")
65 , m_is_excluding_regex_rows(false)
66 , m_regex_columns("")
67 , m_is_excluding_regex_columns(false)
68 , m_is_excluding_array_rows(false)
69 , m_is_excluding_array_columns(false)
70 , m_epsilons_column()
71 , m_epsilons_row()
72 {
73 }
74
75 virtual ~SimpleTableInternalComparator() = default;
76
77 public:
78
79 bool compare(bool compare_dimension_too) override;
80
81 bool compareElem(const String& column_name, const String& row_name) override;
82 bool compareElem(Real elem, const String& column_name, const String& row_name) override;
83
84 void clearComparator() override;
85
86 bool addColumnForComparing(const String& column_name) override;
87 bool addRowForComparing(const String& row_name) override;
88
89 void isAnArrayExclusiveColumns(bool is_exclusive) override;
90 void isAnArrayExclusiveRows(bool is_exclusive) override;
91
92 void editRegexColumns(const String& regex_column) override;
93 void editRegexRows(const String& regex_row) override;
94
95 void isARegexExclusiveColumns(bool is_exclusive) override;
96 void isARegexExclusiveRows(bool is_exclusive) override;
97
98 bool addEpsilonColumn(const String& column_name, Real epsilon) override;
99 bool addEpsilonRow(const String& row_name, Real epsilon) override;
100
102 void setInternalRef(const Ref<SimpleTableInternal>& simple_table_internal) override;
103
105 void setInternalToCompare(const Ref<SimpleTableInternal>& simple_table_internal) override;
106
107 protected:
108
109 bool _exploreColumn(const String& column_name);
110 bool _exploreRows(const String& row_name);
111
112 protected:
113
114 Ref<SimpleTableInternal> m_simple_table_internal_reference;
115 Ref<SimpleTableInternal> m_simple_table_internal_to_compare;
116
117 SimpleTableInternalMng m_simple_table_internal_mng_reference;
118 SimpleTableInternalMng m_simple_table_internal_mng_to_compare;
119
120 String m_regex_rows;
121 bool m_is_excluding_regex_rows;
122
123 String m_regex_columns;
124 bool m_is_excluding_regex_columns;
125
126 StringUniqueArray m_rows_to_compare;
127 bool m_is_excluding_array_rows;
128
129 StringUniqueArray m_columns_to_compare;
130 bool m_is_excluding_array_columns;
131
132 std::map<String, Real> m_epsilons_column;
133 std::map<String, Real> m_epsilons_row;
134};
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
139} // End namespace Arcane
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144#endif
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Class interface representing a SimpleTableInternal comparator (aka STI).
bool isNull() const
Indicates if the counter references a non-null instance.
Reference to an instance.
bool compare(bool compare_dimension_too) override
Method allowing comparison of the values of the two STIs.
Ref< SimpleTableInternal > internalRef() override
Method allowing retrieval of a reference to the used "reference" SimpleTableInternal object.
bool _exploreColumn(const String &column_name)
Method to determine whether the column named column_name should be explored or not.
void setInternalToCompare(const Ref< SimpleTableInternal > &simple_table_internal) override
Method allowing definition of a reference to the "to compare" SimpleTableInternal.
void isAnArrayExclusiveRows(bool is_exclusive) override
Method allowing definition of whether the row array represents rows to include in the comparison (fal...
void setInternalRef(const Ref< SimpleTableInternal > &simple_table_internal) override
Method allowing definition of a reference to a "reference" SimpleTableInternal.
void isAnArrayExclusiveColumns(bool is_exclusive) override
Method allowing definition of whether the column array represents columns to include in the compariso...
Ref< SimpleTableInternal > internalToCompare() override
Method allowing retrieval of a reference to the used "to compare" SimpleTableInternal object.
bool addEpsilonRow(const String &row_name, Real epsilon) override
Method allowing the definition of an epsilon for a given row. This epsilon must be positive to be con...
bool addRowForComparing(const String &row_name) override
Method allowing the addition of a row to the list of rows to compare.
bool _exploreRows(const String &row_name)
Method to determine whether the row named column_name should be explored or not.
bool compareElem(const String &column_name, const String &row_name) override
Method allowing comparison of a single element. Both SimpleTableInternals are represented by Refs,...
void isARegexExclusiveRows(bool is_exclusive) override
Method allowing specification that the regular expression excludes rows instead of including them.
bool addColumnForComparing(const String &column_name) override
Method allowing the addition of a column to the list of columns to compare.
void editRegexColumns(const String &regex_column) override
Method allowing the addition of a regular expression to determine the columns to compare.
void editRegexRows(const String &regex_row) override
Method allowing the addition of a regular expression to determine the rows to compare.
void isARegexExclusiveColumns(bool is_exclusive) override
Method allowing specification that the regular expression excludes columns instead of including them.
void clearComparator() override
Method allowing the clearing of comparison arrays and regular expressions. Does not affect the STIs.
bool addEpsilonColumn(const String &column_name, Real epsilon) override
Method allowing the definition of an epsilon for a given column. This epsilon must be positive to be ...
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
double Real
Type representing a real number.
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.
Definition UtilsTypes.h:359