OpenMS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
128  double getMin() const
129  {
130  if (isEmpty())
131  {
132  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Empty or uninitalized range object. Did you forget to call updateRanges()?");
133  }
134  return min_;
135  }
136 
139  double getMax() const
140  {
141  if (isEmpty())
142  {
143  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Empty or uninitialized range object. Did you forget to call updateRanges()?");
144  }
145  return max_;
146  }
148 
150  void extend(const RangeBase& other)
151  {
152  min_ = std::min(min_, other.min_);
153  max_ = std::max(max_, other.max_);
154  }
155 
157  void extend(const double value)
158  {
159  min_ = std::min(min_, value);
160  max_ = std::max(max_, value);
161  }
162 
166  void extendLeftRight(const double by)
167  {
168  if (isEmpty()) return;
169  min_ -= by;
170  max_ += by;
171  }
172 
178  void minSpanIfSingular(const double min_span)
179  {
180  if (min_ == max_) extendLeftRight(min_span / 2);
181  }
182 
189  void clampTo(const RangeBase& other)
190  {
191  if (isEmpty()) return;
192  if (other.isEmpty()) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
193 
194  min_ = std::max(min_, other.min_);
195  max_ = std::min(max_, other.max_);
196  }
197 
203  void pushInto(const RangeBase& sandbox)
204  {
205  if (isEmpty()) return;
206  if (sandbox.isEmpty()) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
207 
208  if (! sandbox.contains(*this))
209  {
210  if (getSpan() > sandbox.getSpan())
211  { // make interval fit into sandbox (= ensure full containment)
212  max_ = min_ + sandbox.getSpan();
213  }
214  if (min_ < sandbox.min_)
215  { // need to shift right (positive shift)
216  shift(sandbox.min_ - min_);
217  }
218  else if (max_ > sandbox.max_)
219  { // need to shift left (negative shift)
220  shift(sandbox.max_ - max_);
221  }
222  }
223  }
224 
235  void scaleBy(const double factor)
236  {
237  if (isEmpty()) return;
238  const double dist = max_ - min_;
239  const double extension = dist * (factor - 1) / 2;
240  min_ -= extension;
241  max_ += extension;
242  }
243 
246  void shift(const double distance)
247  {
248  if (isEmpty()) return;
249  min_ += distance;
250  max_ += distance;
251  }
252 
255  double center() const
256  {
257  if (isEmpty()) return nan("");
258  return min_ + (max_ - min_) / 2.0;
259  }
260 
263  double getSpan() const
264  {
265  if (isEmpty()) return nan("");
266  return max_ - min_;
267  }
268 
269  bool operator==(const RangeBase& rhs) const
270  {
271  return min_ == rhs.min_ && max_ == rhs.max_;
272  }
273 
278  std::pair<double, double> getNonEmptyRange() const
279  {
280  // pair with full range
281  if (isEmpty()) return {std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max()};
282  else
283  return {min_, max_};
284  }
285 
286 protected:
287  // make members non-accessible to maintain invariant: min <= max (unless uninitialized)
288  double min_ = std::numeric_limits<double>::max();
289  double max_ = std::numeric_limits<double>::lowest();
290 };
291 
292 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeBase& b);
293 
294 struct OPENMS_DLLAPI RangeRT : public RangeBase
295 {
296 
297  const static MSDim DIM = MSDim::RT;
298 
299  // Rule of 0!
300  using RangeBase::RangeBase; // inherit C'tors from base
301  using RangeBase::operator=; // inherit assignment operator from base
302 
308 
310  void setMinRT(const double min)
311  {
312  setMin(min);
313  }
314 
316  void setMaxRT(const double max)
317  {
318  setMax(max);
319  }
320 
323  double getMinRT() const
324  {
325  return getMin();
326  }
327 
330  double getMaxRT() const
331  {
332  return getMax();
333  }
335 
337  void extendRT(const double value)
338  {
339  extend(value);
340  }
341 
343  bool containsRT(const double value) const
344  {
345  return RangeBase::contains(value);
346  }
347 
349  bool containsRT(const RangeBase& inner_range) const
350  {
351  return RangeBase::contains(inner_range);
352  }
353 };
354 
355 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeRT& range);
356 
357 struct OPENMS_DLLAPI RangeMZ : public RangeBase
358 {
359 
360  const static MSDim DIM = MSDim::MZ;
361 
362  // Rule of 0!
363  using RangeBase::RangeBase; // inherit C'tors from base
364  using RangeBase::operator=; // inherit assignment operator
365 
371 
373  void setMinMZ(const double min)
374  {
375  setMin(min);
376  }
377 
379  void setMaxMZ(const double max)
380  {
381  setMax(max);
382  }
383 
386  double getMinMZ() const
387  {
388  return getMin();
389  }
390 
393  double getMaxMZ() const
394  {
395  return getMax();
396  }
398 
400  void extendMZ(const double value)
401  {
402  extend(value);
403  }
404 
406  bool containsMZ(const double value) const
407  {
408  return RangeBase::contains(value);
409  }
410 
412  bool containsMZ(const RangeBase& inner_range) const
413  {
414  return RangeBase::contains(inner_range);
415  }
416 };
417 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeMZ& range);
418 
419 struct OPENMS_DLLAPI RangeIntensity : public RangeBase
420 {
421 
422  const static MSDim DIM = MSDim::INT;
423 
424  // Rule of 0!
425  using RangeBase::RangeBase; // inherit C'tors from base
426  using RangeBase::operator=; // inherit assignment operator
427 
433 
435  void setMinIntensity(const double min)
436  {
437  setMin(min);
438  }
439 
441  void setMaxIntensity(const double max)
442  {
443  setMax(max);
444  }
445 
448  double getMinIntensity() const
449  {
450  return getMin();
451  }
452 
455  double getMaxIntensity() const
456  {
457  return getMax();
458  }
460 
462  void extendIntensity(const double value)
463  {
464  extend(value);
465  }
466 
468  bool containsIntensity(const double value) const
469  {
470  return RangeBase::contains(value);
471  }
472 
474  bool containsIntensity(const RangeBase& inner_range) const
475  {
476  return RangeBase::contains(inner_range);
477  }
478 };
479 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeIntensity& range);
480 
481 struct OPENMS_DLLAPI RangeMobility : public RangeBase
482 {
483  const static MSDim DIM = MSDim::IM;
484 
485  // Rule of 0!
486  using RangeBase::RangeBase; // inherit C'tors from base
487  using RangeBase::operator=; // inherit assignment operator
488 
494 
496  void setMinMobility(const double min)
497  {
498  setMin(min);
499  }
500 
502  void setMaxMobility(const double max)
503  {
504  setMax(max);
505  }
506 
509  double getMinMobility() const
510  {
511  return getMin();
512  }
513 
516  double getMaxMobility() const
517  {
518  return getMax();
519  }
521 
523  void extendMobility(const double value)
524  {
525  extend(value);
526  }
527 
529  bool containsMobility(const double value) const
530  {
531  return RangeBase::contains(value);
532  }
533 
535  bool containsMobility(const RangeBase& inner_range) const
536  {
537  return RangeBase::contains(inner_range);
538  }
539 };
540 
541 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& out, const RangeMobility& range);
542 
544 enum class HasRangeType
545 {
546  ALL,
547  SOME,
548  NONE
549 };
550 
566 template<typename... RangeBases>
567 class RangeManager : public RangeBases...
568 {
569 public:
570  using ThisRangeType = RangeManager<RangeBases...>;
571 
572  // rule of 0 -- no need for a virtual d'tor or anything fancy
573  // ...
574 
575  bool operator==(const RangeManager& rhs) const
576  {
577  bool equal = true;
578  for_each_base_([&](auto* base) {
579  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
580  equal &= ((T_BASE&)rhs == (T_BASE&)*this);
581  });
582  return equal;
583  }
584 
585  bool operator!=(const RangeManager& rhs) const
586  {
587  return ! operator==(rhs);
588  }
589 
594  template<typename... RangeBasesOther>
596  {
597  bool found = false;
598  for_each_base_([&](auto* base) {
599  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
600  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
601  {
602  base->operator=((T_BASE&)rhs);
603  found = true;
604  }
605  });
606 
607  return found;
608  }
609 
614  template<typename... RangeBasesOther>
616  {
617  if (! assignUnsafe(rhs))
618  {
619  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
620  }
621  return *this;
622  }
623 
628  template<typename... RangeBasesOther>
630  {
631  bool found = false;
632  for_each_base_([&](auto* base) {
633  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
634  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
635  {
636  base->extend((T_BASE&)rhs);
637  found = true;
638  }
639  });
640  return found;
641  }
642 
647  template<typename... RangeBasesOther>
649  {
650  if (! extendUnsafe(rhs))
651  {
652  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
653  }
654  }
655 
657  void scaleBy(const double factor)
658  {
659  for_each_base_([&](auto* base) { base->scaleBy(factor); });
660  }
661 
670  void minSpanIfSingular(const double min_span)
671  {
672  for_each_base_([&](auto* base) { base->minSpanIfSingular(min_span); });
673  }
674 
675 
681  template<typename... RangeBasesOther>
683  {
684  bool found = false;
685  for_each_base_([&](auto* base) {
686  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
687  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
688  {
689  const auto& rhs_base = (T_BASE&)rhs;
690  if (! rhs_base.isEmpty()) base->pushInto(rhs_base);
691  found = true;
692  }
693  });
694  return found;
695  }
696 
702  template<typename... RangeBasesOther>
704  {
705  if (! pushIntoUnsafe(sandbox))
706  {
707  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
708  }
709  }
710 
711 
716  template<typename... RangeBasesOther>
718  {
719  bool found = false;
720  for_each_base_([&](auto* base) {
721  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
722  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
723  {
724  const auto& rhs_base = (T_BASE&)rhs;
725  if (! rhs_base.isEmpty()) base->clampTo(rhs_base);
726  found = true;
727  }
728  });
729  return found;
730  }
731 
737  template<typename... RangeBasesOther>
739  {
740  if (! clampToUnsafe(rhs))
741  {
742  throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "No assignment took place (no dimensions in common!);");
743  }
744  }
745 
747  const RangeBase& getRangeForDim(MSDim dim) const
748  {
749  RangeBase* r_base = nullptr;
750 
751  static_for_each_base_([&](auto* base) {
752  using Base = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
753  if (base->DIM == dim) r_base = (Base*)this;
754  });
755 
756  assert((r_base != nullptr) && "No base class has this MSDim!");
757  return *r_base;
758  }
759 
762  {
763  RangeBase* r_base = nullptr;
764 
765  static_for_each_base_([&](auto* base) {
766  using Base = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
767  if (base->DIM == dim) r_base = (Base*)this;
768  });
769 
770  assert((r_base != nullptr) && "No base class has this MSDim!");
771  return *r_base;
772  }
773 
776  {
777  constexpr size_t total {sizeof...(RangeBases)}; // total number of bases
778  size_t count {0};
779  for_each_base_([&](auto* base) { count += ! base->isEmpty(); });
780  switch (count)
781  {
782  case 0:
783  return HasRangeType::NONE;
784  case total:
785  return HasRangeType::ALL;
786  default:
787  return HasRangeType::SOME;
788  }
789  }
790 
795  template<typename... RangeBasesOther>
797  {
798  bool contained = true; // assume rhs is contained, until proven otherwise
799  bool has_overlap = false;
800  for_each_base_([&](auto* base) {
801  using T_BASE = std::decay_t<decltype(*base)>; // remove const/ref qualifiers
802  if constexpr (std::is_base_of_v<T_BASE, RangeManager<RangeBasesOther...>>)
803  {
804  has_overlap = true; // at least one dimension overlaps
805  if (((T_BASE&)rhs).isEmpty()) return;
806  if (base->contains((T_BASE&)rhs)) return;
807  contained = false;
808  }
809  });
810  if (! has_overlap) throw Exception::InvalidRange(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
811 
812  return contained;
813  }
814 
816  void clearRanges()
817  {
818  for_each_base_([&](auto* base) { base->clear(); });
819  }
820 
824  {
825  switch (range)
826  {
827  case DIM_UNIT::RT:
828  if constexpr (std::is_base_of_v<RangeRT, ThisRangeType>) this->RangeRT::clear();
829  break;
830  case DIM_UNIT::MZ:
831  if constexpr (std::is_base_of_v<RangeMZ, ThisRangeType>) this->RangeMZ::clear();
832  break;
833  case DIM_UNIT::INT:
834  if constexpr (std::is_base_of_v<RangeIntensity, ThisRangeType>) this->RangeIntensity::clear();
835  break;
836  // assume all ion mobility ranges are the same and never occur together. If this is violated at some point, then split RangeMobility into
837  // subclasses...
838  case DIM_UNIT::IM_MS:
839  case DIM_UNIT::IM_VSSC:
840  case DIM_UNIT::FAIMS_CV:
841  if constexpr (std::is_base_of_v<RangeMobility, ThisRangeType>) this->RangeMobility::clear();
842  break;
843  default:
844  // all cases should be covered above
845  assert(false && "This should never be reached. Did you forget to implement a new DIM_UNIT?");
846  }
847  return *this;
848  }
849 
851  void printRange(std::ostream& out) const
852  {
853  for_each_base_([&](auto* base) { out << *base; });
854  }
855 
856 protected:
858  template<typename Visitor>
859  void for_each_base_(Visitor&& visitor)
860  {
861  (void(visitor(static_cast<RangeBases*>(this))), ...);
862  }
864  template<typename Visitor>
865  void for_each_base_(Visitor&& visitor) const
866  {
867  (void(visitor(static_cast<const RangeBases*>(this))), ...);
868  }
869 
871  template<typename Visitor>
872  static void static_for_each_base_(Visitor&& visitor)
873  {
874  (void(visitor(static_cast<const RangeBases*>(nullptr))), ...);
875  }
876 };
877 
878 template<typename... Range>
879 std::ostream& operator<<(std::ostream& out, const RangeManager<Range...>& me)
880 {
881  me.printRange(out);
882  return out;
883 }
884 
887 template<typename... RangeBases>
888 class RangeManagerContainer : public RangeManager<RangeBases...>
889 {
890 public:
891  using ThisRangeType = typename RangeManager<RangeBases...>::ThisRangeType;
892 
894  virtual ~RangeManagerContainer() = default; // required since we have virtual methods
895 
898  virtual void updateRanges() = 0;
899 
901  const ThisRangeType& getRange() const
902  {
903  return (ThisRangeType&)*this;
904  }
905 
908  {
909  return (ThisRangeType&)*this;
910  }
911 };
912 
915 
916 } // namespace OpenMS
Invalid range exception.
Definition: Exception.h:257
Definition: RangeManager.h:889
const ThisRangeType & getRange() const
get range of current data (call updateRanges() before to ensure the range is accurate)
Definition: RangeManager.h:901
typename RangeManager< RangeBases... >::ThisRangeType ThisRangeType
Definition: RangeManager.h:891
virtual void updateRanges()=0
ThisRangeType & getRange()
get mutable range, provided for efficiency reasons (avoid updateRanges(), if only minor changes were ...
Definition: RangeManager.h:907
virtual ~RangeManagerContainer()=default
D'tor.
Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.
Definition: RangeManager.h:568
void pushInto(const RangeManager< RangeBasesOther... > &sandbox)
Definition: RangeManager.h:703
bool assignUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:595
const RangeBase & getRangeForDim(MSDim dim) const
obtain a range dimension at runtime using dim
Definition: RangeManager.h:747
bool pushIntoUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:682
bool clampToUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:717
HasRangeType hasRange() const
is any/some/all dimension in this range populated?
Definition: RangeManager.h:775
RangeBase & getRangeForDim(MSDim dim)
obtain a range dimension at runtime using dim
Definition: RangeManager.h:761
bool operator==(const RangeManager &rhs) const
Definition: RangeManager.h:575
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:859
void for_each_base_(Visitor &&visitor) const
.. and a const version
Definition: RangeManager.h:865
ThisRangeType & clear(const DIM_UNIT range)
Definition: RangeManager.h:823
void clampTo(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:738
void scaleBy(const double factor)
calls RangeBase::scale() for each dimension
Definition: RangeManager.h:657
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:670
auto & assign(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:615
bool extendUnsafe(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:629
void clearRanges()
Resets all ranges.
Definition: RangeManager.h:816
void printRange(std::ostream &out) const
print each dimension (base classes) to a stream
Definition: RangeManager.h:851
void extend(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:648
bool operator!=(const RangeManager &rhs) const
Definition: RangeManager.h:585
bool containsAll(const RangeManager< RangeBasesOther... > &rhs) const
Definition: RangeManager.h:796
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:872
bool contains(T value, T min, T max)
Is a value contained in [min, max] ?
Definition: MathFunctions.h:64
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:545
@ 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:289
double getSpan() const
Definition: RangeManager.h:263
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:278
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:235
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:178
void pushInto(const RangeBase &sandbox)
Definition: RangeManager.h:203
void shift(const double distance)
Definition: RangeManager.h:246
~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:255
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:157
void extendLeftRight(const double by)
Definition: RangeManager.h:166
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:189
double getMin() const
Definition: RangeManager.h:128
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:288
RangeBase(const double min, const double max)
Definition: RangeManager.h:49
bool operator==(const RangeBase &rhs) const
Definition: RangeManager.h:269
double getMax() const
Definition: RangeManager.h:139
void extend(const RangeBase &other)
ensure the range includes the range of other
Definition: RangeManager.h:150
Definition: RangeManager.h:420
void setMinIntensity(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:435
double getMinIntensity() const
Definition: RangeManager.h:448
void extendIntensity(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:462
bool containsIntensity(const double value) const
is value within [min, max]?
Definition: RangeManager.h:468
double getMaxIntensity() const
Definition: RangeManager.h:455
bool containsIntensity(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:474
void setMaxIntensity(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:441
Definition: RangeManager.h:358
bool containsMZ(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:412
void setMaxMZ(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:379
void extendMZ(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:400
void setMinMZ(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:373
double getMaxMZ() const
Definition: RangeManager.h:393
double getMinMZ() const
Definition: RangeManager.h:386
bool containsMZ(const double value) const
is value within [min, max]?
Definition: RangeManager.h:406
Definition: RangeManager.h:482
bool containsMobility(const double value) const
is value within [min, max]?
Definition: RangeManager.h:529
void extendMobility(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:523
double getMinMobility() const
Definition: RangeManager.h:509
bool containsMobility(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:535
double getMaxMobility() const
Definition: RangeManager.h:516
void setMinMobility(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:496
void setMaxMobility(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:502
Definition: RangeManager.h:295
bool containsRT(const RangeBase &inner_range) const
is the range inner_range within [min, max] of this range?
Definition: RangeManager.h:349
void extendRT(const double value)
extend the range such that it includes the given value
Definition: RangeManager.h:337
double getMaxRT() const
Definition: RangeManager.h:330
void setMaxRT(const double max)
sets the maximum (and the minimum, if uninitialized)
Definition: RangeManager.h:316
void setMinRT(const double min)
sets the minimum (and the maximum, if uninitialized)
Definition: RangeManager.h:310
double getMinRT() const
Definition: RangeManager.h:323
bool containsRT(const double value) const
is value within [min, max]?
Definition: RangeManager.h:343