00001 /** 00002 * \file SingletonsConstraint.h 00003 * \brief Use a SingletonModifier applied to a Particles to 00004 * maintain an invariant 00005 * 00006 * This file is generated by a script (core/tools/make-container). 00007 * Do not edit directly. 00008 * 00009 * Copyright 2007-2010 IMP Inventors. All rights reserved. 00010 */ 00011 00012 #ifndef IMPCONTAINER_SINGLETONS_CONSTRAINT_H 00013 #define IMPCONTAINER_SINGLETONS_CONSTRAINT_H 00014 00015 #include "container_config.h" 00016 #include <IMP/SingletonContainer.h> 00017 #include <IMP/SingletonModifier.h> 00018 #include <IMP/Constraint.h> 00019 00020 IMP_BEGIN_NAMESPACE 00021 // for swig 00022 class SingletonContainer; 00023 class SingletonModifier; 00024 IMP_END_NAMESPACE 00025 00026 IMPCONTAINER_BEGIN_NAMESPACE 00027 //! Apply a SingletonFunction to a SingletonContainer to maintain an invariant 00028 /** The score state is passed up to two SingletonModifiers, one to 00029 apply before evaluation and the other after. The one after 00030 should take a DerivativeAccumulator as its last argument for 00031 SingletonModifier::apply() and will only be called if 00032 the score was computed with derivatives. 00033 00034 An example showing a how to use such a score state to maintain a cover 00035 of the atoms of a protein by a sphere per residue. 00036 \verbinclude cover_particles.py 00037 00038 \see SingletonConstraint 00039 */ 00040 class IMPCONTAINEREXPORT SingletonsConstraint : public Constraint 00041 { 00042 IMP::internal::OwnerPointer<SingletonModifier> f_; 00043 IMP::internal::OwnerPointer<SingletonModifier> af_; 00044 IMP::internal::OwnerPointer<SingletonContainer> c_; 00045 public: 00046 /** \param[in] c The Container to hold the elements to process 00047 \param[in] before The SingletonModifier to apply to all elements 00048 before evaluate. 00049 \param[in] after The SingletonModifier to apply to all elements 00050 after evaluate. 00051 \param[in] name The object name 00052 */ 00053 SingletonsConstraint(SingletonContainer *c, SingletonModifier *before, 00054 SingletonModifier *after, 00055 std::string name="SingletonConstraint %1%"); 00056 00057 //! Apply this modifier to all the elements after an evaluate 00058 void set_after_evaluate_modifier(SingletonModifier* f) { 00059 af_=f; 00060 } 00061 00062 //! Apply this modifier to all the elements before an evaluate 00063 void set_before_evaluate_modifier(SingletonModifier* f) { 00064 f_=f; 00065 } 00066 00067 IMP_CONSTRAINT(SingletonsConstraint); 00068 }; 00069 00070 00071 IMPCONTAINER_END_NAMESPACE 00072 00073 #endif /* IMPCONTAINER_SINGLETONS_CONSTRAINT_H */