9 #ifndef IMPKERNEL_DECLARE_PARTICLE_H
10 #define IMPKERNEL_DECLARE_PARTICLE_H
12 #include <IMP/kernel/kernel_config.h>
17 #include "internal/AttributeTable.h"
25 #define IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(UCName, lcname, Value) \
26 void add_attribute(UCName##Key name, Value initial_value); \
27 void remove_attribute(UCName##Key name); \
28 bool has_attribute(UCName##Key name) const; \
29 Value get_value(UCName##Key name) const; \
30 void set_value(UCName##Key name, Value value); \
31 void add_cache_attribute(UCName##Key name, Value value); \
32 UCName##Keys get_##lcname##_keys() const
35 #define IMP_PARTICLE_ATTRIBUTE_TYPE_DEF(UCName, lcname, Value) \
36 inline void Particle::add_attribute(UCName##Key name, Value initial_value){ \
37 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
38 get_model()->add_attribute(name, id_, initial_value); \
40 inline void Particle::remove_attribute(UCName##Key name) { \
41 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
42 get_model()->remove_attribute(name, id_); \
44 inline bool Particle::has_attribute(UCName##Key name) const{ \
45 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
46 return get_model()->get_has_attribute(name, id_); \
48 inline Value Particle::get_value(UCName##Key name) const { \
49 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
50 return get_model()->get_attribute(name, id_); \
52 inline void Particle::set_value(UCName##Key name, Value value) { \
53 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
54 get_model()->set_attribute(name, id_, value); \
56 inline UCName##Keys Particle::get_##lcname##_keys() const { \
57 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
58 return get_model()->internal::UCName##AttributeTable \
59 ::get_attribute_keys(id_); \
61 inline void Particle::add_cache_attribute(UCName##Key name, \
63 IMP_USAGE_CHECK(get_is_active(), "Inactive particle used."); \
64 return get_model()->add_cache_attribute(name, id_, value); \
69 IMPKERNEL_BEGIN_NAMESPACE
97 IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(
Float,
float,
Float);
98 IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(
Int,
int,
Int);
99 IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(
String,
string,
String);
100 IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(Object,
object, Object*);
101 IMP_PARTICLE_ATTRIBUTE_TYPE_DECL(WeakObject, weak_object, Object*);
114 void add_attribute(
FloatKey name,
const Float initial_value,
bool optimized);
119 void set_is_optimized(
FloatKey k,
bool tf);
121 bool get_is_optimized(
FloatKey k)
const;
142 bool get_is_active()
const;
146 #if !defined(IMP_DOXYGEN)&& !defined(SWIG)
147 void *
operator new(std::size_t sz,
void*p);
148 void operator delete(
void *p);
149 void *
operator new(std::size_t sz);
155 #if !defined(IMP_DOXYGEN)
168 IMPKERNEL_END_NAMESPACE