OpenMS  2.8.0
Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
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 Member Functions

bool operator== (const RangeManager &rhs) const
 
template<typename... RangeBasesOther>
bool assignUnsafe (const RangeManager< RangeBasesOther... > &rhs)
 
template<typename... RangeBasesOther>
void 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...
 
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...
 
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.

Instanciate 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 Function Documentation

◆ assign()

void assign ( 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
Exceptions
Exception::InvalidRangeif no dimensions overlapped

References RangeManager< RangeBases >::assignUnsafe().

Referenced by LayerDataChrom::getRange(), LayerDataConsensus::getRange(), LayerDataFeature::getRange(), and LayerDataPeak::getRange().

◆ 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().

◆ clearRanges()

void clearRanges ( )
inline

Resets all ranges.

References RangeManager< RangeBases >::for_each_base_().

◆ 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().

◆ 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]

void for_each_base_ ( Visitor &&  visitor)
inlineprotected

◆ for_each_base_() [2/2]

void for_each_base_ ( Visitor &&  visitor) const
inlineprotected

.. and a const version

◆ getRangeForDim()

RangeBase& getRangeForDim ( MSDim  dim)
inline

obtain a range dimension at runtime using dim

References RangeManager< RangeBases >::static_for_each_base_().

◆ 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.

◆ 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<<().

◆ scaleBy()

void scaleBy ( const double  factor)
inline

calls RangeBase::scale() for each dimension

References RangeManager< RangeBases >::for_each_base_().

◆ 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().