OpenMS
Loading...
Searching...
No Matches
MetaInfoRegistry Class Reference

Registry which assigns unique integer indices to strings. More...

#include <OpenMS/METADATA/MetaInfoRegistry.h>

Collaboration diagram for MetaInfoRegistry:
[legend]

Public Member Functions

 MetaInfoRegistry ()
 Default constructor.
 
 MetaInfoRegistry (const MetaInfoRegistry &rhs)
 Copy constructor.
 
 ~MetaInfoRegistry ()
 Destructor.
 
MetaInfoRegistryoperator= (const MetaInfoRegistry &rhs)
 Assignment operator.
 
UInt registerName (const std::string &name, const std::string &description="", const std::string &unit="")
 
void setDescription (UInt index, const std::string &description)
 Sets the description (String), corresponding to an index.
 
void setDescription (const std::string &name, const std::string &description)
 Sets the description (String), corresponding to a name.
 
void setUnit (UInt index, const std::string &unit)
 Sets the unit (String), corresponding to an index.
 
void setUnit (const std::string &name, const std::string &unit)
 Sets the unit (String), corresponding to a name.
 
UInt getIndex (const std::string &name) const
 
std::string getName (UInt index) const
 Returns the corresponding name to an index.
 
std::string getDescription (UInt index) const
 returns the description of an index
 
std::string getDescription (const std::string &name) const
 returns the description of a name
 
std::string getUnit (UInt index) const
 returns the unit of an index
 
std::string getUnit (const std::string &name) const
 returns the unit of a name
 

Private Types

using MapString2IndexType = std::unordered_map< std::string, UInt >
 
using MapIndex2StringType = std::unordered_map< UInt, std::string >
 

Private Attributes

UInt next_index_
 internal counter, that stores the next index to assign
 
MapString2IndexType name_to_index_
 map from name to index
 
MapIndex2StringType index_to_name_
 map from index to name
 
MapIndex2StringType index_to_description_
 map from index to description
 
MapIndex2StringType index_to_unit_
 map from index to unit
 

Detailed Description

Registry which assigns unique integer indices to strings.

When registering a new name an index >= 1024 is assigned. Indices from 1 to 1023 are reserved for fast access and will never change:
1 - isotopic_range
2 - cluster_id
3 - label
4 - icon
5 - color
6 - RT
7 - MZ
8 - predicted_RT
9 - predicted_RT_p_value
10 - spectrum_reference
11 - ID
12 - low_quality
13 - charge

Member Typedef Documentation

◆ MapIndex2StringType

using MapIndex2StringType = std::unordered_map<UInt, std::string>
private

◆ MapString2IndexType

using MapString2IndexType = std::unordered_map<std::string, UInt>
private

Constructor & Destructor Documentation

◆ MetaInfoRegistry() [1/2]

Default constructor.

◆ MetaInfoRegistry() [2/2]

Copy constructor.

◆ ~MetaInfoRegistry()

Destructor.

Member Function Documentation

◆ getDescription() [1/2]

std::string getDescription ( const std::string &  name) const

returns the description of a name

Exceptions
Exception::InvalidValueis thrown for unregistered names

◆ getDescription() [2/2]

std::string getDescription ( UInt  index) const

returns the description of an index

Exceptions
Exception::InvalidValueis thrown for unregistered indices

◆ getIndex()

UInt getIndex ( const std::string &  name) const

Returns the integer index corresponding to a string. If the string is not registered, returns UInt(-1) (= UINT_MAX).

◆ getName()

std::string getName ( UInt  index) const

Returns the corresponding name to an index.

Exceptions
Exception::InvalidValueis thrown for unregistered indices

◆ getUnit() [1/2]

std::string getUnit ( const std::string &  name) const

returns the unit of a name

Exceptions
Exception::InvalidValueis thrown for unregistered names

◆ getUnit() [2/2]

std::string getUnit ( UInt  index) const

returns the unit of an index

Exceptions
Exception::InvalidValueis thrown for unregistered indices

◆ operator=()

MetaInfoRegistry & operator= ( const MetaInfoRegistry rhs)

Assignment operator.

◆ registerName()

UInt registerName ( const std::string &  name,
const std::string &  description = "",
const std::string &  unit = "" 
)

Registers a string, stores its description and unit, and returns the corresponding index. If the string is already registered, it returns the index of the string.

Referenced by OpenMS::MRMTransitionGroupPickerMeta::areaBackgroundLevel(), OpenMS::MRMTransitionGroupPickerMeta::asymmetryFactor(), OpenMS::MRMTransitionGroupPickerMeta::baselineDelta2Height(), OpenMS::MRMTransitionGroupPickerMeta::endPositionAt10(), OpenMS::MRMTransitionGroupPickerMeta::endPositionAt5(), OpenMS::MRMTransitionGroupPickerMeta::endPositionAt50(), OpenMS::MRMTransitionGroupPickerMeta::initialPeakQuality(), OpenMS::MRMTransitionGroupPickerMeta::leftWidth(), OpenMS::MRMTransitionGroupPickerMeta::nativeID(), OpenMS::MRMTransitionGroupPickerMeta::noiseBackgroundLevel(), OpenMS::MRMTransitionGroupPickerMeta::peakApexInt(), OpenMS::MRMTransitionGroupPickerMeta::peakApexPosition(), OpenMS::MRMTransitionGroupPickerMeta::peakApicesSum(), OpenMS::MRMTransitionGroupPickerMeta::peptideRef(), OpenMS::MRMTransitionGroupPickerMeta::pointsAcrossBaseline(), OpenMS::MRMTransitionGroupPickerMeta::pointsAcrossHalfHeight(), OpenMS::MRMTransitionGroupPickerMeta::potentialOutlier(), OpenMS::MRMTransitionGroupPickerMeta::rightWidth(), OpenMS::MRMTransitionGroupPickerMeta::slopeOfBaseline(), OpenMS::MRMTransitionGroupPickerMeta::startPositionAt10(), OpenMS::MRMTransitionGroupPickerMeta::startPositionAt5(), OpenMS::MRMTransitionGroupPickerMeta::startPositionAt50(), OpenMS::MRMTransitionGroupPickerMeta::tailingFactor(), OpenMS::MRMTransitionGroupPickerMeta::totalMI(), OpenMS::MRMTransitionGroupPickerMeta::totalWidth(), OpenMS::MRMTransitionGroupPickerMeta::totalXIC(), OpenMS::MRMTransitionGroupPickerMeta::widthAt10(), OpenMS::MRMTransitionGroupPickerMeta::widthAt5(), and OpenMS::MRMTransitionGroupPickerMeta::widthAt50().

◆ setDescription() [1/2]

void setDescription ( const std::string &  name,
const std::string &  description 
)

Sets the description (String), corresponding to a name.

Exceptions
Exception::InvalidValueis thrown for unregistered names

◆ setDescription() [2/2]

void setDescription ( UInt  index,
const std::string &  description 
)

Sets the description (String), corresponding to an index.

Exceptions
Exception::InvalidValueis thrown for unregistered indices

◆ setUnit() [1/2]

void setUnit ( const std::string &  name,
const std::string &  unit 
)

Sets the unit (String), corresponding to a name.

Exceptions
Exception::InvalidValueis thrown for unregistered names

◆ setUnit() [2/2]

void setUnit ( UInt  index,
const std::string &  unit 
)

Sets the unit (String), corresponding to an index.

Exceptions
Exception::InvalidValueis thrown for unregistered indices

Member Data Documentation

◆ index_to_description_

MapIndex2StringType index_to_description_
private

map from index to description

◆ index_to_name_

MapIndex2StringType index_to_name_
private

map from index to name

◆ index_to_unit_

MapIndex2StringType index_to_unit_
private

map from index to unit

◆ name_to_index_

MapString2IndexType name_to_index_
private

map from name to index

◆ next_index_

UInt next_index_
private

internal counter, that stores the next index to assign