10 #ifndef IMPKERNEL_PARTICLE_H
11 #define IMPKERNEL_PARTICLE_H
13 #include <IMP/kernel/kernel_config.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, base::Object *);
222 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(WeakObject, weak_object, base::Object *);
226 IMPKERNEL_END_NAMESPACE
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
ParticleIndex get_index() const
returns the particle index of this particle in its model
#define IMP_FINAL
Have the compiler report an error if anything overrides this method.
A smart pointer to a ref-counted Object that is a class member.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
virtual ModelObjectsTemp do_get_outputs() const
A smart pointer to a reference counted object.
virtual void clear_caches()
virtual ModelObjectsTemp do_get_inputs() const
Single variable function.
Key< 3, true > ParticleIndexKey
The type used to identify a particle attribute in the Particles.
Various general useful functions for IMP.
Class to handle individual model particles.
Storage of a model, its restraints, constraints and particles.
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.
IMP::kernel::Particle Particle
double Float
Basic floating-point value (could be float, double...)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
int Int
Basic integer value.
Keys to cache lookup of attribute strings.
std::string String
Basic string value.
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Class for storing model, its restraints, constraints, and particles.