OpenMS
Sample.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: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <list>
38 
42 
43 namespace OpenMS
44 {
45  class SampleTreatment;
46 
59  class OPENMS_DLLAPI Sample :
60  public MetaInfoInterface
61  {
62 public:
64  enum SampleState {SAMPLENULL, SOLID, LIQUID, GAS, SOLUTION, EMULSION, SUSPENSION, SIZE_OF_SAMPLESTATE};
66  static const std::string NamesOfSampleState[SIZE_OF_SAMPLESTATE];
67 
69  Sample();
71  Sample(const Sample & source);
73  Sample(Sample&&) = default;
76 
78  Sample & operator=(const Sample & source);
80  Sample& operator=(Sample&&) & = default;
81 
83  bool operator==(const Sample & rhs) const;
84 
86  const String & getName() const;
88  void setName(const String & name);
89 
91  const String & getOrganism() const;
93  void setOrganism(const String & organism);
94 
96  const String & getNumber() const;
98  void setNumber(const String & number);
99 
101  const String & getComment() const;
103  void setComment(const String & comment);
104 
108  void setState(SampleState state);
109 
111  double getMass() const;
113  void setMass(double mass);
114 
116  double getVolume() const;
118  void setVolume(double volume);
119 
121  double getConcentration() const;
123  void setConcentration(double concentration);
124 
126  std::vector<Sample> & getSubsamples();
128  const std::vector<Sample> & getSubsamples() const;
130  void setSubsamples(const std::vector<Sample> & subsamples);
131 
140  void addTreatment(const SampleTreatment & treatment, Int before_position = -1);
141 
148 
154  const SampleTreatment & getTreatment(UInt position) const;
155 
161  void removeTreatment(UInt position);
162 
165 
166 protected:
172  double mass_;
173  double volume_;
175  std::vector<Sample> subsamples_;
176 
177  // note: default move constructor / assignment operator will work on this,
178  // since it will move the whole vector over to the new object who will then
179  // own the memory.
180  std::list<SampleTreatment *> treatments_;
181 
182  };
183 } // namespace OpenMS
184 
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
Base class for sample treatments (Digestion, Modification, Tagging, ...)
Definition: SampleTreatment.h:53
Meta information about the sample.
Definition: Sample.h:61
String comment_
Definition: Sample.h:169
void setOrganism(const String &organism)
sets the sample name
Sample & operator=(Sample &&) &=default
Move assignment operator.
bool operator==(const Sample &rhs) const
Equality operator.
double mass_
Definition: Sample.h:172
void setComment(const String &comment)
sets the comment (may contain newline characters)
double getConcentration() const
returns the concentration (in g/l) (default: 0.0)
void setConcentration(double concentration)
sets the concentration (in g/l)
Sample & operator=(const Sample &source)
Assignment operator.
String number_
Definition: Sample.h:168
SampleState
state of aggregation of the sample
Definition: Sample.h:64
@ EMULSION
Definition: Sample.h:64
String name_
Definition: Sample.h:167
Sample(const Sample &source)
Copy constructor.
double concentration_
Definition: Sample.h:174
Sample(Sample &&)=default
Move constructor.
void setName(const String &name)
sets the sample name
String organism_
Definition: Sample.h:170
Int countTreatments() const
returns the number of sample treatments
void setState(SampleState state)
sets the state of aggregation
SampleTreatment & getTreatment(UInt position)
returns a mutable reference to the sample treatment at the given position
const String & getOrganism() const
returns the sample name (default: "")
double getVolume() const
returns the volume (in ml) (default: 0.0)
void removeTreatment(UInt position)
removes the sample treatment at the given position
~Sample()
Destructor.
std::vector< Sample > & getSubsamples()
returns a mutable reference to the vector of subsamples that were combined to create this sample
const SampleTreatment & getTreatment(UInt position) const
returns a const reference to the sample treatment at the given position
void setNumber(const String &number)
sets the sample number (e.g. sample ID)
void setMass(double mass)
sets the mass (in gram)
const std::vector< Sample > & getSubsamples() const
returns a const reference to the vector of subsamples that were combined to create this sample
void setVolume(double volume)
sets the volume (in ml)
const String & getName() const
returns the sample name (default: "")
std::list< SampleTreatment * > treatments_
Definition: Sample.h:180
const String & getNumber() const
returns the sample number (default: "")
const String & getComment() const
returns the comment (default: "")
SampleState getState() const
returns the state of aggregation (default: SAMPLENULL)
void addTreatment(const SampleTreatment &treatment, Int before_position=-1)
adds a sample treatment before the given position (default is the end of the list)....
SampleState state_
Definition: Sample.h:171
Sample()
Default constructor.
double volume_
Definition: Sample.h:173
double getMass() const
returns the mass (in gram) (default: 0.0)
std::vector< Sample > subsamples_
Definition: Sample.h:175
void setSubsamples(const std::vector< Sample > &subsamples)
sets the vector of subsamples that were combined to create this sample
A more convenient string class.
Definition: String.h:60
int Int
Signed integer type.
Definition: Types.h:102
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
static String number(double d, UInt n)
Definition: StringUtils.h:217
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48