OpenMS
Loading...
Searching...
No Matches
MetaInfoRegistry.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Hendrik Weisser $
6// $Authors: Marc Sturm $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <map>
12#include <string>
13
17
18#include <unordered_map>
19
20#ifdef OPENMS_COMPILER_MSVC
21#pragma warning( push )
22#pragma warning( disable : 4251 ) // disable MSVC dll-interface warning
23#endif
24
25namespace OpenMS
26{
27
49 class OPENMS_DLLAPI MetaInfoRegistry
50 {
51public:
54
57
60
63
68 UInt registerName(const std::string& name, const std::string& description = "", const std::string& unit = "");
69
75 void setDescription(UInt index, const std::string& description);
76
82 void setDescription(const std::string& name, const std::string& description);
83
89 void setUnit(UInt index, const std::string& unit);
90
96 void setUnit(const std::string& name, const std::string& unit);
97
102 UInt getIndex(const std::string& name) const;
103
109 std::string getName(UInt index) const;
110
116 std::string getDescription(UInt index) const;
122 std::string getDescription(const std::string& name) const;
123
129 std::string getUnit(UInt index) const;
135 std::string getUnit(const std::string& name) const;
136
137private:
140 using MapString2IndexType = std::unordered_map<std::string, UInt>;
141 using MapIndex2StringType = std::unordered_map<UInt, std::string>;
142
151 };
152
153} // namespace OpenMS
154
155#ifdef OPENMS_COMPILER_MSVC
156#pragma warning( pop )
157#endif
158
Registry which assigns unique integer indices to strings.
Definition MetaInfoRegistry.h:50
UInt next_index_
internal counter, that stores the next index to assign
Definition MetaInfoRegistry.h:139
void setUnit(const std::string &name, const std::string &unit)
Sets the unit (String), corresponding to a name.
MetaInfoRegistry & operator=(const MetaInfoRegistry &rhs)
Assignment operator.
MapIndex2StringType index_to_unit_
map from index to unit
Definition MetaInfoRegistry.h:150
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.
UInt getIndex(const std::string &name) const
MapString2IndexType name_to_index_
map from name to index
Definition MetaInfoRegistry.h:144
std::unordered_map< std::string, UInt > MapString2IndexType
Definition MetaInfoRegistry.h:140
MapIndex2StringType index_to_description_
map from index to description
Definition MetaInfoRegistry.h:148
std::string getName(UInt index) const
Returns the corresponding name to an index.
std::string getUnit(UInt index) const
returns the unit of an index
~MetaInfoRegistry()
Destructor.
std::unordered_map< UInt, std::string > MapIndex2StringType
Definition MetaInfoRegistry.h:141
void setDescription(const std::string &name, const std::string &description)
Sets the description (String), corresponding to a name.
MapIndex2StringType index_to_name_
map from index to name
Definition MetaInfoRegistry.h:146
std::string getUnit(const std::string &name) const
returns the unit of a name
MetaInfoRegistry(const MetaInfoRegistry &rhs)
Copy constructor.
std::string getDescription(const std::string &name) const
returns the description of a name
std::string getDescription(UInt index) const
returns the description of an index
MetaInfoRegistry()
Default constructor.
void setUnit(UInt index, const std::string &unit)
Sets the unit (String), corresponding to an index.
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19