OpenMS
Loading...
Searching...
No Matches
CVTermList.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: Mathias Walzer $
6// $Authors: Andreas Bertsch, Mathias Walzer $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14#include <map>
15
16namespace OpenMS
17{
27 class OPENMS_DLLAPI CVTermList :
29 {
30public:
31
33 CVTermList() = default;
34
36 CVTermList(const CVTermList&) = default;
37
38 // note: we implement the move constructor ourselves due to a bug in MSVS
39 // 2015/2017 which cannot produce a default move constructor for classes
40 // that contain STL containers (other than vector).
41
44
46 virtual ~CVTermList();
47
49 CVTermList& operator=(const CVTermList& rhs) & = default;
50
52 CVTermList& operator=(CVTermList&&) & = default;
53
58 void setCVTerms(const std::vector<CVTerm>& terms);
59
61 void replaceCVTerm(const CVTerm& cv_term);
62
64 void replaceCVTerms(const std::vector<CVTerm>& cv_terms, const String& accession);
65
67 void replaceCVTerms(const std::map<String, std::vector<CVTerm> >& cv_term_map);
68
70 void consumeCVTerms(const std::map<String, std::vector<CVTerm> >& cv_term_map);
71
73 const std::map<String, std::vector<CVTerm> >& getCVTerms() const;
74
76 void addCVTerm(const CVTerm& term);
77
79 //bool checkCVTerms(const ControlledVocabulary& cv) const;
80
82 //void correctCVTermNames();
84
89 bool operator==(const CVTermList& cv_term_list) const;
90
92 bool operator!=(const CVTermList& cv_term_list) const;
93
95 bool hasCVTerm(const String& accession) const;
96
99 //bool checkCVTerms(const CVMappingRule & rule, const ControlledVocabulary & cv) const;
100
102 bool empty() const;
103 //}
104
105protected:
106
107 std::map<String, std::vector<CVTerm> > cv_terms_;
108
109 };
110
111} // namespace OpenMS
112
113// Hash function specialization for CVTermList
114namespace std
115{
126 template<>
127 struct hash<OpenMS::CVTermList>
128 {
129 std::size_t operator()(const OpenMS::CVTermList& list) const noexcept
130 {
131 // Start with MetaInfoInterface base class hash
132 std::size_t seed = std::hash<OpenMS::MetaInfoInterface>{}(list);
133
134 // Hash all CV terms
135 for (const auto& entry : list.getCVTerms())
136 {
137 // Hash the accession string
139 // Hash each CV term in the vector
140 for (const auto& term : entry.second)
141 {
142 OpenMS::hash_combine(seed, std::hash<OpenMS::CVTerm>{}(term));
143 }
144 }
145 return seed;
146 }
147 };
148} // namespace std
149
Representation of controlled vocabulary term list.
Definition CVTermList.h:29
CVTermList()=default
Defaults constructor.
CVTermList(const CVTermList &)=default
Copy constructor.
CVTermList(CVTermList &&) noexcept
Move constructor.
Representation of controlled vocabulary term.
Definition CVTerm.h:28
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition MetaInfoInterface.h:36
A more convenient string class.
Definition String.h:34
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t fnv1a_hash_string(const std::string &s) noexcept
FNV-1a hash for a string.
Definition HashUtils.h:70
STL namespace.
std::size_t operator()(const OpenMS::CVTermList &list) const noexcept
Definition CVTermList.h:129