OpenMS
RangeManager.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- 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 
11 #include <OpenMS/config.h>
14 
15 #include <cmath> // for nan()
16 #include <algorithm> // for min/max
17 #include <cassert>
18 #include <iosfwd> // for std::ostream
19 
20 namespace OpenMS
21 {
23  enum class MSDim
24  {
25  RT,
26  MZ,
27  INT,
28  IM
29  };
30 
31  struct RangeRT;
32  struct RangeMZ;
33  struct RangeIntensity;
34  struct RangeMobility;
35 
37  struct OPENMS_DLLAPI RangeBase
38  {
39  public:
41  RangeBase() = default;
42 
45  RangeBase(const double min, const double max) :
46  min_(min), max_(max)
47  {
48  if (min_ > max_)
49  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Invalid initialization of range");
50  }
52  RangeBase(const RangeBase& rhs) = default;
53 
55  RangeBase(RangeBase&& rhs) noexcept = default;
56 
58  RangeBase& operator=(const RangeBase& rhs) = default;
59 
61  RangeBase& operator=(RangeBase&& rhs) noexcept = default;
62 
64  ~RangeBase() noexcept = default;
65 
67  operator RangeRT() const;
69  operator RangeMZ() const;
71  operator RangeIntensity() const;
73  operator RangeMobility() const;
74 
76  void clear()
77  {
78  *this = RangeBase(); // overwrite with fresh instance
79  }
80 
82  bool isEmpty() const
83  {
84  return min_ > max_;
85  }
86 
88  bool contains(const double value) const
89  {
90  return uint8_t(min_ <= value) & uint8_t(value <= max_); // using && leads to branches on all compilers in Debug and in Release on MVSC
91  }
92 
94  bool contains(const RangeBase& inner_range) const
95  {
96  return uint8_t(contains(inner_range.min_)) & uint8_t(contains(inner_range.max_)); // using && leads to branches on all compilers in Debug and in Release on MVSC
97  }
98 
104 
106  void setMin(const double min)
107  {
108  min_ = min;
109  if (max_ < min)
110  max_ = min;
111  }
112 
114  void setMax(const double max)
115  {
116  max_ = max;
117  if (min_ > max)
118  min_ = max;
119  }
120 
122  double getMin() const
123  {
124  return min_;
125  }
126 
128  double getMax() const
129  {
130  return max_;
131  }
133 
135  void extend(const RangeBase& other)
136  {
137  min_ = std::min(min_, other.min_);
138  max_ = std::max(max_, other.max_);
139  }
140 
142  void extend(const double value)
143  {
144  min_ = std::min(min_, value);
145  max_ = std::max(max_, value);
146  }
147 
151  void extendLeftRight(const double by)
152  {
153  if (isEmpty()) return;
154  min_ -= by;
155  max_ += by;
156  }
157 
163  void minSpanIfSingular(const double min_span)
164  {
165  if (min_ == max_) extendLeftRight(min_span / 2);
166  }
167 
174  void clampTo(const RangeBase& other)
175  {
176  if (isEmpty()) return;
177  if (other.isEmpty()) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
178 
179  min_ = std::max(min_, other.min_);
180  max_ = std::min(max_, other.max_);
181  }
182 
188  void pushInto(const RangeBase& sandbox)
189  {
190  if (isEmpty()) return;
191  if (sandbox.isEmpty()) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
192 
193  if (!sandbox.contains(*this))
194  {
195  if (getSpan() > sandbox.getSpan())
196  { // make interval fit into sandbox (= ensure full containment)
197  max_ = min_ + sandbox.getSpan();
198  }
199  if (min_ < sandbox.min_)
200  { // need to shift right (positive shift)
201  shift(sandbox.min_ - min_);
202  }
203  else if (max_ > sandbox.max_)
204  { // need to shift left (negative shift)
205  shift(sandbox.max_ - max_);
206  }
207  }
208 
209  }
210 
211 
222  void scaleBy(const double factor)
223  {
224  if (isEmpty()) return;
225  const double dist = max_ - min_;
226  const double extension = dist * (factor - 1) / 2;
227  min_ -= extension;
228  max_ += extension;
229  }
230 
233  void shift(const double distance)
234  {
235  if (isEmpty()) return;
236  min_ += distance;
237  max_ += distance;
238  }
239 
242  double center() const
243  {
244  if (isEmpty()) return nan("");
245  return min_ + (max_ - min_) / 2.0;
246  }
247 
250  double getSpan() const
251  {
252  if (isEmpty()) return nan("");
253  return max_ - min_;
254  }
255 
256  bool operator==(const RangeBase& rhs) const
257  {
258  return min_ == rhs.min_ && max_ == rhs.max_;
259  }
260 
265  std::pair<double, double> getNonEmptyRange() const
266  {
267  // pair with full range
268  if (isEmpty()) return {std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max()};
269  else return {min_, max_};
270  }
271 
272  protected:
273  // make members non-accessible to maintain invariant: min <= max (unless uninitialized)
274  double min_ = std::numeric_limits<double>::max();
275  double max_ = std::numeric_limits<double>::lowest();
276  };
277 
278  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeBase& b);
279 
280  struct OPENMS_DLLAPI RangeRT : public RangeBase {
281 
282  const static MSDim DIM = MSDim::RT;
283 
284  // Rule of 0!
285  using RangeBase::RangeBase; // inherit C'tors from base
286 
292 
294  void setMinRT(const double min)
295  {
296  setMin(min);
297  }
298 
300  void setMaxRT(const double max)
301  {
302  setMax(max);
303  }
304 
306  double getMinRT() const
307  {
308  return min_;
309  }
310 
312  double getMaxRT() const
313  {
314  return max_;
315  }
317 
319  void extendRT(const double value)
320  {
321  extend(value);
322  }
323 
325  bool containsRT(const double value) const
326  {
327  return RangeBase::contains(value);
328  }
329 
331  bool containsRT(const RangeBase& inner_range) const
332  {
333  return RangeBase::contains(inner_range);
334  }
335  };
336 
337  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeRT& range);
338 
339  struct OPENMS_DLLAPI RangeMZ : public RangeBase
340  {
341 
342  const static MSDim DIM = MSDim::MZ;
343 
344  // Rule of 0!
345  using RangeBase::RangeBase; // inherit C'tors from base
346 
352 
354  void setMinMZ(const double min)
355  {
356  setMin(min);
357  }
358 
360  void setMaxMZ(const double max)
361  {
362  setMax(max);
363  }
364 
366  double getMinMZ() const
367  {
368  return min_;
369  }
370 
372  double getMaxMZ() const
373  {
374  return max_;
375  }
377 
379  void extendMZ(const double value)
380  {
381  extend(value);
382  }
383 
385  bool containsMZ(const double value) const
386  {
387  return RangeBase::contains(value);
388  }
389 
391  bool containsMZ(const RangeBase& inner_range) const
392  {
393  return RangeBase::contains(inner_range);
394  }
395  };
396  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeMZ& range);
397 
398  struct OPENMS_DLLAPI RangeIntensity : public RangeBase {
399 
400  const static MSDim DIM = MSDim::INT;
401 
402  // Rule of 0!
403  using RangeBase::RangeBase; // inherit C'tors from base
404 
410 
412  void setMinIntensity(const double min)
413  {
414  setMin(min);
415  }
416 
418  void setMaxIntensity(const double max)
419  {
420  setMax(max);
421  }
422 
424  double getMinIntensity() const
425  {
426  return min_;
427  }
428 
430  double getMaxIntensity() const
431  {
432  return max_;
433  }
435 
437  void extendIntensity(const double value)
438  {
439  extend(value);
440  }
441 
443  bool containsIntensity(const double value) const
444  {
445  return RangeBase::contains(value);
446  }
447 
449  bool containsIntensity(const RangeBase& inner_range) const
450  {
451  return RangeBase::contains(inner_range);
452  }
453  };
454  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeIntensity& range);
455 
456  struct OPENMS_DLLAPI RangeMobility : public RangeBase
457  {
458  const static MSDim DIM = MSDim::IM;
459 
460  // Rule of 0!
461  using RangeBase::RangeBase; // inherit C'tors from base
462 
468 
470  void setMinMobility(const double min)
471  {
472  setMin(min);
473  }
474 
476  void setMaxMobility(const double max)
477  {
478  setMax(max);
479  }
480 
482  double getMinMobility() const
483  {
484  return min_;
485  }
486 
488  double getMaxMobility() const
489  {
490  return max_;
491  }
493 
495  void extendMobility(const double value)
496  {
497  extend(value);
498  }
499 
501  bool containsMobility(const double value) const
502  {
503  return RangeBase::contains(value);
504  }
505 
507  bool containsMobility(const RangeBase& inner_range) const
508  {
509  return RangeBase::contains(inner_range);
510  }
511  };
512 
513  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeMobility& range);
514 
516  enum class HasRangeType
517  {
518  ALL,
519  SOME,
520  NONE
521  };
522 
538  template<typename... RangeBases>
539  class RangeManager : public RangeBases...
540  {
541  public:
542  using ThisRangeType = RangeManager<RangeBases...>;
543  // rule of 0 -- no need for a virtual d'tor or anything fancy
544  // ...
545 
546  bool operator==(const RangeManager& rhs) const
547  {
548  bool equal = true;
549  for_each_base_([&](auto* base) {
550  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
551  equal &= ((T_BASE&) rhs == (T_BASE&) *this);
552  });
553  return equal;
554  }
555 
556  bool operator!=(const RangeManager& rhs) const
557  {
558  return !operator==(rhs);
559  }
560 
565  template <typename... RangeBasesOther>
567  {
568  bool found = false;
569  for_each_base_([&](auto* base) {
570  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
571  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
572  {
573  base->operator=((T_BASE&) rhs);
574  found = true;
575  }
576  });
577 
578  return found;
579  }
580 
585  template<typename... RangeBasesOther>
587  {
588  if (!assignUnsafe(rhs))
589  {
590  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION , "No assignment took place (no dimensions in common!);");
591  }
592  return *this;
593  }
594 
599  template<typename... RangeBasesOther>
601  {
602  bool found = false;
603  for_each_base_([&](auto* base) {
604  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
605  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
606  {
607  base->extend((T_BASE&) rhs);
608  found = true;
609  }
610  });
611  return found;
612  }
613 
618  template<typename... RangeBasesOther>
620  {
621  if (!extendUnsafe(rhs))
622  {
623  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
624  }
625  }
626 
628  void scaleBy(const double factor)
629  {
630  for_each_base_([&](auto* base) {
631  base->scaleBy(factor);
632  });
633  }
634 
643  void minSpanIfSingular(const double min_span)
644  {
645  for_each_base_([&](auto* base) {
646  base->minSpanIfSingular(min_span);
647  });
648  }
649 
650 
656  template<typename... RangeBasesOther>
658  {
659  bool found = false;
660  for_each_base_([&](auto* base) {
661  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
662  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
663  {
664  const auto& rhs_base = (T_BASE&)rhs;
665  if (!rhs_base.isEmpty()) base->pushInto(rhs_base);
666  found = true;
667  }
668  });
669  return found;
670  }
671 
677  template<typename... RangeBasesOther>
679  {
680  if (!pushIntoUnsafe(sandbox))
681  {
682  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
683  }
684  }
685 
686 
691  template<typename... RangeBasesOther>
693  {
694  bool found = false;
695  for_each_base_([&](auto* base) {
696  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
697  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
698  {
699  const auto& rhs_base = (T_BASE&)rhs;
700  if (!rhs_base.isEmpty()) base->clampTo(rhs_base);
701  found = true;
702  }
703  });
704  return found;
705  }
706 
712  template<typename... RangeBasesOther>
714  {
715  if (!clampToUnsafe(rhs))
716  {
717  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
718  }
719  }
720 
722  const RangeBase& getRangeForDim(MSDim dim) const
723  {
724  RangeBase* r_base = nullptr;
725 
726  static_for_each_base_([&](auto* base) {
727  using Base = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
728  if (base->DIM == dim)
729  r_base = (Base*)this;
730  });
731 
732  assert((r_base != nullptr) && "No base class has this MSDim!");
733  return *r_base;
734  }
735 
738  {
739  RangeBase* r_base = nullptr;
740 
741  static_for_each_base_([&](auto* base) {
742  using Base = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
743  if (base->DIM == dim)
744  r_base = (Base*) this;
745  });
746 
747  assert((r_base != nullptr) && "No base class has this MSDim!");
748  return *r_base;
749  }
750 
753  {
754  constexpr size_t total{sizeof...(RangeBases)};// total number of bases
755  size_t count{0};
756  for_each_base_([&](auto* base) {
757  count += !base->isEmpty();
758  });
759  switch (count)
760  {
761  case 0:
762  return HasRangeType::NONE;
763  case total:
764  return HasRangeType::ALL;
765  default:
766  return HasRangeType::SOME;
767  }
768  }
769 
774  template<typename... RangeBasesOther>
776  {
777  bool contained = true; // assume rhs is contained, until proven otherwise
778  bool has_overlap = false;
779  for_each_base_([&](auto* base) {
780  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
781  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
782  {
783  has_overlap = true; // at least one dimension overlaps
784  if (((T_BASE&)rhs).isEmpty()) return;
785  if (base->contains((T_BASE&) rhs)) return;
786  contained = false;
787  }
788  });
789  if (!has_overlap) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
790 
791  return contained;
792  }
793 
795  void clearRanges()
796  {
797  for_each_base_([&](auto* base) {
798  base->clear();
799  });
800  }
801 
805  {
806  switch (range)
807  {
808  case DIM_UNIT::RT:
809  if constexpr (std::is_base_of_v<RangeRT, ThisRangeType>) this->RangeRT::clear();
810  break;
811  case DIM_UNIT::MZ:
812  if constexpr (std::is_base_of_v<RangeMZ, ThisRangeType>) this->RangeMZ::clear();
813  break;
814  case DIM_UNIT::INT:
815  if constexpr (std::is_base_of_v<RangeIntensity, ThisRangeType>) this->RangeIntensity::clear();
816  break;
817  // assume all ion mobility ranges are the same and never occur together. If this is violated at some point, then split RangeMobility into subclasses...
818  case DIM_UNIT::IM_MS:
819  case DIM_UNIT::IM_VSSC:
820  case DIM_UNIT::FAIMS_CV:
821  if constexpr (std::is_base_of_v<RangeMobility, ThisRangeType>) this->RangeMobility::clear();
822  break;
823  default:
824  // all cases should be covered above
825  assert(false && "This should never be reached. Did you forget to implement a new DIM_UNIT?");
826  }
827  return *this;
828  }
829 
831  void printRange(std::ostream& out) const
832  {
833  for_each_base_([&](auto* base) {
834  out << *base;
835  });
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>
871  : public RangeManager<RangeBases...>
872  {
873  public:
874  using ThisRangeType = typename RangeManager<RangeBases...>::ThisRangeType;
875 
877  virtual ~RangeManagerContainer() = default; // required since we have virtual methods
878 
881  virtual void updateRanges() = 0;
882 
884  const ThisRangeType& getRange() const
885  {
886  return (ThisRangeType&)*this;
887  }
888 
891  {
892  return (ThisRangeType&)*this;
893  }
894  };
895 
898 
899 } // namespace OpenMS
Invalid range exception.
Definition: Exception.h:252
Definition: RangeManager.h:872
const ThisRangeType & getRange() const
get range of current data (call updateRanges() before to ensure the range is accurate)
Definition: RangeManager.h:884
typename RangeManager< RangeBases... >::ThisRangeType ThisRangeType
Definition: RangeManager.h:874
virtual void updateRanges()=0
ThisRangeType & getRange()
get mutable range, provided for efficiency reasons (avoid updateRanges(), if only minor changes were ...
Definition: RangeManager.h:890
virtual ~RangeManagerContainer()=default
D'tor.
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:540
void pushInto(const RangeManager< RangeBasesOther... > &sandbox)
Definition: RangeManager.h:678
bool assignUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:566
const RangeBase & getRangeForDim(MSDim dim) const
obtain a range dimension at runtime using dim
Definition: RangeManager.h:722
bool pushIntoUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:657
bool clampToUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:692
HasRangeType hasRange() const
is any/some/all dimension in this range populated?
Definition: RangeManager.h:752
RangeBase & getRangeForDim(MSDim dim)
obtain a range dimension at runtime using dim
Definition: RangeManager.h:737
bool operator==(const RangeManager &rhs) const
Definition: RangeManager.h:546
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:804
void clampTo(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:713
void scaleBy(const double factor)
calls RangeBase::scale() for each dimension
Definition: RangeManager.h:628
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:643
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:586
bool extendUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:600
void clearRanges()
Resets all ranges.
Definition: RangeManager.h:795
void printRange(std::ostream &out) const
print each dimension (base classes) to a stream
Definition: RangeManager.h:831
void extend(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:619
bool operator!=(const RangeManager &rhs) const
Definition: RangeManager.h:556
bool containsAll(const RangeManager< RangeBasesOther... > &rhs) const
Definition: RangeManager.h:775
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:62
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
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:24
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:517
@ 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:38
double max_
Definition: RangeManager.h:275
double getSpan() const
Definition: RangeManager.h:250
RangeBase(const RangeBase &rhs)=default
Copy C'tor.
void setMin(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:106
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:265
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:222
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:163
void pushInto(const RangeBase &sandbox)
Definition: RangeManager.h:188
void shift(const double distance)
Definition: RangeManager.h:233
~RangeBase() noexcept=default
D'tor.
bool contains(const double value) const
is value within [min, max]?
Definition: RangeManager.h:88
double center() const
Definition: RangeManager.h:242
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:142
void extendLeftRight(const double by)
Definition: RangeManager.h:151
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:94
void clampTo(const RangeBase &other)
Definition: RangeManager.h:174
double getMin() const
only useful if isEmpty() returns false
Definition: RangeManager.h:122
void clear()
make the range empty, i.e. isEmpty() will be true
Definition: RangeManager.h:76
void setMax(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:114
bool isEmpty() const
is the range empty (i.e. min > max)?
Definition: RangeManager.h:82
double min_
Definition: RangeManager.h:274
RangeBase(const double min, const double max)
Definition: RangeManager.h:45
bool operator==(const RangeBase &rhs) const
Definition: RangeManager.h:256
double getMax() const
only useful if isEmpty() returns false
Definition: RangeManager.h:128
void extend(const RangeBase &other)
ensure the range includes the range of other
Definition: RangeManager.h:135
Definition: RangeManager.h:398
void setMinIntensity(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:412
double getMinIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:424
void extendIntensity(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:437
bool containsIntensity(const double value) const
is value within [min, max]?
Definition: RangeManager.h:443
double getMaxIntensity() const
only useful if isEmpty() returns false
Definition: RangeManager.h:430
bool containsIntensity(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:449
void setMaxIntensity(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:418
Definition: RangeManager.h:340
bool containsMZ(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:391
void setMaxMZ(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:360
void extendMZ(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:379
void setMinMZ(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:354
double getMaxMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:372
double getMinMZ() const
only useful if isEmpty() returns false
Definition: RangeManager.h:366
bool containsMZ(const double value) const
is value within [min, max]?
Definition: RangeManager.h:385
Definition: RangeManager.h:457
bool containsMobility(const double value) const
is value within [min, max]?
Definition: RangeManager.h:501
void extendMobility(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:495
double getMinMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:482
bool containsMobility(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:507
double getMaxMobility() const
only useful if isEmpty() returns false
Definition: RangeManager.h:488
void setMinMobility(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:470
void setMaxMobility(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:476
Definition: RangeManager.h:280
bool containsRT(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:331
void extendRT(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:319
double getMaxRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:312
void setMaxRT(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:300
void setMinRT(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:294
double getMinRT() const
only useful if isEmpty() returns false
Definition: RangeManager.h:306
bool containsRT(const double value) const
is value within [min, max]?
Definition: RangeManager.h:325