IMP  2.0.1
The Integrative Modeling Platform
Mass.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Mass.h
3  * \brief A decorator for particles with mass
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPATOM_MASS_H
9 #define IMPATOM_MASS_H
10 
11 #include <IMP/atom/atom_config.h>
12 
13 #include <IMP/PairContainer.h>
14 #include <IMP/SingletonContainer.h>
15 #include <IMP/Decorator.h>
16 #include <IMP/decorator_macros.h>
17 
18 IMPATOM_BEGIN_NAMESPACE
19 
20 //! Add mass to a particle
21 /** The mass of the particle is assumed to be in Daltons.
22  */
23 class IMPATOMEXPORT Mass: public Decorator
24 {
25 public:
26  static Mass setup_particle(Particle *p, double mass) {
27  p->add_attribute(get_mass_key(), mass);
28  return Mass(p);
29  }
30 
31  static bool particle_is_instance(Particle *p) {
32  return p->has_attribute(get_mass_key());
33  }
34 
35  Float get_mass() const {
36  return get_particle()->get_value(get_mass_key());
37  }
38 
39  void set_mass(Float d) {
40  get_particle()->set_value(get_mass_key(), d);
41  }
42 
44 
45  static FloatKey get_mass_key();
46 };
47 
48 
49 IMPATOM_END_NAMESPACE
50 
51 #endif /* IMPATOM_MASS_H */