OpenMS
Loading...
Searching...
No Matches
CVTermListInterface.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: Hannes Roest $
6// $Authors: Hannes Roest $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14#include <map>
15
16namespace OpenMS
17{
18
19 class CVTermList;
20
32 class OPENMS_DLLAPI CVTermListInterface :
34 {
35
36 public:
37
41 // Constructor
47 // Destructor (non virtual)
49
51 CVTermListInterface & operator=(const CVTermListInterface & rhs);
55
57 bool operator==(const CVTermListInterface& rhs) const;
58
60 bool operator!=(const CVTermListInterface& rhs) const;
61
62 void replaceCVTerms(std::map<String, std::vector<CVTerm> > & cv_terms);
63
65 void setCVTerms(const std::vector<CVTerm>& terms);
66
68 void replaceCVTerm(const CVTerm& cv_term);
69
71 void replaceCVTerms(const std::vector<CVTerm>& cv_terms, const String& accession);
72
74 void replaceCVTerms(const std::map<String, std::vector<CVTerm> >& cv_term_map);
75
77 void consumeCVTerms(const std::map<String, std::vector<CVTerm> >& cv_term_map);
78
80 const std::map<String, std::vector<CVTerm> >& getCVTerms() const;
81
83 void addCVTerm(const CVTerm& term);
84
86 bool hasCVTerm(const String& accession) const;
87
88 bool empty() const;
89
90 private:
91
92 void createIfNotExists_();
93
94 CVTermList* cvt_ptr_;
95 };
96
97} // namespace OpenMS
98
99// Hash function specialization for CVTermListInterface
100namespace std
101{
108 template<>
109 struct hash<OpenMS::CVTermListInterface>
110 {
111 std::size_t operator()(const OpenMS::CVTermListInterface& iface) const noexcept
112 {
113 std::size_t seed = 0;
114 for (const auto& entry : iface.getCVTerms())
115 {
116 // Hash the accession string
118 // Hash each CV term in the vector
119 for (const auto& term : entry.second)
120 {
121 OpenMS::hash_combine(seed, std::hash<OpenMS::CVTerm>{}(term));
122 }
123 }
124 return seed;
125 }
126 };
127} // namespace std
128
Interface to the controlled vocabulary term list.
Definition CVTermListInterface.h:34
CVTermListInterface(const CVTermListInterface &rhs)
Copy constructor.
CVTermListInterface(CVTermListInterface &&) noexcept
Move constructor.
Representation of controlled vocabulary term list.
Definition CVTermList.h:29
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::CVTermListInterface &iface) const noexcept
Definition CVTermListInterface.h:111