37 #include <OpenMS/config.h>
87 return min_ <= value && value <= max_;
93 return contains(inner_range.
min_) && contains(inner_range.
max_);
134 min_ = std::min(min_, other.
min_);
135 max_ = std::max(max_, other.
max_);
141 min_ = std::min(min_, value);
142 max_ = std::max(max_, value);
157 if (isEmpty())
return;
158 const double dist = max_ - min_;
159 const double extension = dist * (factor - 1) / 2;
171 return min_ == rhs.
min_ && max_ == rhs.
max_;
176 double min_ = std::numeric_limits<double>::max();
177 double max_ = -std::numeric_limits<double>::max();
453 template<
typename... RangeBases>
464 using T_BASE = std::decay_t<decltype(*base)>;
465 equal &= ((T_BASE&) rhs == (T_BASE&) *
this);
475 template <
typename... RangeBasesOther>
480 using T_BASE = std::decay_t<decltype(*base)>;
483 base->assign((T_BASE&) rhs);
495 template<
typename... RangeBasesOther>
500 throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION ,
"No assignment took place (no dimensions in common!);");
508 template<
typename... RangeBasesOther>
513 using T_BASE = std::decay_t<decltype(*base)>;
516 base->extend((T_BASE&) rhs);
527 template<
typename... RangeBasesOther>
532 throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"No assignment took place (no dimensions in common!);");
540 base->scaleBy(factor);
550 using Base = std::decay_t<decltype(*base)>;
551 if (base->DIM == dim)
552 r_base = (Base*)
this;
555 assert((r_base !=
nullptr) &&
"No base class has this MSDim!");
562 constexpr
size_t total{
sizeof...(RangeBases)};
565 count += !base->isEmpty();
582 template<
typename... RangeBasesOther>
585 bool contained =
true;
586 bool has_overlap =
false;
588 using T_BASE = std::decay_t<decltype(*base)>;
592 if (((T_BASE&)rhs).isEmpty())
return;
593 if (base->contains((T_BASE&) rhs))
return;
620 template<
typename Visitor>
623 (void(visitor(
static_cast<RangeBases*
>(
this))), ...);
626 template<
typename Visitor>
629 (void(visitor(
static_cast<const RangeBases*
>(
this))), ...);
633 template<
typename Visitor>
636 (void(visitor(
static_cast<const RangeBases*
>(
nullptr))), ...);
640 template<
typename... Range>
649 template <
typename ...RangeBases>
Invalid range exception.
Definition: Exception.h:278
Definition: RangeManager.h:652
RangeManager< RangeBases... > & getRange()
get mutable range, provided for efficiency reasons (avoid updateRanges(), if only minor changes were ...
Definition: RangeManager.h:665
virtual void updateRanges()=0
const RangeManager< RangeBases... > & getRange() const
get range of current data (call updateRanges() before to ensure the range is accurate)
Definition: RangeManager.h:659
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:455
bool assignUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:476
HasRangeType hasRange() const
is any/some/all dimension in this range populated?
Definition: RangeManager.h:560
RangeBase & getRangeForDim(MSDim dim)
obtain a range dimension at runtime using dim
Definition: RangeManager.h:545
bool operator==(const RangeManager &rhs) const
Definition: RangeManager.h:460
void for_each_base_(Visitor &&visitor)
use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for e...
Definition: RangeManager.h:621
void for_each_base_(Visitor &&visitor) const
.. and a const version
Definition: RangeManager.h:627
void scaleBy(const double factor)
calls RangeBase::scale() for each dimension
Definition: RangeManager.h:537
bool extendUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:509
void clearRanges()
Resets all ranges.
Definition: RangeManager.h:603
void printRange(std::ostream &out) const
print each dimension (base classes) to a stream
Definition: RangeManager.h:611
void extend(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:528
void assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:496
bool containsAll(const RangeManager< RangeBasesOther... > &rhs) const
Definition: RangeManager.h:583
static void static_for_each_base_(Visitor &&visitor)
use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for e...
Definition: RangeManager.h:634
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
MSDim
Dimensions of data acquisition for MS data.
Definition: RangeManager.h:49
HasRangeType
Enum listing state of dimensions (RangeBases)
Definition: RangeManager.h:432
@ ALL
all dimensions are filled
@ SOME
some dimensions are empty, some are filled
@ NONE
all dimensions are empty (=cleared)
Base class for a simple range with minimum and maximum.
Definition: RangeManager.h:58
double max_
Definition: RangeManager.h:177
void setMin(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:103
void scaleBy(const double factor)
Scale the range of the dimension by a factor. A factor > 1 increases the range; factor < 1 decreases ...
Definition: RangeManager.h:155
void assign(const RangeBase &rhs)
Definition: RangeManager.h:164
bool contains(const double value) const
is value within [min, max]?
Definition: RangeManager.h:85
RangeBase()=default
Ctor: initialize with empty range.
void extend(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:139
bool contains(const RangeBase &inner_range) const
is the range inner_range within [min, max]?
Definition: RangeManager.h:91
double getMin() const
only useful if isEmpty() returns false
Definition: RangeManager.h:119
void clear()
make the range empty, i.e. isEmpty() will be true
Definition: RangeManager.h:73
void setMax(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:111
bool isEmpty() const
is the range empty (i.e. default constructed or cleared using clear())?
Definition: RangeManager.h:79
double min_
Definition: RangeManager.h:176
RangeBase(const double min, const double max)
Definition: RangeManager.h:65
bool operator==(const RangeBase &rhs) const
Definition: RangeManager.h:169
double getMax() const
only useful if isEmpty() returns false
Definition: RangeManager.h:125
void extend(const RangeBase &other)
ensure the range includes the range of other
Definition: RangeManager.h:132
Definition: RangeManager.h:306
void setMinIntensity(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:323
double getMinIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:335
void extendIntensity(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:348
bool containsIntensity(const double value) const
is value within [min, max]?
Definition: RangeManager.h:354
RangeIntensity(const double min, const double max)
Definition: RangeManager.h:311
double getMaxIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:341
bool containsIntensity(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:360
void setMaxIntensity(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:329
Definition: RangeManager.h:245
bool containsMZ(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:299
void setMaxMZ(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:268
void extendMZ(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:287
void setMinMZ(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:262
double getMaxMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:280
double getMinMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:274
RangeMZ(const double min, const double max)
Definition: RangeManager.h:250
bool containsMZ(const double value) const
is value within [min, max]?
Definition: RangeManager.h:293
Definition: RangeManager.h:369
bool containsMobility(const double value) const
is value within [min, max]?
Definition: RangeManager.h:416
void extendMobility(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:410
double getMinMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:397
bool containsMobility(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:422
double getMaxMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:403
void setMinMobility(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:385
void setMaxMobility(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:391
RangeMobility(const double min, const double max)
Definition: RangeManager.h:373
Definition: RangeManager.h:182
bool containsRT(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:236
void extendRT(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:224
double getMaxRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:217
RangeRT(const double min, const double max)
Definition: RangeManager.h:187
void setMaxRT(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:205
void setMinRT(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:199
double getMinRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:211
bool containsRT(const double value) const
is value within [min, max]?
Definition: RangeManager.h:230