OpenMS
CVTerm.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2023.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
40 namespace OpenMS
41 {
42 
52  class OPENMS_DLLAPI CVTerm
53  {
54 public:
55 
56  struct Unit
57  {
58 
60  Unit() = default;
61 
62  Unit(const String& p_accession, const String& p_name, const String& p_cv_ref) :
63  accession(p_accession),
64  name(p_name),
65  cv_ref(p_cv_ref)
66  {
67  }
68 
70  Unit(const Unit &) = default;
71 
73  Unit(Unit&&) = default;
74 
76  virtual ~Unit()
77  {
78  }
79 
81  Unit& operator=(const Unit&) = default;
82 
84  Unit& operator=(Unit&&)& = default;
85 
86  bool operator==(const Unit& rhs) const
87  {
88  return accession == rhs.accession &&
89  name == rhs.name &&
90  cv_ref == rhs.cv_ref;
91  }
92 
93  bool operator!=(const Unit& rhs) const
94  {
95  return !(*this == rhs);
96  }
97 
101  };
102 
104  CVTerm() = default;
105 
107  CVTerm(const String& accession, const String& name = "", const String& cv_identifier_ref = "", const String& value = "", const Unit& unit = Unit());
108 
110  CVTerm(const CVTerm&) = default;
111 
113  CVTerm(CVTerm&&) = default;
114 
116  virtual ~CVTerm();
117 
119  CVTerm& operator=(const CVTerm&) = default;
120 
122  CVTerm& operator=(CVTerm&&)& = default;
123 
128  void setAccession(const String& accession);
129 
131  const String& getAccession() const;
132 
134  void setName(const String& name);
135 
137  const String& getName() const;
138 
140  void setCVIdentifierRef(const String& cv_identifier_ref);
141 
143  const String& getCVIdentifierRef() const;
144 
146  void setValue(const DataValue& value);
147 
149  const DataValue& getValue() const;
150 
152  void setUnit(const Unit& unit);
153 
155  const Unit& getUnit() const;
157 
162  bool operator==(const CVTerm& rhs) const;
163 
165  bool operator!=(const CVTerm& rhs) const;
166 
168  bool hasValue() const;
169 
171  bool hasUnit() const;
172  //}
173 
174 protected:
175 
177 
179 
181 
183 
185  };
186 
187 } // namespace OpenMS
188 
Representation of controlled vocabulary term.
Definition: CVTerm.h:53
bool operator==(const CVTerm &rhs) const
equality operator
const String & getCVIdentifierRef() const
returns the cv identifier reference string
virtual ~CVTerm()
Destructor.
void setUnit(const Unit &unit)
sets the unit of the term
Unit unit_
Definition: CVTerm.h:182
String name_
Definition: CVTerm.h:178
DataValue value_
Definition: CVTerm.h:184
CVTerm(const CVTerm &)=default
Copy constructor.
CVTerm(CVTerm &&)=default
Move constructor.
CVTerm & operator=(CVTerm &&) &=default
Move assignment operator.
void setCVIdentifierRef(const String &cv_identifier_ref)
sets the cv identifier reference string, e.g. UO for unit obo
void setName(const String &name)
sets the name of the term
const Unit & getUnit() const
returns the unit
void setValue(const DataValue &value)
set the value of the term
const String & getAccession() const
returns the accession string of the term
String accession_
Definition: CVTerm.h:176
const String & getName() const
returns the name of the term
void setAccession(const String &accession)
sets the accession string of the term
bool hasUnit() const
checks whether the term has a unit
const DataValue & getValue() const
returns the value of the term
bool operator!=(const CVTerm &rhs) const
inequality operator
String cv_identifier_ref_
Definition: CVTerm.h:180
CVTerm & operator=(const CVTerm &)=default
Assignment operator.
bool hasValue() const
checks whether the term has a value
CVTerm()=default
Default constructor.
CVTerm(const String &accession, const String &name="", const String &cv_identifier_ref="", const String &value="", const Unit &unit=Unit())
Detailed constructor.
Class to hold strings, numeric values, lists of strings and lists of numeric values.
Definition: DataValue.h:59
A more convenient string class.
Definition: String.h:60
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
Definition: CVTerm.h:57
bool operator!=(const Unit &rhs) const
Definition: CVTerm.h:93
Unit()=default
Default constructor.
String cv_ref
Definition: CVTerm.h:100
Unit & operator=(Unit &&) &=default
Move assignment operator.
virtual ~Unit()
Destructor.
Definition: CVTerm.h:76
String name
Definition: CVTerm.h:99
String accession
Definition: CVTerm.h:98
Unit(const String &p_accession, const String &p_name, const String &p_cv_ref)
Definition: CVTerm.h:62
Unit(Unit &&)=default
Move constructor.
Unit & operator=(const Unit &)=default
Assignment operator.
bool operator==(const Unit &rhs) const
Definition: CVTerm.h:86
Unit(const Unit &)=default
Copy constructor.