10 #ifndef IMPKERNEL_PARTICLE_H
11 #define IMPKERNEL_PARTICLE_H
13 #include <IMP/kernel_config.h>
14 #include "base_types.h"
15 #include "DerivativeAccumulator.h"
20 #include "internal/AttributeTable.h"
27 IMPKERNEL_BEGIN_NAMESPACE
55 #define IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(UCName, lcname, Value) \
56 inline void add_attribute(UCName##Key name, Value initial_value); \
57 inline void remove_attribute(UCName##Key name); \
58 inline bool has_attribute(UCName##Key name) const; \
59 inline Value get_value(UCName##Key name) const; \
60 inline void set_value(UCName##Key name, Value value); \
61 inline void add_cache_attribute(UCName##Key name, Value value); \
62 inline UCName##Keys get_##lcname##_keys() const
64 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Float,
float,
Float);
65 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Int,
int,
Int);
66 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
String,
string,
String);
67 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Object,
object,
Object *);
68 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(WeakObject, weak_object,
Object *);
86 void add_attribute(
FloatKey name,
const Float initial_value,
bool optimized);
97 void set_is_optimized(
FloatKey k,
bool tf);
100 inline bool get_is_optimized(
FloatKey k)
const;
118 void show(std::ostream &out = std::cout)
const;
125 bool get_is_active()
const;
131 #if !defined(IMP_DOXYGEN)
157 : m_(p->get_model()), pi_(p->get_index()) {}
159 : m_(p->get_model()), pi_(p->get_index()) {}
161 : m_(p->get_model()), pi_(p->get_index()) {}
163 Model *get_model()
const {
return m_; }
172 bool Particle::get_is_optimized(
FloatKey k)
const {
174 return get_model()->get_is_optimized(k, id_);
179 return get_model()->get_derivative(name, id_);
184 return get_model()->get_particle(get_model()->get_attribute(k, id_));
187 #define IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(UCName, lcname, Value) \
188 void Particle::add_attribute(UCName##Key name, Value initial_value) { \
189 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
190 get_model()->add_attribute(name, id_, initial_value); \
192 void Particle::remove_attribute(UCName##Key name) { \
193 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
194 get_model()->remove_attribute(name, id_); \
196 bool Particle::has_attribute(UCName##Key name) const { \
197 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
198 return get_model()->get_has_attribute(name, id_); \
200 Value Particle::get_value(UCName##Key name) const { \
201 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
202 return get_model()->get_attribute(name, id_); \
204 void Particle::set_value(UCName##Key name, Value value) { \
205 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
206 get_model()->set_attribute(name, id_, value); \
208 UCName##Keys Particle::get_##lcname##_keys() const { \
209 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
210 return get_model()->internal::UCName##AttributeTable::get_attribute_keys( \
213 void Particle::add_cache_attribute(UCName##Key name, Value value) { \
214 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
215 return get_model()->add_cache_attribute(name, id_, value); \
218 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
Float,
float,
Float);
219 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
Int,
int,
Int);
220 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
String,
string,
String);
221 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(Object,
object, Object *);
222 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(WeakObject, weak_object, Object *);
226 IMPKERNEL_END_NAMESPACE
virtual ModelObjectsTemp do_get_outputs() const
virtual ModelObjectsTemp do_get_inputs() const
Smart pointer to Object-derived classes that does not refcount.
Various general useful functions for IMP.
#define IMP_FINAL
Have the compiler report an error if anything overrides this method.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Storage of a model, its restraints, constraints and particles.
Keys to cache lookup of attribute strings.
virtual void clear_caches()
A smart pointer to a reference counted object.
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Class for storing model, its restraints, constraints, and particles.
Ints get_index(const ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
Common base class for heavy weight IMP objects.
A smart pointer to a ref-counted Object that is a class member.
Key< 3, true > ParticleIndexKey
The type used to identify a particle attribute in the Particles.
Key< 0, true > FloatKey
The type used to identify float attributes in the Particles.
Single variable function.
A nullptr-initialized pointer to an IMP Object.
Exception definitions and assertions.
A shared base class to help in debugging and things.
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
double Float
Basic floating-point value (could be float, double...)
Class to handle individual model particles.
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
int Int
Basic integer value.
ParticleIndex get_index() const
returns the particle index of this particle in its model
Various general useful functions for IMP.
std::string String
Basic string value.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for adding derivatives from restraints to the model.