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(
Int,
int,
Int);
70 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
String,
string,
String);
71 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(
Object,
object,
Object *);
72 IMP_KERNEL_PARTICLE_ATTRIBUTE_TYPE_DECL(WeakObject, weak_object,
Object *);
90 void add_attribute(
FloatKey name,
const Float initial_value,
bool optimized);
102 void set_is_optimized(
FloatKey k,
bool tf);
105 inline bool get_is_optimized(
FloatKey k)
const;
123 void show(std::ostream &out = std::cout)
const;
130 bool get_is_active()
const;
136 #if !defined(IMP_DOXYGEN)
162 : m_(p->get_model()), pi_(p->get_index()) {}
164 : m_(p->get_model()), pi_(p->get_index()) {}
166 : m_(p->get_model()), pi_(p->get_index()) {}
168 Model *get_model()
const {
return m_; }
177 bool Particle::get_is_optimized(
FloatKey k)
const {
179 return get_model()->get_is_optimized(k, id_);
184 return get_model()->get_derivative(k, id_);
189 return get_model()->get_particle(get_model()->get_attribute(k, id_));
192 #define IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(UCName, lcname, Value) \
193 void Particle::add_attribute(UCName##Key name, Value initial_value) { \
194 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
195 get_model()->add_attribute(name, id_, initial_value); \
197 void Particle::remove_attribute(UCName##Key name) { \
198 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
199 get_model()->remove_attribute(name, id_); \
201 bool Particle::has_attribute(UCName##Key name) const { \
202 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
203 return get_model()->get_has_attribute(name, id_); \
205 Value Particle::get_value(UCName##Key name) const { \
206 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
207 return get_model()->get_attribute(name, id_); \
209 void Particle::set_value(UCName##Key name, Value value) { \
210 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
211 get_model()->set_attribute(name, id_, value); \
213 UCName##Keys Particle::get_##lcname##_keys() const { \
214 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
215 return get_model()->internal::UCName##AttributeTable::get_attribute_keys( \
218 void Particle::add_cache_attribute(UCName##Key name, Value value) { \
219 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
220 return get_model()->add_cache_attribute(name, id_, value); \
223 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
Float,
float,
Float);
224 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
Int,
int,
Int);
225 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(
String,
string,
String);
226 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(Object,
object, Object *);
227 IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(WeakObject, weak_object, Object *);
231 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.
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.
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 more IMP-like version of the std::vector.
A smart pointer to a reference counted object.
IMP::Vector< IMP::WeakPointer< ModelObject > > ModelObjectsTemp
Class for storing model, its restraints, constraints, and particles.
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.
Single variable function.
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.
Exception definitions and assertions.
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
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.