IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
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-2022 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>
15#include <IMP/Decorator.h>
17
18IMPATOM_BEGIN_NAMESPACE
19
20//! Add mass to a particle
21/** The mass of the particle is assumed to be in Daltons.
22 */
23class IMPATOMEXPORT Mass : public Decorator {
24 static void do_setup_particle(Model *m, ParticleIndex pi,
25 double mass) {
26 m->add_attribute(get_mass_key(), pi, mass);
27 }
28 static void do_setup_particle(Model *m, ParticleIndex pi,
29 Mass o) {
30 do_setup_particle(m, pi, o.get_mass());
31 }
32
33 public:
34 static bool get_is_setup(Model *m, ParticleIndex pi) {
35 return m->get_has_attribute(get_mass_key(), pi);
36 }
37
38 Float get_mass() const {
39 return get_model()->get_attribute(get_mass_key(), get_particle_index());
40 }
41
42 void set_mass(Float d) {
43 get_model()->set_attribute(get_mass_key(), get_particle_index(), d);
44 }
45
46 IMP_DECORATOR_METHODS(Mass, Decorator);
47 /** Add the specified mass to the particle. */
49 IMP_DECORATOR_SETUP_1(Mass, Mass, other);
50
51 /** Get the key used to store the mass. */
53};
54
55IMPATOM_END_NAMESPACE
56
57#endif /* IMPATOM_MASS_H */
The base class for decorators.
A container for Pairs.
A container for Singletons.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition Decorator.h:211
Model * get_model() const
Returns the Model containing the particle.
Definition Decorator.h:214
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
static FloatKey get_mass_key()
Helper macros for implementing Decorators.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
#define IMP_DECORATOR_METHODS(Name, Parent)
Index< ParticleIndexTag > ParticleIndex
Definition base_types.h:196
double Float
Basic floating-point value (could be float, double...).
Definition types.h:19
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
Definition base_types.h:32