OpenMS
RangeManager.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
13 #include <OpenMS/config.h>
14 #include <algorithm> // for min/max
15 #include <cassert>
16 #include <cmath> // for nan()
17 #include <iosfwd> // for std::ostream
18 
19 namespace OpenMS
20 {
22 enum class MSDim
23 {
24  RT,
25  MZ,
26  INT,
27  IM
28 };
29 
30 struct RangeRT;
31 struct RangeMZ;
32 struct RangeIntensity;
33 struct RangeMobility;
34 
36 struct OPENMS_DLLAPI RangeBase
37 {
38 public:
40  RangeBase() = default;
41 
43  RangeBase(const double single): min_(single), max_(single)
44  {
45  }
46 
49  RangeBase(const double min, const double max): min_(min), max_(max)
50  {
51  if (min_ > max_) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Invalid initialization of range");
52  }
54  RangeBase(const RangeBase& rhs) = default;
55 
57  RangeBase(RangeBase&& rhs) noexcept = default;
58 
60  RangeBase& operator=(const RangeBase& rhs) = default;
61 
63  RangeBase& operator=(RangeBase&& rhs) noexcept = default;
64 
66  ~RangeBase() noexcept = default;
67 
70  operator RangeRT() const;
73  operator RangeMZ() const;
76  operator RangeIntensity() const;
79  operator RangeMobility() const;
80 
82  void clear()
83  {
84  *this = RangeBase(); // overwrite with fresh instance
85  }
86 
88  bool isEmpty() const
89  {
90  return min_ > max_;
91  }
92 
94  bool contains(const double value) const
95  {
96  return uint8_t(min_ <= value) & uint8_t(value <= max_); // using && leads to branches on all compilers in Debug and in Release on MVSC
97  }
98 
100  bool contains(const RangeBase& inner_range) const
101  {
102  return uint8_t(contains(inner_range.min_))
103  & uint8_t(contains(inner_range.max_)); // using && leads to branches on all compilers in Debug and in Release on MVSC
104  }
105 
111 
113  void setMin(const double min)
114  {
115  min_ = min;
116  if (max_ < min) max_ = min;
117  }
118 
120  void setMax(const double max)
121  {
122  max_ = max;
123  if (min_ > max) min_ = max;
124  }
125 
127  double getMin() const
128  {
129  return min_;
130  }
131 
133  double getMax() const
134  {
135  return max_;
136  }
138 
140  void extend(const RangeBase& other)
141  {
142  min_ = std::min(min_, other.min_);
143  max_ = std::max(max_, other.max_);
144  }
145 
147  void extend(const double value)
148  {
149  min_ = std::min(min_, value);
150  max_ = std::max(max_, value);
151  }
152 
156  void extendLeftRight(const double by)
157  {
158  if (isEmpty()) return;
159  min_ -= by;
160  max_ += by;
161  }
162 
168  void minSpanIfSingular(const double min_span)
169  {
170  if (min_ == max_) extendLeftRight(min_span / 2);
171  }
172 
179  void clampTo(const RangeBase& other)
180  {
181  if (isEmpty()) return;
182  if (other.isEmpty()) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
183 
184  min_ = std::max(min_, other.min_);
185  max_ = std::min(max_, other.max_);
186  }
187 
193  void pushInto(const RangeBase& sandbox)
194  {
195  if (isEmpty()) return;
196  if (sandbox.isEmpty()) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
197 
198  if (! sandbox.contains(*this))
199  {
200  if (getSpan() > sandbox.getSpan())
201  { // make interval fit into sandbox (= ensure full containment)
202  max_ = min_ + sandbox.getSpan();
203  }
204  if (min_ < sandbox.min_)
205  { // need to shift right (positive shift)
206  shift(sandbox.min_ - min_);
207  }
208  else if (max_ > sandbox.max_)
209  { // need to shift left (negative shift)
210  shift(sandbox.max_ - max_);
211  }
212  }
213  }
214 
225  void scaleBy(const double factor)
226  {
227  if (isEmpty()) return;
228  const double dist = max_ - min_;
229  const double extension = dist * (factor - 1) / 2;
230  min_ -= extension;
231  max_ += extension;
232  }
233 
236  void shift(const double distance)
237  {
238  if (isEmpty()) return;
239  min_ += distance;
240  max_ += distance;
241  }
242 
245  double center() const
246  {
247  if (isEmpty()) return nan("");
248  return min_ + (max_ - min_) / 2.0;
249  }
250 
253  double getSpan() const
254  {
255  if (isEmpty()) return nan("");
256  return max_ - min_;
257  }
258 
259  bool operator==(const RangeBase& rhs) const
260  {
261  return min_ == rhs.min_ && max_ == rhs.max_;
262  }
263 
268  std::pair<double, double> getNonEmptyRange() const
269  {
270  // pair with full range
271  if (isEmpty()) return {std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max()};
272  else
273  return {min_, max_};
274  }
275 
276 protected:
277  // make members non-accessible to maintain invariant: min <= max (unless uninitialized)
278  double min_ = std::numeric_limits<double>::max();
279  double max_ = std::numeric_limits<double>::lowest();
280 };
281 
282 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeBase& b);
283 
284 struct OPENMS_DLLAPI RangeRT : public RangeBase
285 {
286 
287  const static MSDim DIM = MSDim::RT;
288 
289  // Rule of 0!
290  using RangeBase::RangeBase; // inherit C'tors from base
291  using RangeBase::operator=; // inherit assignment operator from base
292 
298 
300  void setMinRT(const double min)
301  {
302  setMin(min);
303  }
304 
306  void setMaxRT(const double max)
307  {
308  setMax(max);
309  }
310 
312  double getMinRT() const
313  {
314  return min_;
315  }
316 
318  double getMaxRT() const
319  {
320  return max_;
321  }
323 
325  void extendRT(const double value)
326  {
327  extend(value);
328  }
329 
331  bool containsRT(const double value) const
332  {
333  return RangeBase::contains(value);
334  }
335 
337  bool containsRT(const RangeBase& inner_range) const
338  {
339  return RangeBase::contains(inner_range);
340  }
341 };
342 
343 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeRT& range);
344 
345 struct OPENMS_DLLAPI RangeMZ : public RangeBase
346 {
347 
348  const static MSDim DIM = MSDim::MZ;
349 
350  // Rule of 0!
351  using RangeBase::RangeBase; // inherit C'tors from base
352  using RangeBase::operator=; // inherit assignment operator
353 
359 
361  void setMinMZ(const double min)
362  {
363  setMin(min);
364  }
365 
367  void setMaxMZ(const double max)
368  {
369  setMax(max);
370  }
371 
373  double getMinMZ() const
374  {
375  return min_;
376  }
377 
379  double getMaxMZ() const
380  {
381  return max_;
382  }
384 
386  void extendMZ(const double value)
387  {
388  extend(value);
389  }
390 
392  bool containsMZ(const double value) const
393  {
394  return RangeBase::contains(value);
395  }
396 
398  bool containsMZ(const RangeBase& inner_range) const
399  {
400  return RangeBase::contains(inner_range);
401  }
402 };
403 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeMZ& range);
404 
405 struct OPENMS_DLLAPI RangeIntensity : public RangeBase
406 {
407 
408  const static MSDim DIM = MSDim::INT;
409 
410  // Rule of 0!
411  using RangeBase::RangeBase; // inherit C'tors from base
412  using RangeBase::operator=; // inherit assignment operator
413 
419 
421  void setMinIntensity(const double min)
422  {
423  setMin(min);
424  }
425 
427  void setMaxIntensity(const double max)
428  {
429  setMax(max);
430  }
431 
433  double getMinIntensity() const
434  {
435  return min_;
436  }
437 
439  double getMaxIntensity() const
440  {
441  return max_;
442  }
444 
446  void extendIntensity(const double value)
447  {
448  extend(value);
449  }
450 
452  bool containsIntensity(const double value) const
453  {
454  return RangeBase::contains(value);
455  }
456 
458  bool containsIntensity(const RangeBase& inner_range) const
459  {
460  return RangeBase::contains(inner_range);
461  }
462 };
463 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeIntensity& range);
464 
465 struct OPENMS_DLLAPI RangeMobility : public RangeBase
466 {
467  const static MSDim DIM = MSDim::IM;
468 
469  // Rule of 0!
470  using RangeBase::RangeBase; // inherit C'tors from base
471  using RangeBase::operator=; // inherit assignment operator
472 
478 
480  void setMinMobility(const double min)
481  {
482  setMin(min);
483  }
484 
486  void setMaxMobility(const double max)
487  {
488  setMax(max);
489  }
490 
492  double getMinMobility() const
493  {
494  return min_;
495  }
496 
498  double getMaxMobility() const
499  {
500  return max_;
501  }
503 
505  void extendMobility(const double value)
506  {
507  extend(value);
508  }
509 
511  bool containsMobility(const double value) const
512  {
513  return RangeBase::contains(value);
514  }
515 
517  bool containsMobility(const RangeBase& inner_range) const
518  {
519  return RangeBase::contains(inner_range);
520  }
521 };
522 
523 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeMobility& range);
524 
526 enum class HasRangeType
527 {
528  ALL,
529  SOME,
530  NONE
531 };
532 
548 template<typename... RangeBases>
549 class RangeManager : public RangeBases...
550 {
551 public:
552  using ThisRangeType = RangeManager<RangeBases...>;
553 
554  // rule of 0 -- no need for a virtual d'tor or anything fancy
555  // ...
556 
557  bool operator==(const RangeManager& rhs) const
558  {
559  bool equal = true;
560  for_each_base_([&](auto* base) {
561  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
562  equal &= ((T_BASE&)rhs == (T_BASE&)*this);
563  });
564  return equal;
565  }
566 
567  bool operator!=(const RangeManager& rhs) const
568  {
569  return ! operator==(rhs);
570  }
571 
576  template<typename... RangeBasesOther>
578  {
579  bool found = false;
580  for_each_base_([&](auto* base) {
581  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
582  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
583  {
584  base->operator=((T_BASE&)rhs);
585  found = true;
586  }
587  });
588 
589  return found;
590  }
591 
596  template<typename... RangeBasesOther>
598  {
599  if (! assignUnsafe(rhs))
600  {
601  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
602  }
603  return *this;
604  }
605 
610  template<typename... RangeBasesOther>
612  {
613  bool found = false;
614  for_each_base_([&](auto* base) {
615  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
616  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
617  {
618  base->extend((T_BASE&)rhs);
619  found = true;
620  }
621  });
622  return found;
623  }
624 
629  template<typename... RangeBasesOther>
631  {
632  if (! extendUnsafe(rhs))
633  {
634  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
635  }
636  }
637 
639  void scaleBy(const double factor)
640  {
641  for_each_base_([&](auto* base) { base->scaleBy(factor); });
642  }
643 
652  void minSpanIfSingular(const double min_span)
653  {
654  for_each_base_([&](auto* base) { base->minSpanIfSingular(min_span); });
655  }
656 
657 
663  template<typename... RangeBasesOther>
665  {
666  bool found = false;
667  for_each_base_([&](auto* base) {
668  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
669  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
670  {
671  const auto& rhs_base = (T_BASE&)rhs;
672  if (! rhs_base.isEmpty()) base->pushInto(rhs_base);
673  found = true;
674  }
675  });
676  return found;
677  }
678 
684  template<typename... RangeBasesOther>
686  {
687  if (! pushIntoUnsafe(sandbox))
688  {
689  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
690  }
691  }
692 
693 
698  template<typename... RangeBasesOther>
700  {
701  bool found = false;
702  for_each_base_([&](auto* base) {
703  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
704  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
705  {
706  const auto& rhs_base = (T_BASE&)rhs;
707  if (! rhs_base.isEmpty()) base->clampTo(rhs_base);
708  found = true;
709  }
710  });
711  return found;
712  }
713 
719  template<typename... RangeBasesOther>
721  {
722  if (! clampToUnsafe(rhs))
723  {
724  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
725  }
726  }
727 
729  const RangeBase& getRangeForDim(MSDim dim) const
730  {
731  RangeBase* r_base = nullptr;
732 
733  static_for_each_base_([&](auto* base) {
734  using Base = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
735  if (base->DIM == dim) r_base = (Base*)this;
736  });
737 
738  assert((r_base != nullptr) && "No base class has this MSDim!");
739  return *r_base;
740  }
741 
744  {
745  RangeBase* r_base = nullptr;
746 
747  static_for_each_base_([&](auto* base) {
748  using Base = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
749  if (base->DIM == dim) r_base = (Base*)this;
750  });
751 
752  assert((r_base != nullptr) && "No base class has this MSDim!");
753  return *r_base;
754  }
755 
758  {
759  constexpr size_t total {sizeof...(RangeBases)}; // total number of bases
760  size_t count {0};
761  for_each_base_([&](auto* base) { count += ! base->isEmpty(); });
762  switch (count)
763  {
764  case 0:
765  return HasRangeType::NONE;
766  case total:
767  return HasRangeType::ALL;
768  default:
769  return HasRangeType::SOME;
770  }
771  }
772 
777  template<typename... RangeBasesOther>
779  {
780  bool contained = true; // assume rhs is contained, until proven otherwise
781  bool has_overlap = false;
782  for_each_base_([&](auto* base) {
783  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
784  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
785  {
786  has_overlap = true; // at least one dimension overlaps
787  if (((T_BASE&)rhs).isEmpty()) return;
788  if (base->contains((T_BASE&)rhs)) return;
789  contained = false;
790  }
791  });
792  if (! has_overlap) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
793 
794  return contained;
795  }
796 
798  void clearRanges()
799  {
800  for_each_base_([&](auto* base) { base->clear(); });
801  }
802 
806  {
807  switch (range)
808  {
809  case DIM_UNIT::RT:
810  if constexpr (std::is_base_of_v<RangeRT, ThisRangeType>) this->RangeRT::clear();
811  break;
812  case DIM_UNIT::MZ:
813  if constexpr (std::is_base_of_v<RangeMZ, ThisRangeType>) this->RangeMZ::clear();
814  break;
815  case DIM_UNIT::INT:
816  if constexpr (std::is_base_of_v<RangeIntensity, ThisRangeType>) this->RangeIntensity::clear();
817  break;
818  // assume all ion mobility ranges are the same and never occur together. If this is violated at some point, then split RangeMobility into
819  // subclasses...
820  case DIM_UNIT::IM_MS:
821  case DIM_UNIT::IM_VSSC:
822  case DIM_UNIT::FAIMS_CV:
823  if constexpr (std::is_base_of_v<RangeMobility, ThisRangeType>) this->RangeMobility::clear();
824  break;
825  default:
826  // all cases should be covered above
827  assert(false && "This should never be reached. Did you forget to implement a new DIM_UNIT?");
828  }
829  return *this;
830  }
831 
833  void printRange(std::ostream& out) const
834  {
835  for_each_base_([&](auto* base) { out << *base; });
836  }
837 
838 protected:
840  template<typename Visitor>
841  void for_each_base_(Visitor&& visitor)
842  {
843  (void(visitor(static_cast<RangeBases*>(this))), ...);
844  }
846  template<typename Visitor>
847  void for_each_base_(Visitor&& visitor) const
848  {
849  (void(visitor(static_cast<const RangeBases*>(this))), ...);
850  }
851 
853  template<typename Visitor>
854  static void static_for_each_base_(Visitor&& visitor)
855  {
856  (void(visitor(static_cast<const RangeBases*>(nullptr))), ...);
857  }
858 };
859 
860 template<typename... Range>
861 std::ostream& operator<<(std::ostream& out, const RangeManager<Range...>& me)
862 {
863  me.printRange(out);
864  return out;
865 }
866 
869 template<typename... RangeBases>
870 class RangeManagerContainer : public RangeManager<RangeBases...>
871 {
872 public:
873  using ThisRangeType = typename RangeManager<RangeBases...>::ThisRangeType;
874 
876  virtual ~RangeManagerContainer() = default; // required since we have virtual methods
877 
880  virtual void updateRanges() = 0;
881 
883  const ThisRangeType& getRange() const
884  {
885  return (ThisRangeType&)*this;
886  }
887 
890  {
891  return (ThisRangeType&)*this;
892  }
893 };
894 
897 
898 } // namespace OpenMS
Invalid range exception.
Definition: Exception.h:257
Definition: RangeManager.h:871
const ThisRangeType & getRange() const
get range of current data (call updateRanges() before to ensure the range is accurate)
Definition: RangeManager.h:883
typename RangeManager< RangeBases... >::ThisRangeType ThisRangeType
Definition: RangeManager.h:873
virtual void updateRanges()=0
ThisRangeType & getRange()
get mutable range, provided for efficiency reasons (avoid updateRanges(), if only minor changes were ...
Definition: RangeManager.h:889
virtual ~RangeManagerContainer()=default
D'tor.
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:550
void pushInto(const RangeManager< RangeBasesOther... > &sandbox)
Definition: RangeManager.h:685
bool assignUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:577
const RangeBase & getRangeForDim(MSDim dim) const
obtain a range dimension at runtime using dim
Definition: RangeManager.h:729
bool pushIntoUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:664
bool clampToUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:699
HasRangeType hasRange() const
is any/some/all dimension in this range populated?
Definition: RangeManager.h:757
RangeBase & getRangeForDim(MSDim dim)
obtain a range dimension at runtime using dim
Definition: RangeManager.h:743
bool operator==(const RangeManager &rhs) const
Definition: RangeManager.h:557
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:841
void for_each_base_(Visitor &&visitor) const
.. and a const version
Definition: RangeManager.h:847
ThisRangeType & clear(const DIM_UNIT range)
Definition: RangeManager.h:805
void clampTo(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:720
void scaleBy(const double factor)
calls RangeBase::scale() for each dimension
Definition: RangeManager.h:639
void minSpanIfSingular(const double min_span)
If any dimension is a single point, e.g. min==max, then extend this dimension by min_span / 2 on eith...
Definition: RangeManager.h:652
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:597
bool extendUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:611
void clearRanges()
Resets all ranges.
Definition: RangeManager.h:798
void printRange(std::ostream &out) const
print each dimension (base classes) to a stream
Definition: RangeManager.h:833
void extend(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:630
bool operator!=(const RangeManager &rhs) const
Definition: RangeManager.h:567
bool containsAll(const RangeManager< RangeBasesOther... > &rhs) const
Definition: RangeManager.h:778
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:854
bool contains(T value, T min, T max)
Is a value contained in [min, max] ?
Definition: MathFunctions.h:63
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
DIM
Definition: DimMapper.h:601
MSDim
Dimensions of data acquisition for MS data.
Definition: RangeManager.h:23
DIM_UNIT
Definition: CommonEnums.h:20
@ IM_VSSC
volt-second per square centimeter (i.e. 1/K_0)
@ INT
intensity
@ FAIMS_CV
FAIMS compensation voltage.
@ RT
RT in seconds.
@ IM_MS
ion mobility milliseconds
HasRangeType
Enum listing state of dimensions (RangeBases)
Definition: RangeManager.h:527
@ 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:37
double max_
Definition: RangeManager.h:279
double getSpan() const
Definition: RangeManager.h:253
RangeBase(const double single)
Cutom C'tor which sets the range to a singular point.
Definition: RangeManager.h:43
RangeBase(const RangeBase &rhs)=default
Copy C'tor.
void setMin(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:113
RangeBase & operator=(RangeBase &&rhs) noexcept=default
Move assignment (seems useless, but is required for completeness in derived classes' move c'tor)
std::pair< double, double > getNonEmptyRange() const
Return the current range, or (if empty) a full range (-1e308, 1e308).
Definition: RangeManager.h:268
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:225
RangeBase & operator=(const RangeBase &rhs)=default
Assignment operator.
void minSpanIfSingular(const double min_span)
If the current range is a single point, e.g. min==max, then extend the range by min_span / 2 on eithe...
Definition: RangeManager.h:168
void pushInto(const RangeBase &sandbox)
Definition: RangeManager.h:193
void shift(const double distance)
Definition: RangeManager.h:236
~RangeBase() noexcept=default
D'tor.
bool contains(const double value) const
is value within [min, max]?
Definition: RangeManager.h:94
double center() const
Definition: RangeManager.h:245
RangeBase()=default
C'tor: initialize with empty range.
void extend(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:147
void extendLeftRight(const double by)
Definition: RangeManager.h:156
RangeBase(RangeBase &&rhs) noexcept=default
Move C'tor (seems useless, but is required for completeness in derived classes' move c'tor)
bool contains(const RangeBase &inner_range) const
is the range inner_range within [min, max]?
Definition: RangeManager.h:100
void clampTo(const RangeBase &other)
Definition: RangeManager.h:179
double getMin() const
only useful if isEmpty() returns false
Definition: RangeManager.h:127
void clear()
make the range empty, i.e. isEmpty() will be true
Definition: RangeManager.h:82
void setMax(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:120
bool isEmpty() const
is the range empty (i.e. min > max)?
Definition: RangeManager.h:88
double min_
Definition: RangeManager.h:278
RangeBase(const double min, const double max)
Definition: RangeManager.h:49
bool operator==(const RangeBase &rhs) const
Definition: RangeManager.h:259
double getMax() const
only useful if isEmpty() returns false
Definition: RangeManager.h:133
void extend(const RangeBase &other)
ensure the range includes the range of other
Definition: RangeManager.h:140
Definition: RangeManager.h:406
void setMinIntensity(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:421
double getMinIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:433
void extendIntensity(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:446
bool containsIntensity(const double value) const
is value within [min, max]?
Definition: RangeManager.h:452
double getMaxIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:439
bool containsIntensity(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:458
void setMaxIntensity(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:427
Definition: RangeManager.h:346
bool containsMZ(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:398
void setMaxMZ(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:367
void extendMZ(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:386
void setMinMZ(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:361
double getMaxMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:379
double getMinMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:373
bool containsMZ(const double value) const
is value within [min, max]?
Definition: RangeManager.h:392
Definition: RangeManager.h:466
bool containsMobility(const double value) const
is value within [min, max]?
Definition: RangeManager.h:511
void extendMobility(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:505
double getMinMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:492
bool containsMobility(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:517
double getMaxMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:498
void setMinMobility(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:480
void setMaxMobility(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:486
Definition: RangeManager.h:285
bool containsRT(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:337
void extendRT(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:325
double getMaxRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:318
void setMaxRT(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:306
void setMinRT(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:300
double getMinRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:312
bool containsRT(const double value) const
is value within [min, max]?
Definition: RangeManager.h:331