OpenMS
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 
15 #include <OpenMS/CONCEPT/Types.h>
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 
25 namespace OpenMS
26 {
27 
49  class OPENMS_DLLAPI MetaInfoRegistry
50  {
51 public:
54 
57 
60 
63 
68  UInt registerName(const String& name, const String& description = "", const String& unit = "");
69 
75  void setDescription(UInt index, const String& description);
76 
82  void setDescription(const String& name, const String& description);
83 
89  void setUnit(UInt index, const String& unit);
90 
96  void setUnit(const String& name, const String& unit);
97 
102  UInt getIndex(const String& name) const;
103 
109  String getName(UInt index) const;
110 
116  String getDescription(UInt index) const;
122  String getDescription(const String& name) const;
123 
129  String getUnit(UInt index) const;
135  String getUnit(const String& name) const;
136 
137 private:
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
String getDescription(UInt index) const
returns the description of an index
UInt next_index_
internal counter, that stores the next index to assign
Definition: MetaInfoRegistry.h:139
MapIndex2StringType index_to_unit_
map from index to unit
Definition: MetaInfoRegistry.h:150
String getUnit(UInt index) const
returns the unit of an index
UInt getIndex(const String &name) const
String getDescription(const String &name) const
returns the description of a name
void setUnit(UInt index, const String &unit)
Sets the unit (String), corresponding to an index.
String getUnit(const String &name) const
returns the unit of a name
String getName(UInt index) const
Returns the corresponding name to an index.
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
void setDescription(const String &name, const String &description)
Sets the description (String), corresponding to a name.
UInt registerName(const String &name, const String &description="", const String &unit="")
void setUnit(const String &name, const String &unit)
Sets the unit (String), corresponding to a name.
~MetaInfoRegistry()
Destructor.
std::unordered_map< UInt, std::string > MapIndex2StringType
Definition: MetaInfoRegistry.h:141
void setDescription(UInt index, const String &description)
Sets the description (String), corresponding to an index.
MapIndex2StringType index_to_name_
map from index to name
Definition: MetaInfoRegistry.h:146
MetaInfoRegistry(const MetaInfoRegistry &rhs)
Copy constructor.
MetaInfoRegistry & operator=(const MetaInfoRegistry &rhs)
Assignment operator.
MetaInfoRegistry()
Default constructor.
A more convenient string class.
Definition: String.h:34
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19