OpenMS
Sample.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Marc Sturm $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <list>
12 
16 
17 namespace OpenMS
18 {
19  class SampleTreatment;
20 
33  class OPENMS_DLLAPI Sample :
34  public MetaInfoInterface
35  {
36 public:
38  enum SampleState {SAMPLENULL, SOLID, LIQUID, GAS, SOLUTION, EMULSION, SUSPENSION, SIZE_OF_SAMPLESTATE};
40  static const std::string NamesOfSampleState[SIZE_OF_SAMPLESTATE];
41 
43  Sample();
45  Sample(const Sample & source);
47  Sample(Sample&&) = default;
50 
52  Sample & operator=(const Sample & source);
54  Sample& operator=(Sample&&) & = default;
55 
57  bool operator==(const Sample & rhs) const;
58 
60  const String & getName() const;
62  void setName(const String & name);
63 
65  const String & getOrganism() const;
67  void setOrganism(const String & organism);
68 
70  const String & getNumber() const;
72  void setNumber(const String & number);
73 
75  const String & getComment() const;
77  void setComment(const String & comment);
78 
82  void setState(SampleState state);
83 
85  double getMass() const;
87  void setMass(double mass);
88 
90  double getVolume() const;
92  void setVolume(double volume);
93 
95  double getConcentration() const;
97  void setConcentration(double concentration);
98 
100  std::vector<Sample> & getSubsamples();
102  const std::vector<Sample> & getSubsamples() const;
104  void setSubsamples(const std::vector<Sample> & subsamples);
105 
114  void addTreatment(const SampleTreatment & treatment, Int before_position = -1);
115 
122 
128  const SampleTreatment & getTreatment(UInt position) const;
129 
135  void removeTreatment(UInt position);
136 
139 
140 protected:
146  double mass_;
147  double volume_;
149  std::vector<Sample> subsamples_;
150 
151  // note: default move constructor / assignment operator will work on this,
152  // since it will move the whole vector over to the new object who will then
153  // own the memory.
154  std::list<SampleTreatment *> treatments_;
155 
156  };
157 } // namespace OpenMS
158 
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:35
Base class for sample treatments (Digestion, Modification, Tagging, ...)
Definition: SampleTreatment.h:27
Meta information about the sample.
Definition: Sample.h:35
String comment_
Definition: Sample.h:143
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:146
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:142
SampleState
state of aggregation of the sample
Definition: Sample.h:38
@ EMULSION
Definition: Sample.h:38
String name_
Definition: Sample.h:141
Sample(const Sample &source)
Copy constructor.
double concentration_
Definition: Sample.h:148
Sample(Sample &&)=default
Move constructor.
void setName(const String &name)
sets the sample name
String organism_
Definition: Sample.h:144
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:154
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:145
Sample()
Default constructor.
double volume_
Definition: Sample.h:147
double getMass() const
returns the mass (in gram) (default: 0.0)
std::vector< Sample > subsamples_
Definition: Sample.h:149
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:34
int Int
Signed integer type.
Definition: Types.h:76
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
static String number(double d, UInt n)
Definition: StringUtils.h:191
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22