OpenMS
2.7.0
|
A Type-Name-Value tuple class. More...
#include <OpenMS/METADATA/MetaInfo.h>
Public Member Functions | |
MetaInfo ()=default | |
Constructor. More... | |
MetaInfo (const MetaInfo &)=default | |
Copy constructor. More... | |
MetaInfo (MetaInfo &&)=default | |
Move constructor. More... | |
~MetaInfo () | |
Destructor. More... | |
MetaInfo & | operator= (const MetaInfo &)=default |
Assignment operator. More... | |
MetaInfo & | operator= (MetaInfo &&) &=default |
Move assignment operator. More... | |
bool | operator== (const MetaInfo &rhs) const |
Equality operator. More... | |
bool | operator!= (const MetaInfo &rhs) const |
Equality operator. More... | |
const DataValue & | getValue (const String &name, const DataValue &default_value=DataValue::EMPTY) const |
Returns the value corresponding to a string, or a default value (default: DataValue::EMPTY) if not found. More... | |
const DataValue & | getValue (UInt index, const DataValue &default_value=DataValue::EMPTY) const |
Returns the value corresponding to an index, or a default value (default: DataValue::EMPTY) if not found. More... | |
bool | exists (const String &name) const |
Returns whether an entry with the given name exists. More... | |
bool | exists (UInt index) const |
Returns whether an entry with the given index exists. More... | |
void | setValue (const String &name, const DataValue &value) |
Sets the DataValue corresponding to a name. More... | |
void | setValue (UInt index, const DataValue &value) |
Sets the DataValue corresponding to an index. More... | |
void | removeValue (const String &name) |
Removes the DataValue corresponding to name if it exists. More... | |
void | removeValue (UInt index) |
Removes the DataValue corresponding to index if it exists. More... | |
void | getKeys (std::vector< String > &keys) const |
Fills the given vector with a list of all keys for which a value is set. More... | |
void | getKeys (std::vector< UInt > &keys) const |
Fills the given vector with a list of all keys for which a value is set. More... | |
bool | empty () const |
Returns if the MetaInfo is empty. More... | |
void | clear () |
Removes all meta values. More... | |
Static Public Member Functions | |
static MetaInfoRegistry & | registry () |
Returns a reference to the MetaInfoRegistry. More... | |
Private Types | |
using | MapType = boost::container::flat_map< UInt, DataValue > |
Private Attributes | |
MapType | index_to_value_ |
The actual mapping of indexes to values. More... | |
Static Private Attributes | |
static MetaInfoRegistry | registry_ |
Static MetaInfoRegistry. More... | |
A Type-Name-Value tuple class.
MetaInfo maps an index (an integer corresponding to a string) to DataValue objects. The mapping of strings to the index is performed by the MetaInfoRegistry, which can be accessed by the method registry().
There are two versions of nearly all members. One which operates with a string name and another one which operates on an index. The index version is always faster, as it does not need to look up the index corresponding to the string in the MetaInfoRegistry.
If you wish to add a MetaInfo member to a class, consider deriving that class from MetaInfoInterface, instead of simply adding MetaInfo as member. MetaInfoInterface implements a full interface to a MetaInfo member and is more memory efficient if no meta info gets added.
|
default |
Constructor.
~MetaInfo | ( | ) |
Destructor.
void clear | ( | ) |
Removes all meta values.
bool empty | ( | ) | const |
Returns if the MetaInfo is empty.
bool exists | ( | const String & | name | ) | const |
Returns whether an entry with the given name exists.
bool exists | ( | UInt | index | ) | const |
Returns whether an entry with the given index exists.
void getKeys | ( | std::vector< String > & | keys | ) | const |
Fills the given vector with a list of all keys for which a value is set.
void getKeys | ( | std::vector< UInt > & | keys | ) | const |
Fills the given vector with a list of all keys for which a value is set.
const DataValue& getValue | ( | const String & | name, |
const DataValue & | default_value = DataValue::EMPTY |
||
) | const |
Returns the value corresponding to a string, or a default value (default: DataValue::EMPTY) if not found.
const DataValue& getValue | ( | UInt | index, |
const DataValue & | default_value = DataValue::EMPTY |
||
) | const |
Returns the value corresponding to an index, or a default value (default: DataValue::EMPTY) if not found.
bool operator!= | ( | const MetaInfo & | rhs | ) | const |
Equality operator.
bool operator== | ( | const MetaInfo & | rhs | ) | const |
Equality operator.
|
static |
Returns a reference to the MetaInfoRegistry.
Sets the DataValue corresponding to a name.
|
private |
The actual mapping of indexes to values.
|
staticprivate |
Static MetaInfoRegistry.