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

Interface for classes that can store arbitrary meta information (Type-Name-Value tuples). More...

#include <OpenMS/METADATA/MetaInfoInterface.h>

Inheritance diagram for MetaInfoInterface:
[legend]
Collaboration diagram for MetaInfoInterface:
[legend]

Public Types

using MetaInfoConstIterator = MetaInfo::const_iterator
 Const iterator type for iterating over meta info entries.
 

Public Member Functions

 MetaInfoInterface ()=default
 Constructor.
 
 MetaInfoInterface (const MetaInfoInterface &rhs)
 Copy constructor.
 
 MetaInfoInterface (MetaInfoInterface &&) noexcept
 Move constructor.
 
 ~MetaInfoInterface ()
 Destructor.
 
MetaInfoInterfaceoperator= (const MetaInfoInterface &rhs)
 Assignment operator.
 
MetaInfoInterfaceoperator= (MetaInfoInterface &&) noexcept
 Move assignment operator.
 
void swap (MetaInfoInterface &rhs)
 Swap contents.
 
bool operator== (const MetaInfoInterface &rhs) const
 Equality operator.
 
bool operator!= (const MetaInfoInterface &rhs) const
 Equality operator.
 
const DataValuegetMetaValue (const String &name) const
 Returns the value corresponding to a string, or DataValue::EMPTY if not found.
 
DataValue getMetaValue (const String &name, const DataValue &default_value) const
 Returns the value corresponding to a string, or a default value (e.g.: DataValue::EMPTY) if not found

 
const DataValuegetMetaValue (UInt index) const
 Returns the value corresponding to the index, or DataValue::EMPTY if not found.
 
DataValue getMetaValue (UInt index, const DataValue &default_value) const
 Returns the value corresponding to the index, or a default value (e.g.: DataValue::EMPTY) if not found

 
bool metaValueExists (const String &name) const
 Returns whether an entry with the given name exists.
 
bool metaValueExists (UInt index) const
 Returns whether an entry with the given index exists.
 
void setMetaValue (const String &name, const DataValue &value)
 Sets the DataValue corresponding to a name.
 
void setMetaValue (UInt index, const DataValue &value)
 Sets the DataValue corresponding to an index.
 
void removeMetaValue (const String &name)
 Removes the DataValue corresponding to name if it exists.
 
void removeMetaValue (UInt index)
 Removes the DataValue corresponding to index if it exists.
 
void addMetaValues (const MetaInfoInterface &from)
 
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.
 
bool isMetaEmpty () const
 Returns if the MetaInfo is empty.
 
void clearMetaInfo ()
 Removes all meta values.
 
Iterator access for meta info

Provides read-only iterator access to the underlying meta info entries. Iterators dereference to std::pair<UInt, DataValue> where the first element is the registry index and the second is the associated value. If no meta info exists (null internal pointer), an empty range is returned.

MetaInfoConstIterator metaBegin () const
 Returns a const iterator to the beginning of the meta info entries.
 
MetaInfoConstIterator metaEnd () const
 Returns a const iterator to the end of the meta info entries.
 
Size metaSize () const
 Returns the number of meta info entries.
 

Static Public Member Functions

static MetaInfoRegistrymetaRegistry ()
 Returns a reference to the MetaInfoRegistry.
 

Protected Member Functions

void createIfNotExists_ ()
 Creates the MetaInfo object if it does not exist.
 

Protected Attributes

MetaInfometa_ = nullptr
 Pointer to the MetaInfo object.
 

Detailed Description

Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).

MetaInfoInterface is a base class for all classes that use one MetaInfo object as member. If you want to add meta information to a class, let it publicly inherit the MetaInfoInterface. Meta information is an array of Type-Name-Value tuples.

Member Typedef Documentation

◆ MetaInfoConstIterator

Const iterator type for iterating over meta info entries.

Dereferences to std::pair<UInt, DataValue> where the first element is the registry index and the second is the associated DataValue.

Constructor & Destructor Documentation

◆ MetaInfoInterface() [1/3]

MetaInfoInterface ( )
default

Constructor.

◆ MetaInfoInterface() [2/3]

Copy constructor.

◆ MetaInfoInterface() [3/3]

Move constructor.

◆ ~MetaInfoInterface()

Destructor.

Member Function Documentation

◆ addMetaValues()

void addMetaValues ( const MetaInfoInterface from)

Copy all meta values from from to this object (both named String and indexed UInt keys). Existing entries with the same key are overwritten; others are preserved.

Referenced by Observation::merge(), and ScoredProcessingResult::merge().

◆ clearMetaInfo()

void clearMetaInfo ( )

Removes all meta values.

◆ createIfNotExists_()

void createIfNotExists_ ( )
inlineprotected

Creates the MetaInfo object if it does not exist.

◆ getKeys() [1/2]

void getKeys ( std::vector< String > &  keys) const

Fills the given vector with a list of all keys for which a value is set.

◆ getKeys() [2/2]

void getKeys ( std::vector< UInt > &  keys) const

Fills the given vector with a list of all keys for which a value is set.

◆ getMetaValue() [1/4]

◆ getMetaValue() [2/4]

DataValue getMetaValue ( const String name,
const DataValue default_value 
) const

Returns the value corresponding to a string, or a default value (e.g.: DataValue::EMPTY) if not found

◆ getMetaValue() [3/4]

const DataValue & getMetaValue ( UInt  index) const

Returns the value corresponding to the index, or DataValue::EMPTY if not found.

◆ getMetaValue() [4/4]

DataValue getMetaValue ( UInt  index,
const DataValue default_value 
) const

Returns the value corresponding to the index, or a default value (e.g.: DataValue::EMPTY) if not found

◆ isMetaEmpty()

bool isMetaEmpty ( ) const

Returns if the MetaInfo is empty.

◆ metaBegin()

MetaInfoConstIterator metaBegin ( ) const

Returns a const iterator to the beginning of the meta info entries.

If no meta info exists (object was never assigned any meta values), returns an iterator equal to metaEnd() (empty range).

Returns
MetaInfoConstIterator pointing to the first index-value pair.

◆ metaEnd()

MetaInfoConstIterator metaEnd ( ) const

Returns a const iterator to the end of the meta info entries.

Returns
MetaInfoConstIterator pointing past the last index-value pair.

◆ metaRegistry()

static MetaInfoRegistry & metaRegistry ( )
static

Returns a reference to the MetaInfoRegistry.

◆ metaSize()

Size metaSize ( ) const

Returns the number of meta info entries.

Returns
The count of meta value entries, or 0 if no meta info exists.

◆ metaValueExists() [1/2]

◆ metaValueExists() [2/2]

bool metaValueExists ( UInt  index) const

Returns whether an entry with the given index exists.

◆ operator!=()

bool operator!= ( const MetaInfoInterface rhs) const

Equality operator.

◆ operator=() [1/2]

MetaInfoInterface & operator= ( const MetaInfoInterface rhs)

Assignment operator.

◆ operator=() [2/2]

MetaInfoInterface & operator= ( MetaInfoInterface &&  )
noexcept

Move assignment operator.

◆ operator==()

bool operator== ( const MetaInfoInterface rhs) const

Equality operator.

◆ removeMetaValue() [1/2]

void removeMetaValue ( const String name)

Removes the DataValue corresponding to name if it exists.

Referenced by MascotGenericFile::getNextSpectrum_().

◆ removeMetaValue() [2/2]

void removeMetaValue ( UInt  index)

Removes the DataValue corresponding to index if it exists.

◆ setMetaValue() [1/2]

◆ setMetaValue() [2/2]

void setMetaValue ( UInt  index,
const DataValue value 
)

Sets the DataValue corresponding to an index.

◆ swap()

void swap ( MetaInfoInterface rhs)

Swap contents.

Referenced by LinearResampler::raster().

Member Data Documentation

◆ meta_

MetaInfo* meta_ = nullptr
protected

Pointer to the MetaInfo object.