IMP  2.1.0
The Integrative Modeling Platform
kernel/declare_Particle.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/declare_Particle.h
3  * \brief Classes to handle individual model particles.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_DECLARE_PARTICLE_H
10 #define IMPKERNEL_DECLARE_PARTICLE_H
11 
12 #include <IMP/kernel/kernel_config.h>
13 #include "base_types.h"
14 #include <IMP/base/Object.h>
15 #include <IMP/base/utility.h>
16 #include "Key.h"
17 #include "internal/AttributeTable.h"
18 #include "DerivativeAccumulator.h"
19 #include <IMP/base/Pointer.h>
20 #include "ModelObject.h"
21 #include "particle_index.h"
22 #include <utility>
23 
24 IMPKERNEL_BEGIN_NAMESPACE
25 
26 class Model;
27 class Changed;
28 class SaveOptimizeds;
29 
30 //! Class to handle individual model particles.
31 /** At this point a Particle should only be considered as a placeholder for the
32  ParticleIndex, accessed through the get_index() method.
33 */
34 class IMPKERNELEXPORT Particle : public ModelObject {
35  private:
36 // doxygen produces funny docs for these things
37 #ifndef IMP_DOXYGEN
38  friend class Model;
39 #endif
40  ParticleIndex id_;
42 
43  public:
44 
45  //! Construct a particle and add it to the Model
46  Particle(kernel::Model *m, std::string name);
47 
48  //! Construct a particle and add it to the Model
50 
51 #ifndef IMP_DOXYGEN
52 
53 #define IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(UCName, lcname, Value) \
54  void add_attribute(UCName##Key name, Value initial_value); \
55  void remove_attribute(UCName##Key name); \
56  bool has_attribute(UCName##Key name) const; \
57  Value get_value(UCName##Key name) const; \
58  void set_value(UCName##Key name, Value value); \
59  void add_cache_attribute(UCName##Key name, Value value); \
60  UCName##Keys get_##lcname##_keys() const
61 
62  IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(Float, float, Float);
63  IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(Int, int, Int);
64  IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(String, string, String);
65  IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(Object, object, Object *);
66  IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(WeakObject, weak_object, Object *);
67 
68  /** @name Float Attributes
69  Float attributes can be optimized, meaning the optimizer is
70  allowed to change their value in order to improve the score.
71  As a result, there are a number of extra methods to manipulate
72  them.
73 
74  All distances are assumed to be in angstroms
75  and derivatives in kcal/mol angstrom. This is not enforced.
76  */
77  /*@{*/
78  void add_attribute(FloatKey name, const Float initial_value, bool optimized);
79 
80  void add_to_derivative(FloatKey key, Float value,
81  const DerivativeAccumulator &da);
82 
83  void set_is_optimized(FloatKey k, bool tf);
84 
85  bool get_is_optimized(FloatKey k) const;
86 
87  Float get_derivative(FloatKey name) const;
88  /** @} */
89 
90  /** \name Particle attributes
91  @{
92  */
93  void add_attribute(ParticleIndexKey k, Particle *v);
94  bool has_attribute(ParticleIndexKey k);
95  void set_value(ParticleIndexKey k, Particle *v);
96  Particle *get_value(ParticleIndexKey k) const;
97  void remove_attribute(ParticleIndexKey k);
98  ParticleIndexKeys get_particle_keys() const;
99  /** @} */
100 
101  //! Print out all the attributes
102  void show(std::ostream &out = std::cout) const;
103 
104  //! Get whether the particle is active.
105  /** Restraints referencing the particle are only evaluated for 'active'
106  particles.
107  \return true it the particle is active.
108  */
109  bool get_is_active() const;
110 #endif
111 
112  ParticleIndex get_index() const;
113 
114 #if !defined(IMP_DOXYGEN)
115  void clear_caches();
116 #endif
117  protected:
118  virtual ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE IMP_FINAL {
119  return ModelObjectsTemp();
120  }
121  virtual ModelObjectsTemp do_get_outputs() const IMP_OVERRIDE IMP_FINAL {
122  return ModelObjectsTemp();
123  }
124 };
125 
126 IMPKERNEL_END_NAMESPACE
127 
128 #endif /* IMPKERNEL_DECLARE_PARTICLE_H */
Various general useful functions for IMP.
Class for adding derivatives from restraints to the model.
Class for adding derivatives from restraints to the model.
Ints get_index(const kernel::ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
IMP::base::Vector< IMP::base::WeakPointer< kernel::ModelObject > > ModelObjectsTemp
A nullptr-initialized pointer to an IMP Object.
Basic types used by IMP.
virtual ModelObjectsTemp do_get_outputs() const
virtual void clear_caches()
virtual ModelObjectsTemp do_get_inputs() const
Single variable function.
IMP::kernel::Model Model
Various general useful functions for IMP.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Class to handle individual model particles.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
IMP::kernel::Particle Particle
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
int Int
Basic integer value.
Definition: base/types.h:35
A shared base class to help in debugging and things.
Keys to cache lookup of attribute strings.
std::string String
Basic string value.
Definition: base/types.h:44
Class for storing model, its restraints, constraints, and particles.