Skip to content

Commit c95859b

Browse files
authored
Merge pull request #167 from thelfer/166-function-make-check-a-free-function
Fix Issue #166
2 parents 0db0889 + 9ec58ef commit c95859b

16 files changed

+123
-29
lines changed

include/MGIS/Function/Algorithms.ixx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ namespace mgis::function {
259259
return ctx.registerErrorMessage("unmatched number of components");
260260
}
261261
//
262-
if (!e.check(ctx)) {
262+
if (!check(ctx, e)) {
263263
return false;
264264
}
265265
allocateWorkspace(e);
@@ -284,7 +284,7 @@ namespace mgis::function {
284284
return ctx.registerErrorMessage("non scalar evaluator");
285285
}
286286
//
287-
if (!e.check(ctx)) {
287+
if (!check(ctx, e)) {
288288
return false;
289289
}
290290
allocateWorkspace(e);

include/MGIS/Function/BinaryOperationEvaluatorBase.hxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ namespace mgis::function {
120120
const BinaryOperationEvaluatorBase<Child,
121121
FirstEvaluatorType,
122122
SecondEvaluatorType>&);
123+
//! \brief perform consistency checks
124+
template <typename Child,
125+
EvaluatorConcept FirstEvaluatorType,
126+
EvaluatorConcept SecondEvaluatorType>
127+
constexpr bool check(
128+
AbstractErrorHandler&,
129+
const BinaryOperationEvaluatorBase<Child,
130+
FirstEvaluatorType,
131+
SecondEvaluatorType>&);
123132
//! \brief allocate internal workspace
124133
template <typename Child,
125134
EvaluatorConcept FirstEvaluatorType,

include/MGIS/Function/BinaryOperationEvaluatorBase.ixx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ namespace mgis::function {
5858
this->second_evaluator)) {
5959
return false;
6060
}
61-
if (!this->first_evaluator.check(ctx)) {
61+
if (!internals::disambiguateCheck(ctx, this->first_evaluator)) {
6262
return false;
6363
}
64-
if (!this->second_evaluator.check(ctx)) {
64+
if (!internals::disambiguateCheck(ctx, this->second_evaluator)) {
6565
return false;
6666
}
6767
return true;
@@ -169,6 +169,17 @@ namespace mgis::function {
169169
return e.getSpace();
170170
} // end of getSpace
171171

172+
template <typename Child,
173+
EvaluatorConcept FirstEvaluatorType,
174+
EvaluatorConcept SecondEvaluatorType>
175+
constexpr bool check(
176+
AbstractErrorHandler& eh,
177+
const BinaryOperationEvaluatorBase<Child,
178+
FirstEvaluatorType,
179+
SecondEvaluatorType>& e) {
180+
return e.check(eh);
181+
} // end of check
182+
172183
template <typename Child,
173184
EvaluatorConcept FirstEvaluatorType,
174185
EvaluatorConcept SecondEvaluatorType>

include/MGIS/Function/EvaluatorConcept.hxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ namespace mgis::function {
153153
allocateWorkspace(e);
154154
} && requires(const EvaluatorType& e) {
155155
{ getNumberOfComponents(e) } -> std::same_as<mgis::size_type>;
156+
} && requires(const EvaluatorType& e, AbstractErrorHandler& eh) {
157+
{ check(eh, e) } -> std::same_as<bool>;
156158
} &&((internals::EvaluatorResultQuery<EvaluatorType>::b1) ||
157159
(internals::EvaluatorResultQuery<EvaluatorType>::b2) ||
158160
(internals::EvaluatorResultQuery<EvaluatorType>::b3) ||
@@ -233,6 +235,12 @@ namespace mgis::function {
233235
* the allocateWorkspace function
234236
*/
235237
template <EvaluatorConcept EvaluatorType>
238+
constexpr bool disambiguateCheck(AbstractErrorHandler&, const EvaluatorType&);
239+
/*!
240+
* This helper function allows to disambiguate the call to
241+
* the allocateWorkspace function
242+
*/
243+
template <EvaluatorConcept EvaluatorType>
236244
constexpr void disambiguateAllocateWorkspace(const EvaluatorType&);
237245
/*!
238246
* This helper function allows to disambiguate the call to

include/MGIS/Function/EvaluatorConcept.ixx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ namespace mgis::function::internals {
1515
return getSpace(e);
1616
}
1717

18+
template <EvaluatorConcept EvaluatorType>
19+
constexpr bool disambiguateCheck(AbstractErrorHandler& ctx, const EvaluatorType& e){
20+
return check(ctx, e);
21+
}
22+
1823
template <EvaluatorConcept EvaluatorType>
1924
constexpr void disambiguateAllocateWorkspace(EvaluatorType& e) {
2025
allocateWorkspace(e);

include/MGIS/Function/EvaluatorModifierBase.hxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ namespace mgis::function {
7777
template <typename Child, EvaluatorConcept EvaluatorType>
7878
constexpr decltype(auto) getSpace(
7979
const EvaluatorModifierBase<Child, EvaluatorType>&);
80+
//! \brief perform consistency checks
81+
template <typename Child, EvaluatorConcept EvaluatorType>
82+
constexpr bool check(AbstractErrorHandler&,
83+
const EvaluatorModifierBase<Child, EvaluatorType>&);
8084
//! \brief allocate internal workspace
8185
template <typename Child, EvaluatorConcept EvaluatorType>
8286
constexpr void allocateWorkspace(

include/MGIS/Function/EvaluatorModifierBase.ixx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace mgis::function {
2626
template <typename Child, EvaluatorConcept EvaluatorType>
2727
constexpr bool EvaluatorModifierBase<Child, EvaluatorType>::check(
2828
AbstractErrorHandler& ctx) const {
29-
return this->evaluator.check(ctx);
29+
return internals::disambiguateCheck(ctx, this->evaluator);
3030
} // end of check
3131

3232
template <typename Child, EvaluatorConcept EvaluatorType>
@@ -81,6 +81,12 @@ namespace mgis::function {
8181
return e.getSpace();
8282
}
8383

84+
template <typename Child, EvaluatorConcept EvaluatorType>
85+
constexpr bool check(AbstractErrorHandler& eh,
86+
const EvaluatorModifierBase<Child, EvaluatorType>& e) {
87+
return e.check(eh);
88+
} // end of check
89+
8490
template <typename Child, EvaluatorConcept EvaluatorType>
8591
constexpr void allocateWorkspace(
8692
EvaluatorModifierBase<Child, EvaluatorType>& e) {

include/MGIS/Function/FixedSizeModifier.hxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ namespace mgis::function {
106106

107107
template <EvaluatorConcept EvaluatorType, size_type N>
108108
decltype(auto) getSpace(const FixedSizeModifier<EvaluatorType, N>&);
109-
109+
//! \brief perform consistency checks
110+
template <EvaluatorConcept EvaluatorType, size_type N>
111+
constexpr bool check(AbstractErrorHandler&,
112+
const FixedSizeModifier<EvaluatorType, N>&);
110113
//! \brief allocate internal workspace
111114
template <EvaluatorConcept EvaluatorType, size_type N>
112115
constexpr void allocateWorkspace(FixedSizeModifier<EvaluatorType, N>&);

include/MGIS/Function/FixedSizeModifier.ixx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ namespace mgis::function {
184184
return e.getSpace();
185185
} // end of getSpace
186186

187+
template <EvaluatorConcept EvaluatorType, size_type N>
188+
constexpr bool check(AbstractErrorHandler& eh,
189+
const FixedSizeModifier<EvaluatorType, N>& e){
190+
return e.check(eh);
191+
} // end of check
192+
187193
template <EvaluatorConcept EvaluatorType, size_type N>
188194
constexpr void allocateWorkspace(FixedSizeModifier<EvaluatorType, N>& e) {
189195
return e.allocateWorkspace();

include/MGIS/Function/FixedSizeView.hxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ namespace mgis::function {
145145

146146
template <FunctionConcept FunctionType, size_type N>
147147
constexpr decltype(auto) getSpace(const FixedSizeView<FunctionType, N>&);
148-
148+
//! \brief perform consistency checks
149+
template <FunctionConcept FunctionType, size_type N>
150+
constexpr bool check(AbstractErrorHandler&,
151+
const FixedSizeView<FunctionType, N>&);
149152
//! \brief allocate internal workspace
150153
template <FunctionConcept FunctionType, size_type N>
151154
constexpr void allocateWorkspace(FixedSizeView<FunctionType, N>&) noexcept;

0 commit comments

Comments
 (0)