IMP  2.1.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  static void do_setup_particle(kernel::Model *m, kernel::ParticleIndex pi,
25  double mass) {
26  m->add_attribute(get_mass_key(), pi, mass);
27  }
28 
29  public:
30 
32  return m->get_has_attribute(get_mass_key(), pi);
33  }
34 
35  Float get_mass() const {
36  return get_model()->get_attribute(get_mass_key(), get_particle_index());
37  }
38 
39  void set_mass(Float d) {
40  get_model()->set_attribute(get_mass_key(), get_particle_index(), d);
41  }
42 
44  /** Add the specified mass to the particle. */
46 
47  /** Get the key used to store the mass. */
48  static FloatKey get_mass_key();
49 };
50 
51 IMPATOM_END_NAMESPACE
52 
53 #endif /* IMPATOM_MASS_H */
Import IMP/kernel/Decorator.h in the namespace.
Add mass to a particle.
Definition: Mass.h:23
Import IMP/kernel/SingletonContainer.h in the namespace.
double get_mass(const Selection &s)
#define IMP_DECORATOR_METHODS(Name, Parent)
Model * get_model() const
Returns the Model containing the particle.
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
Import IMP/kernel/PairContainer.h in the namespace.
static bool get_is_setup(Particle *p)
Return true if the particle can be cast to the decorator.
Import IMP/kernel/decorator_macros.h in the namespace.
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Class for storing model, its restraints, constraints, and particles.