1 // -*- C++ -*-
2 /**
3 * @brief Abstract top-level class for all ComparisonOperator
4 *
5 * Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6 *
7 * This library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21 #include "openturns/ComparisonOperator.hxx"
22 #include "openturns/Less.hxx"
23
24 BEGIN_NAMESPACE_OPENTURNS
25
CLASSNAMEINIT(ComparisonOperator)26 CLASSNAMEINIT(ComparisonOperator)
27
28 /* Default constructor */
29 ComparisonOperator::ComparisonOperator()
30 : TypedInterfaceObject<ComparisonOperatorImplementation>(new Less())
31 {
32 // Nothing to do
33 }
34
35
36 /* Constructor from implementation */
ComparisonOperator(const ComparisonOperatorImplementation & op)37 ComparisonOperator::ComparisonOperator(const ComparisonOperatorImplementation & op)
38 : TypedInterfaceObject<ComparisonOperatorImplementation>(op.clone())
39 {
40 // Nothing to do
41 }
42
43
44 /* Return true if comparison succeeds */
operator ()(const Scalar a,const Scalar b) const45 Bool ComparisonOperator::operator()(const Scalar a,
46 const Scalar b) const
47 {
48 return (*getImplementation())(a, b);
49 }
50
compare(Scalar a,Scalar b) const51 Bool ComparisonOperator::compare(Scalar a, Scalar b) const
52 {
53 return (*getImplementation())(a, b);
54 }
55
56
__repr__() const57 String ComparisonOperator::__repr__() const
58 {
59 return getImplementation()->__repr__();
60 }
61
62
63 END_NAMESPACE_OPENTURNS
64