OpenMS
Sample Class Reference

Meta information about the sample. More...

#include <OpenMS/METADATA/Sample.h>

Inheritance diagram for Sample:
[legend]
Collaboration diagram for Sample:
[legend]

Public Types

enum  SampleState {
  SAMPLENULL , SOLID , LIQUID , GAS ,
  SOLUTION , EMULSION , SUSPENSION , SIZE_OF_SAMPLESTATE
}
 state of aggregation of the sample More...
 

Public Member Functions

 Sample ()
 Default constructor. More...
 
 Sample (const Sample &source)
 Copy constructor. More...
 
 Sample (Sample &&)=default
 Move constructor. More...
 
 ~Sample ()
 Destructor. More...
 
Sampleoperator= (const Sample &source)
 Assignment operator. More...
 
Sampleoperator= (Sample &&) &=default
 Move assignment operator. More...
 
bool operator== (const Sample &rhs) const
 Equality operator. More...
 
const StringgetName () const
 returns the sample name (default: "") More...
 
void setName (const String &name)
 sets the sample name More...
 
const StringgetOrganism () const
 returns the sample name (default: "") More...
 
void setOrganism (const String &organism)
 sets the sample name More...
 
const StringgetNumber () const
 returns the sample number (default: "") More...
 
void setNumber (const String &number)
 sets the sample number (e.g. sample ID) More...
 
const StringgetComment () const
 returns the comment (default: "") More...
 
void setComment (const String &comment)
 sets the comment (may contain newline characters) More...
 
SampleState getState () const
 returns the state of aggregation (default: SAMPLENULL) More...
 
void setState (SampleState state)
 sets the state of aggregation More...
 
double getMass () const
 returns the mass (in gram) (default: 0.0) More...
 
void setMass (double mass)
 sets the mass (in gram) More...
 
double getVolume () const
 returns the volume (in ml) (default: 0.0) More...
 
void setVolume (double volume)
 sets the volume (in ml) More...
 
double getConcentration () const
 returns the concentration (in g/l) (default: 0.0) More...
 
void setConcentration (double concentration)
 sets the concentration (in g/l) More...
 
std::vector< Sample > & getSubsamples ()
 returns a mutable reference to the vector of subsamples that were combined to create this sample More...
 
const std::vector< Sample > & getSubsamples () const
 returns a const reference to the vector of subsamples that were combined to create this sample More...
 
void setSubsamples (const std::vector< Sample > &subsamples)
 sets the vector of subsamples that were combined to create this sample More...
 
void addTreatment (const SampleTreatment &treatment, Int before_position=-1)
 adds a sample treatment before the given position (default is the end of the list). Sample treatments are ordered in the order of application to the sample. If before_position is smaller than 0, the sample treatment is appended to the list. More...
 
SampleTreatmentgetTreatment (UInt position)
 returns a mutable reference to the sample treatment at the given position More...
 
const SampleTreatmentgetTreatment (UInt position) const
 returns a const reference to the sample treatment at the given position More...
 
void removeTreatment (UInt position)
 removes the sample treatment at the given position More...
 
Int countTreatments () const
 returns the number of sample treatments More...
 
- Public Member Functions inherited from MetaInfoInterface
 MetaInfoInterface ()
 Constructor. More...
 
 MetaInfoInterface (const MetaInfoInterface &rhs)
 Copy constructor. More...
 
 MetaInfoInterface (MetaInfoInterface &&) noexcept
 Move constructor. More...
 
 ~MetaInfoInterface ()
 Destructor. More...
 
MetaInfoInterfaceoperator= (const MetaInfoInterface &rhs)
 Assignment operator. More...
 
MetaInfoInterfaceoperator= (MetaInfoInterface &&) noexcept
 Move assignment operator. More...
 
void swap (MetaInfoInterface &rhs)
 Swap contents. More...
 
bool operator== (const MetaInfoInterface &rhs) const
 Equality operator. More...
 
bool operator!= (const MetaInfoInterface &rhs) const
 Equality operator. More...
 
const DataValuegetMetaValue (const String &name) const
 Returns the value corresponding to a string, or DataValue::EMPTY if not found. More...
 
DataValue getMetaValue (const String &name, const DataValue &default_value) const
 Returns the value corresponding to a string, or a default value (e.g.: DataValue::EMPTY) if not found. More...
 
const DataValuegetMetaValue (UInt index) const
 Returns the value corresponding to the index, or DataValue::EMPTY if not found. More...
 
DataValue getMetaValue (UInt index, const DataValue &default_value) const
 Returns the value corresponding to the index, or a default value (e.g.: DataValue::EMPTY) if not found. More...
 
bool metaValueExists (const String &name) const
 Returns whether an entry with the given name exists. More...
 
bool metaValueExists (UInt index) const
 Returns whether an entry with the given index exists. More...
 
void setMetaValue (const String &name, const DataValue &value)
 Sets the DataValue corresponding to a name. More...
 
void setMetaValue (UInt index, const DataValue &value)
 Sets the DataValue corresponding to an index. More...
 
void removeMetaValue (const String &name)
 Removes the DataValue corresponding to name if it exists. More...
 
void removeMetaValue (UInt index)
 Removes the DataValue corresponding to index if it exists. More...
 
void addMetaValues (const MetaInfoInterface &from)
 function to copy all meta values from one object to this one More...
 
void getKeys (std::vector< String > &keys) const
 Fills the given vector with a list of all keys for which a value is set. More...
 
void getKeys (std::vector< UInt > &keys) const
 Fills the given vector with a list of all keys for which a value is set. More...
 
bool isMetaEmpty () const
 Returns if the MetaInfo is empty. More...
 
void clearMetaInfo ()
 Removes all meta values. More...
 

Static Public Attributes

static const std::string NamesOfSampleState [SIZE_OF_SAMPLESTATE]
 Names of sample states. More...
 

Protected Attributes

String name_
 
String number_
 
String comment_
 
String organism_
 
SampleState state_
 
double mass_
 
double volume_
 
double concentration_
 
std::vector< Samplesubsamples_
 
std::list< SampleTreatment * > treatments_
 
- Protected Attributes inherited from MetaInfoInterface
MetaInfometa_
 Pointer to the MetaInfo object (0 by default) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MetaInfoInterface
static MetaInfoRegistrymetaRegistry ()
 Returns a reference to the MetaInfoRegistry. More...
 
- Protected Member Functions inherited from MetaInfoInterface
void createIfNotExists_ ()
 Creates the MetaInfo object if it does not exist. More...
 

Detailed Description

Meta information about the sample.

It contains basic descriptions like name, number (i.e. order number), mass, volume, concentration, state and a comment.

Additionally sample treatments like Digestion, Modification or Tagging can be added.

A Sample can be composed of other samples.

Member Enumeration Documentation

◆ SampleState

state of aggregation of the sample

Enumerator
SAMPLENULL 
SOLID 
LIQUID 
GAS 
SOLUTION 
EMULSION 
SUSPENSION 
SIZE_OF_SAMPLESTATE 

Constructor & Destructor Documentation

◆ Sample() [1/3]

Sample ( )

Default constructor.

◆ Sample() [2/3]

Sample ( const Sample source)

Copy constructor.

◆ Sample() [3/3]

Sample ( Sample &&  )
default

Move constructor.

◆ ~Sample()

~Sample ( )

Destructor.

Member Function Documentation

◆ addTreatment()

void addTreatment ( const SampleTreatment treatment,
Int  before_position = -1 
)

adds a sample treatment before the given position (default is the end of the list). Sample treatments are ordered in the order of application to the sample. If before_position is smaller than 0, the sample treatment is appended to the list.

Exceptions
Exception::IndexOverflowis thrown if the position is invalid.

◆ countTreatments()

Int countTreatments ( ) const

returns the number of sample treatments

◆ getComment()

const String& getComment ( ) const

returns the comment (default: "")

◆ getConcentration()

double getConcentration ( ) const

returns the concentration (in g/l) (default: 0.0)

◆ getMass()

double getMass ( ) const

returns the mass (in gram) (default: 0.0)

◆ getName()

const String& getName ( ) const

returns the sample name (default: "")

◆ getNumber()

const String& getNumber ( ) const

returns the sample number (default: "")

◆ getOrganism()

const String& getOrganism ( ) const

returns the sample name (default: "")

◆ getState()

SampleState getState ( ) const

returns the state of aggregation (default: SAMPLENULL)

◆ getSubsamples() [1/2]

std::vector<Sample>& getSubsamples ( )

returns a mutable reference to the vector of subsamples that were combined to create this sample

◆ getSubsamples() [2/2]

const std::vector<Sample>& getSubsamples ( ) const

returns a const reference to the vector of subsamples that were combined to create this sample

◆ getTreatment() [1/2]

SampleTreatment& getTreatment ( UInt  position)

returns a mutable reference to the sample treatment at the given position

Exceptions
Exception::IndexOverflowis thrown if the position is invalid.

◆ getTreatment() [2/2]

const SampleTreatment& getTreatment ( UInt  position) const

returns a const reference to the sample treatment at the given position

Exceptions
Exception::IndexOverflowis thrown if the position is invalid.

◆ getVolume()

double getVolume ( ) const

returns the volume (in ml) (default: 0.0)

◆ operator=() [1/2]

Sample& operator= ( const Sample source)

Assignment operator.

◆ operator=() [2/2]

Sample& operator= ( Sample &&  ) &
default

Move assignment operator.

◆ operator==()

bool operator== ( const Sample rhs) const

Equality operator.

◆ removeTreatment()

void removeTreatment ( UInt  position)

removes the sample treatment at the given position

Exceptions
Exception::IndexOverflowis thrown if the position is invalid.

◆ setComment()

void setComment ( const String comment)

sets the comment (may contain newline characters)

◆ setConcentration()

void setConcentration ( double  concentration)

sets the concentration (in g/l)

◆ setMass()

void setMass ( double  mass)

sets the mass (in gram)

◆ setName()

void setName ( const String name)

sets the sample name

◆ setNumber()

void setNumber ( const String number)

sets the sample number (e.g. sample ID)

◆ setOrganism()

void setOrganism ( const String organism)

sets the sample name

◆ setState()

void setState ( SampleState  state)

sets the state of aggregation

◆ setSubsamples()

void setSubsamples ( const std::vector< Sample > &  subsamples)

sets the vector of subsamples that were combined to create this sample

◆ setVolume()

void setVolume ( double  volume)

sets the volume (in ml)

Member Data Documentation

◆ comment_

String comment_
protected

◆ concentration_

double concentration_
protected

◆ mass_

double mass_
protected

◆ name_

String name_
protected

◆ NamesOfSampleState

const std::string NamesOfSampleState[SIZE_OF_SAMPLESTATE]
static

Names of sample states.

◆ number_

String number_
protected

◆ organism_

String organism_
protected

◆ state_

SampleState state_
protected

◆ subsamples_

std::vector<Sample> subsamples_
protected

◆ treatments_

std::list<SampleTreatment *> treatments_
protected

◆ volume_

double volume_
protected