IMP  2.0.0
The Integrative Modeling Platform
kernel/Particle.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/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_PARTICLE_H
10 #define IMPKERNEL_PARTICLE_H
11 
12 #include <IMP/kernel/kernel_config.h>
13 #include "declare_Particle.h"
14 #include "Model.h"
15 
16 
17 IMPKERNEL_BEGIN_NAMESPACE
18 #ifndef IMP_DOXYGEN
19 
20 inline bool Particle::get_is_active() const {
21  IMP_CHECK_OBJECT(this);
22  return get_is_part_of_model();
23 }
24 
25 inline ParticleIndex Particle::get_index() const {
26  return id_;
27 }
28 
29 
30 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(Float, float, Float);
31 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(Int, int, Int);
32 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(String, string, String);
33 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(Object, object, base::Object*);
34 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(WeakObject, weak_object, base::Object*);
35 
36 
37 inline void Particle::add_attribute(FloatKey name,
38  const Float initial_value, bool optimized){
39  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
40  get_model()->add_attribute(name, id_, initial_value);
41  get_model()->set_is_optimized(name, id_, optimized);
42 }
43 inline void Particle::add_to_derivative(FloatKey key, Float value,
44  const DerivativeAccumulator &da) {
45  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
46  get_model()->add_to_derivative(key, id_, value, da);
47 }
48 inline void Particle::set_is_optimized(FloatKey k, bool tf) {
49  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
50  return get_model()->set_is_optimized(k, id_, tf);
51 }
52 inline bool Particle::get_is_optimized(FloatKey k) const {
53  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
54  return get_model()->get_is_optimized(k, id_);
55 }
56 inline Float Particle::get_derivative(FloatKey name) const {
57  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
58  return get_model()->get_derivative(name, id_);
59 }
60 inline void Particle::add_attribute(ParticleIndexKey k, Particle *v) {
61  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
62  get_model()->add_attribute(k, id_, v->get_index());
63 }
64 inline bool Particle::has_attribute(ParticleIndexKey k) {
65  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
66  return get_model()->get_has_attribute(k, id_);
67 }
68 inline void Particle::set_value(ParticleIndexKey k, Particle *v) {
69  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
70  get_model()->set_attribute(k, id_, v->get_index());
71 }
72 inline Particle *Particle::get_value(ParticleIndexKey k) const {
73  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
74  return get_model()->get_particle(get_model()->get_attribute(k, id_));
75 }
76 inline void Particle::remove_attribute(ParticleIndexKey k) {
77  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
78  get_model()->remove_attribute(k, id_);
79 }
80 inline ParticleIndexKeys Particle::get_particle_keys() const {
81  IMP_USAGE_CHECK(get_is_active(), "Inactive particle used.");
82  return get_model()->internal::ParticleAttributeTable::get_attribute_keys(id_);
83 }
84 #endif
85 
86 IMPKERNEL_END_NAMESPACE
87 
88 #endif /* IMPKERNEL_PARTICLE_H */