OpenMS
2.5.0
|
Registry which assigns unique integer indices to strings. More...
#include <OpenMS/METADATA/MetaInfoRegistry.h>
Public Member Functions | |
MetaInfoRegistry () | |
Default constructor. More... | |
MetaInfoRegistry (const MetaInfoRegistry &rhs) | |
Copy constructor. More... | |
~MetaInfoRegistry () | |
Destructor. More... | |
MetaInfoRegistry & | operator= (const MetaInfoRegistry &rhs) |
Assignment operator. More... | |
UInt | registerName (const String &name, const String &description="", const String &unit="") |
void | setDescription (UInt index, const String &description) |
Sets the description (String), corresponding to an index. More... | |
void | setDescription (const String &name, const String &description) |
Sets the description (String), corresponding to a name. More... | |
void | setUnit (UInt index, const String &unit) |
Sets the unit (String), corresponding to an index. More... | |
void | setUnit (const String &name, const String &unit) |
Sets the unit (String), corresponding to a name. More... | |
UInt | getIndex (const String &name) const |
String | getName (UInt index) const |
Returns the corresponding name to an index. More... | |
String | getDescription (UInt index) const |
returns the description of an index More... | |
String | getDescription (const String &name) const |
returns the description of a name More... | |
String | getUnit (UInt index) const |
returns the unit of an index More... | |
String | getUnit (const String &name) const |
returns the unit of a name More... | |
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 More... | |
MapString2IndexType | name_to_index_ |
map from name to index More... | |
MapIndex2StringType | index_to_name_ |
map from index to name More... | |
MapIndex2StringType | index_to_description_ |
map from index to description More... | |
MapIndex2StringType | index_to_unit_ |
map from index to unit More... | |
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
|
private |
|
private |
MetaInfoRegistry | ( | ) |
Default constructor.
MetaInfoRegistry | ( | const MetaInfoRegistry & | rhs | ) |
Copy constructor.
~MetaInfoRegistry | ( | ) |
Destructor.
returns the description of a name
Exception::InvalidValue | is thrown for unregistered names |
returns the description of an index
Exception::InvalidValue | is thrown for unregistered indices |
Returns the integer index corresponding to a string. If the string is not registered, returns UInt(-1) (= UINT_MAX).
Returns the corresponding name to an index.
Exception::InvalidValue | is thrown for unregistered indices |
returns the unit of a name
Exception::InvalidValue | is thrown for unregistered names |
returns the unit of an index
Exception::InvalidValue | is thrown for unregistered indices |
MetaInfoRegistry& operator= | ( | const MetaInfoRegistry & | rhs | ) |
Assignment operator.
UInt registerName | ( | const String & | name, |
const String & | description = "" , |
||
const 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.
Sets the description (String), corresponding to a name.
Exception::InvalidValue | is thrown for unregistered names |
Sets the description (String), corresponding to an index.
Exception::InvalidValue | is thrown for unregistered indices |
Sets the unit (String), corresponding to a name.
Exception::InvalidValue | is thrown for unregistered names |
Sets the unit (String), corresponding to an index.
Exception::InvalidValue | is thrown for unregistered indices |
|
private |
map from index to description
|
private |
map from index to name
|
private |
map from index to unit
|
private |
map from name to index
|
private |
internal counter, that stores the next index to assign