IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
Uncertainty.h
Go to the documentation of this file.
1 /**
2  * \file IMP/pmi/Uncertainty.h
3  * \brief A decorator for particles with Uncertainty
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPPMI_UNCERTAINTY_H
9 #define IMPPMI_UNCERTAINTY_H
10 
11 #include <IMP/pmi/pmi_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 IMPPMI_BEGIN_NAMESPACE
19 
20 //! Add uncertainty to a particle
21 /** The uncertainty of the particle can be assumed to be the radius
22  of a particle.
23  */
24 class IMPPMIEXPORT Uncertainty : public Decorator {
25  static void do_setup_particle(Model *m, ParticleIndex pi, double uncertainty) {
26  m->add_attribute(get_uncertainty_key(), pi, uncertainty);
27  }
28  public:
29 
30  static bool get_is_setup(Model *m, ParticleIndex pi) {
31  return m->get_has_attribute(get_uncertainty_key(), pi);
32  }
33 
34  Float get_uncertainty() const {
35  return get_model()->get_attribute(get_uncertainty_key(),
37  }
38 
39  void set_uncertainty(Float d) {
40  get_model()->set_attribute(get_uncertainty_key(), get_particle_index(), d);
41  }
42 
44  /** Add the specified Uncertainty to the particle. */
46 
47  static FloatKey get_uncertainty_key();
48 };
49 
50 IMPPMI_END_NAMESPACE
51 
52 #endif /* IMPPMI_UNCERTAINTY_H */
The base class for decorators.
ParticleIndex get_particle_index() const
Returns the particle index decorated by this decorator.
Definition: Decorator.h:211
A container for Singletons.
#define IMP_DECORATOR_SETUP_1(Name, FirstArgumentType, first_argument_name)
Model * get_model() const
Returns the Model containing the particle.
Definition: Decorator.h:214
Add uncertainty to a particle.
Definition: Uncertainty.h:24
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
A container for Pairs.
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle attribute with the specified key and initial value
Helper macros for implementing Decorators.
void set_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
set the value of particle attribute with the specified key
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:119
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
Type get_attribute(TypeKey attribute_key, ParticleIndex particle)
get the value of the particle attribute with the specified key