Go to the documentation of this file.
32 const scalarRange::testType
type,
67 else if (
equal(minVal, maxVal))
69 type_ = scalarRange::EQ;
105 return scalarRange(scalarRange::LE, -GREAT, maxVal);
111 return scalarRange(scalarRange::LT, -GREAT, maxVal);
128 type_ = scalarRange::NONE;
134 return type_ == scalarRange::NONE;
146 return type_ == scalarRange::EQ;
166 case scalarRange::EQ:
167 case scalarRange::GE:
168 case scalarRange::GT:
171 case scalarRange::LE:
172 case scalarRange::LT:
175 case scalarRange::GE_LE:
177 return (0.5 * min_) + (0.5 * max_);
189 case scalarRange::EQ:
return equal(val, min_);
190 case scalarRange::GE:
return (val >= min_);
191 case scalarRange::GT:
return (val > min_);
192 case scalarRange::LE:
return (val <= max_);
193 case scalarRange::LT:
return (val < max_);
194 case scalarRange::GE_LE:
return (val >= min_ && val <= max_);
195 case scalarRange::ALWAYS:
return true;
196 default:
return false;
209 inline constexpr
bool
210 Foam::scalarRange::operator==
215 return (type_ == rhs.type_ && min_ == rhs.min_ && max_ == rhs.max_);
219 inline constexpr
bool
220 Foam::scalarRange::operator!=
225 return !(*
this == rhs);
bool match(const scalar &val) const
True if the value matches the condition.
static constexpr scalarRange le(const scalar maxVal) noexcept
A less-equals bound.
static constexpr scalarRange gt0() noexcept
A greater-than zero bound.
constexpr scalarRange() noexcept
Construct an empty (inverse, NONE) range - never matches.
scalar max() const noexcept
The max value of the range.
static constexpr scalarRange zero_one() noexcept
A greater-equals 0, less-equals 1 bound.
bool operator()(const scalar &val) const
Identical to match(), for use as a predicate.
Scalar bounds to be used as a unary predicate.
static constexpr scalarRange ge(const scalar minVal) noexcept
A greater-equals bound.
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
scalar min() const noexcept
The min value of the range.
bool empty() const noexcept
True if range is empty (eg, inverted, NONE)
static constexpr scalarRange ge0() noexcept
A greater-equals zero bound.
void clear() noexcept
Reset to an empty (inverse, NONE) range.
static constexpr scalarRange lt(const scalar maxVal) noexcept
A less-than bound.
bool single() const noexcept
True if the range bounds represent a single value.
bool equal(const T &s1, const T &s2)
Compare two values for equality.
bool valid() const noexcept
True if range is non-empty.
static constexpr scalarRange gt(const scalar minVal) noexcept
A greater-than bound.
scalar value() const
A representative (average) value for the range.