10 #ifndef IMPKERNEL_PARTICLE_H
11 #define IMPKERNEL_PARTICLE_H
13 #include <IMP/kernel_config.h>
20 #include "internal/AttributeTable.h"
27 IMPKERNEL_BEGIN_NAMESPACE
59 #define IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(UCName, lcname, Value) \
60 inline void add_attribute(UCName##Key name, Value initial_value); \
61 inline void remove_attribute(UCName##Key name); \
62 inline bool has_attribute(UCName##Key name) const; \
63 inline Value get_value(UCName##Key name) const; \
64 inline void set_value(UCName##Key name, Value value); \
65 inline void add_cache_attribute(UCName##Key name, Value value); \
66 inline UCName##Keys get_##lcname##_keys() const
68 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Float,
float,
Float);
69 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Floats, floats,
Floats);
70 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Int,
int,
Int);
71 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Ints, ints,
Ints);
72 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
String,
string,
String);
73 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Object,
object,
Object *);
74 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(WeakObject, weak_object,
Object *);
92 void add_attribute(
FloatKey name,
const Float initial_value,
bool optimized);
104 void set_is_optimized(
FloatKey k,
bool tf);
107 inline bool get_is_optimized(
FloatKey k)
const;
125 void show(std::ostream &out = std::cout)
const;
132 bool get_is_active()
const;
138 #if !defined(IMP_DOXYGEN)
164 : m_(p->get_model()), pi_(p->get_index()) {}
166 : m_(p->get_model()), pi_(p->get_index()) {}
168 : m_(p->get_model()), pi_(p->get_index()) {}
170 Model *get_model()
const {
return m_; }
179 bool Particle::get_is_optimized(
FloatKey k)
const {
181 return get_model()->get_is_optimized(k, id_);
186 return get_model()->get_derivative(k, id_);
191 return get_model()->get_particle(get_model()->get_attribute(k, id_));
194 #define IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(UCName, lcname, Value) \
195 void Particle::add_attribute(UCName##Key name, Value initial_value) { \
196 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
197 get_model()->add_attribute(name, id_, initial_value); \
199 void Particle::remove_attribute(UCName##Key name) { \
200 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
201 get_model()->remove_attribute(name, id_); \
203 bool Particle::has_attribute(UCName##Key name) const { \
204 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
205 return get_model()->get_has_attribute(name, id_); \
207 Value Particle::get_value(UCName##Key name) const { \
208 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
209 return get_model()->get_attribute(name, id_); \
211 void Particle::set_value(UCName##Key name, Value value) { \
212 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
213 get_model()->set_attribute(name, id_, value); \
215 UCName##Keys Particle::get_##lcname##_keys() const { \
216 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
217 return get_model()->internal::UCName##AttributeTable::get_attribute_keys( \
220 void Particle::add_cache_attribute(UCName##Key name, Value value) { \
221 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
222 return get_model()->add_cache_attribute(name, id_, value); \
225 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
Float,
float,
Float);
226 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
Floats, floats,
Floats);
227 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
Int,
int,
Int);
228 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
Ints, ints,
Ints);
229 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
String,
string,
String);
230 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(Object,
object, Object *);
231 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(WeakObject, weak_object, Object *);
235 IMPKERNEL_END_NAMESPACE
virtual ModelObjectsTemp do_get_outputs() const
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
virtual ModelObjectsTemp do_get_inputs() const
Smart pointer to Object-derived classes that does not refcount.
Functions and adaptors for dealing with particle indexes.
#define IMP_FINAL
Have the compiler report an error if anything overrides this method.
IMP::Vector< Float > Floats
Standard way to pass a bunch of Float values.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Class for adding derivatives from restraints to the model.
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.
Base class for objects in a Model that depend on other objects.
Key< 3 > ParticleIndexKey
The type used to identify a particle attribute in the 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.
Base class for objects in a Model that depend on other objects.
Interface to specialized Particle types (e.g. atoms)
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
A nullptr-initialized pointer to an IMP Object.
Helper macros for throwing and handling exceptions.
A shared base class to help in debugging and things.
double Float
Basic floating-point value (could be float, double...)
Class to handle individual particles of a Model object.
#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
IMP::Vector< Int > Ints
Standard way to pass a bunch of Int values.
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.