OpenMS
RangeManager< RangeBases > Class Template Reference

Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra. More...

#include <OpenMS/KERNEL/RangeManager.h>

Inheritance diagram for RangeManager< RangeBases >:
[legend]
Collaboration diagram for RangeManager< RangeBases >:
[legend]

Public Types

using ThisRangeType = RangeManager< RangeBases... >
 

Public Member Functions

bool operator== (const RangeManager &rhs) const
 
bool operator!= (const RangeManager &rhs) const
 
template<typename... RangeBasesOther>
bool assignUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
template<typename... RangeBasesOther>
auto & assign (const RangeManager< RangeBasesOther... > &rhs)
 
template<typename... RangeBasesOther>
bool extendUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
template<typename... RangeBasesOther>
void extend (const RangeManager< RangeBasesOther... > &rhs)
 
void scaleBy (const double factor)
 calls RangeBase::scale() for each dimension More...
 
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 either side. More...
 
template<typename... RangeBasesOther>
bool pushIntoUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
template<typename... RangeBasesOther>
void pushInto (const RangeManager< RangeBasesOther... > &sandbox)
 
template<typename... RangeBasesOther>
bool clampToUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
template<typename... RangeBasesOther>
void clampTo (const RangeManager< RangeBasesOther... > &rhs)
 
const RangeBasegetRangeForDim (MSDim dim) const
 obtain a range dimension at runtime using dim More...
 
RangeBasegetRangeForDim (MSDim dim)
 obtain a range dimension at runtime using dim More...
 
HasRangeType hasRange () const
 is any/some/all dimension in this range populated? More...
 
template<typename... RangeBasesOther>
bool containsAll (const RangeManager< RangeBasesOther... > &rhs) const
 
void clearRanges ()
 Resets all ranges. More...
 
ThisRangeTypeclear (const DIM_UNIT range)
 
void printRange (std::ostream &out) const
 print each dimension (base classes) to a stream More...
 

Protected Member Functions

template<typename Visitor >
void for_each_base_ (Visitor &&visitor)
 use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for each one More...
 
template<typename Visitor >
void for_each_base_ (Visitor &&visitor) const
 .. and a const version More...
 

Static Protected Member Functions

template<typename Visitor >
static void static_for_each_base_ (Visitor &&visitor)
 use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for each one (for static members) More...
 

Detailed Description

template<typename... RangeBases>
class OpenMS::RangeManager< RangeBases >

Handles the management of a multidimensional range, e.g. RangeMZ and RangeIntensity for spectra.

Instantiate it with the dimensions which are supported/required, e.g. RangeManager<RangeRT, RangeMZ> range_spec for a spectrum and use the strongly typed features, such as range_spec.getMaxRT()/setMaxRT(500.0) or range_spec.extend(RangeMZ{100, 1500}).

Use RangeManagerContainer as a base class for all peak and feature containers like MSSpectrum, MSExperiment and FeatureMap.

The implementation uses non-virtual multiple inheritance using variadic templates. Each dimension, e.g. RangeRT, is inherited from, thus all members of the base class become accessible in the RangeManager, e.g. getMaxRT(). Operations (e.g. assignment, or extension of ranges) across RangeManagers with a different, yet overlapping set of base classes is enabled using fold expressions and constexpr evaluations, which are resolved at compile time (see for_each_base_ member function).

Member Typedef Documentation

◆ ThisRangeType

using ThisRangeType = RangeManager<RangeBases...>

Member Function Documentation

◆ assign()

◆ assignUnsafe()

bool assignUnsafe ( const RangeManager< RangeBasesOther... > &  rhs)
inline

copy all overlapping dimensions from rhs to this instance. Dimensions which are not contained in rhs are left untouched.

Parameters
rhsRange to copy from
Returns
true if one or more dimensions overlapped

References RangeManager< RangeBases >::for_each_base_().

Referenced by RangeManager< RangeBases >::assign().

◆ clampTo()

void clampTo ( const RangeManager< RangeBasesOther... > &  rhs)
inline

Clamp min/max of all overlapping dimensions to min/max of rhs. This may tighten the range (even to a single point). Dimensions which are not contained in rhs or where rhs is empty are left untouched.

Parameters
rhsRange to clamp to
Exceptions
Exception::InvalidRangeif no dimensions overlapped

References RangeManager< RangeBases >::clampToUnsafe().

Referenced by RangeManager< RangeBases >::clampToUnsafe().

◆ clampToUnsafe()

bool clampToUnsafe ( const RangeManager< RangeBasesOther... > &  rhs)
inline

Clamp min/max of all overlapping dimensions to min/max of rhs Dimensions which are not contained in rhs or where rhs is empty are left untouched.

Parameters
rhsRange to clamp to
Returns
true if dimensions overlapped, false otherwise

References RangeManager< RangeBases >::clampTo(), and RangeManager< RangeBases >::for_each_base_().

Referenced by RangeManager< RangeBases >::clampTo().

◆ clear()

ThisRangeType& clear ( const DIM_UNIT  range)
inline

Resets the dimension of the given range. Any type of ion mobility in range will clear the RTMobility dimension. If the range is not contained in this class, then nothing happens.

References RangeBase::clear(), OpenMS::FAIMS_CV, OpenMS::IM_MS, OpenMS::IM_VSSC, OpenMS::INT, OpenMS::MZ, and OpenMS::RT.

◆ clearRanges()

void clearRanges ( )
inline

◆ containsAll()

bool containsAll ( const RangeManager< RangeBasesOther... > &  rhs) const
inline

Are all dimensions of rhs (which overlap with this Range) contained in this range? An empty dimension is considered contained in the other dimension (even if that one is empty as well). If only all overlapping dimensions are empty, true is returned.

Exceptions
Exception::InvalidRangeif no dimensions overlap

References RangeManager< RangeBases >::for_each_base_().

◆ extend()

void extend ( const RangeManager< RangeBasesOther... > &  rhs)
inline

extend all dimensions which overlap with rhs to contain the range of rhs Dimensions which are not contained in rhs are left untouched.

Parameters
rhsRange to extend from
Exceptions
Exception::InvalidRangeif no dimensions overlapped

References RangeManager< RangeBases >::extendUnsafe().

Referenced by Plot1DCanvas::recalculateRanges_().

◆ extendUnsafe()

bool extendUnsafe ( const RangeManager< RangeBasesOther... > &  rhs)
inline

extend all dimensions which overlap with rhs to contain the range of rhs Dimensions which are not contained in rhs are left untouched.

Parameters
rhsRange to extend from
Returns
false if no dimensions overlapped

References RangeManager< RangeBases >::for_each_base_().

Referenced by RangeManager< RangeBases >::extend().

◆ for_each_base_() [1/2]

◆ for_each_base_() [2/2]

void for_each_base_ ( Visitor &&  visitor) const
inlineprotected

.. and a const version

◆ getRangeForDim() [1/2]

RangeBase& getRangeForDim ( MSDim  dim)
inline

obtain a range dimension at runtime using dim

References RangeManager< RangeBases >::static_for_each_base_().

◆ getRangeForDim() [2/2]

const RangeBase& getRangeForDim ( MSDim  dim) const
inline

obtain a range dimension at runtime using dim

References RangeManager< RangeBases >::static_for_each_base_().

Referenced by DimRT::map(), DimMZ::map(), DimINT::map(), and DimIM::map().

◆ hasRange()

HasRangeType hasRange ( ) const
inline

is any/some/all dimension in this range populated?

References OpenMS::ALL, RangeManager< RangeBases >::for_each_base_(), OpenMS::NONE, and OpenMS::SOME.

◆ minSpanIfSingular()

void minSpanIfSingular ( const double  min_span)
inline

If any dimension is a single point, e.g. min==max, then extend this dimension by min_span / 2 on either side.

Empty dimensions remain unchanged.

See also
DimBase::minSpanIfSingular

References RangeManager< RangeBases >::for_each_base_().

Referenced by Plot1DCanvas::recalculateRanges_().

◆ operator!=()

bool operator!= ( const RangeManager< RangeBases > &  rhs) const
inline

◆ operator==()

bool operator== ( const RangeManager< RangeBases > &  rhs) const
inline

◆ printRange()

void printRange ( std::ostream &  out) const
inline

print each dimension (base classes) to a stream

References RangeManager< RangeBases >::for_each_base_().

Referenced by OpenMS::operator<<().

◆ pushInto()

void pushInto ( const RangeManager< RangeBasesOther... > &  sandbox)
inline

Move range of *this to min/max of sandbox, without changing the span, if possible. This does tighten the range unless sandbox's ranges are smaller than *this. Dimensions which are not contained in sandbox or are empty are left untouched.

Parameters
sandboxRange to translate/move the current range into
Exceptions
Exception::InvalidRangeif no dimensions overlapped

References RangeManager< RangeBases >::pushIntoUnsafe().

Referenced by Area< N_DIM >::pushInto(), and RangeManager< RangeBases >::pushIntoUnsafe().

◆ pushIntoUnsafe()

bool pushIntoUnsafe ( const RangeManager< RangeBasesOther... > &  rhs)
inline

Move range of *this to min/max of rhs, without changing the span, if possible. This does tighten the range unless rhs's ranges are smaller than *this. Dimensions which are not contained in rhs or are empty are left untouched.

Parameters
rhsRange to translate/move the current range into
Returns
true if dimensions overlapped, false otherwise

References RangeManager< RangeBases >::for_each_base_(), and RangeManager< RangeBases >::pushInto().

Referenced by RangeManager< RangeBases >::pushInto().

◆ scaleBy()

void scaleBy ( const double  factor)
inline

calls RangeBase::scale() for each dimension

References RangeManager< RangeBases >::for_each_base_().

Referenced by Plot1DCanvas::recalculateRanges_().

◆ static_for_each_base_()

static void static_for_each_base_ ( Visitor &&  visitor)
inlinestaticprotected

use fold expression to iterate over all RangeBases of RangeManager and apply a lambda (Visitor) for each one (for static members)

Referenced by RangeManager< RangeBases >::getRangeForDim().