8 #ifndef IMPKERNEL_DECORATOR_H
9 #define IMPKERNEL_DECORATOR_H
11 #include <IMP/kernel/kernel_config.h>
18 #include "internal/utility.h"
23 IMPKERNEL_BEGIN_NAMESPACE
24 class ParticleAdaptor;
119 if (o < get_particle())
121 else if (o > get_particle())
142 bool __eq__(
base::Object* o)
const {
return operator==(o); }
143 bool __ne__(
base::Object* o)
const {
return operator!=(o); }
144 bool __lt__(
base::Object* o)
const {
return operator<(o); }
145 bool __gt__(
base::Object* o)
const {
return operator>(o); }
146 bool __ge__(
base::Object* o)
const {
return operator>=(o); }
147 bool __le__(
base::Object* o)
const {
return operator<=(o); }
177 "Particle " << pi_ <<
" is no longer part of the model.");
178 return model_->get_particle(pi_);
182 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
183 operator Particle*()
const {
return get_particle(); }
184 Particle* operator->()
const {
return get_particle(); }
185 operator ParticleIndex()
const {
return get_particle_index(); }
226 static bool get_is_setup(
Particle* p);
240 #if !defined(IMP_DOXYGEN) && !defined(SWIG)
241 typedef boost::false_type DecoratorHasTraits;
248 : model_(m), pi_(pi) {};
249 inline Decorator::Decorator() : pi_(-1) {}
251 #define IMP_CONSTRAINT_DECORATOR_DECL(Name) \
253 static ObjectKey get_constraint_key(); \
254 static void set_constraint(SingletonModifier* before, \
255 SingletonDerivativeModifier* after, Model* m, \
259 Constraint* get_constraint() const { \
260 return dynamic_cast<Constraint*>( \
261 get_particle()->get_value(get_constraint_key())); \
263 IMP_REQUIRE_SEMICOLON_CLASS(constraint)
265 #define IMP_CONSTRAINT_DECORATOR_DEF(Name) \
266 ObjectKey Name::get_constraint_key() { \
267 static ObjectKey ret(#Name " score state"); \
270 void Name::set_constraint(SingletonModifier* before, \
271 SingletonDerivativeModifier* after, Model* m, \
272 ParticleIndex pi) { \
273 if (!after && !before) { \
274 if (m->get_has_attribute(get_constraint_key(), pi)) { \
275 m->remove_score_state(dynamic_cast<ScoreState*>( \
276 m->get_attribute(get_constraint_key(), pi))); \
277 m->remove_attribute(get_constraint_key(), pi); \
280 Constraint* ss = new core::SingletonConstraint( \
281 before, after, m, pi, \
282 std::string(#Name "updater for ") + m->get_particle_name(pi)); \
283 m->add_attribute(get_constraint_key(), pi, ss); \
284 m->add_score_state(ss); \
287 IMP_REQUIRE_SEMICOLON_NAMESPACE
299 #define IMP_CHECK_DECORATOR(Name, function) \
300 IMP::kernel::internal::ParticleCheck Name##pc(Name::get_is_setup, function);
306 IMPKERNELEXPORT
void check_particle(
Particle* p);
309 IMPKERNEL_END_NAMESPACE
311 #if !defined(SWIG) && !defined IMP_DOXYGEN
312 IMPKERNEL_BEGIN_INTERNAL_NAMESPACE
314 return base::internal::unref(static_cast<Particle*>(d));
317 return base::internal::release(static_cast<Particle*>(d));
320 return base::internal::ref(static_cast<Particle*>(d));
323 IMPKERNEL_END_INTERNAL_NAMESPACE
Particle * get_particle() const
Model * get_model() const
Returns the Model containing the particle.
#define IMP_HASHABLE_INLINE(name, hashret)
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
#define IMP_ONLY_DOXYGEN(x)
Only show something to doxygen.
int compare(const VectorD< D > &a, const VectorD< D > &b)
lexicographic comparison of two vectors
A class for storing lists of IMP items.
Various general useful macros for IMP.
Class to handle individual model particles.
Storage of a model, its restraints, constraints and particles.
Common base class for heavy weight IMP objects.
A base class for constraints.
A nullptr-initialized pointer to an Object.
IMP::kernel::Particle Particle
For backwards compatibility.
A shared base class to help in debugging and things.
IMP::kernel::Decorator Decorator
IMP::kernel::ParticleIndex ParticleIndex
Class for storing model, its restraints, constraints, and particles.