/** * \file MovedSingletonContainer.cpp * \brief Keep track of the maximumimum change of a set of attributes. * * Copyright 2007-2010 IMP Inventors. All rights reserved. */ #include #include #include #include #include #include #include #include #include #include #include IMPCORE_BEGIN_INTERNAL_NAMESPACE namespace { internal::CoreListSingletonContainer* get_list(SingletonContainer *g) { return dynamic_cast(g); } } MovedSingletonContainer::MovedSingletonContainer(Model *m, SingletonContainer *pc, double threshold): internal::ListLikeSingletonContainer(m, "MovedSingletonContainer"), threshold_(threshold), pc_(pc) { initialize_active_container(m); first_call_=true; } void MovedSingletonContainer::do_show(std::ostream &) const { } void MovedSingletonContainer::do_after_evaluate() { internal::ListLikeSingletonContainer::do_after_evaluate(); } void MovedSingletonContainer::do_before_evaluate() { IMP_CHECK_OBJECT(pc_); if (first_call_) { first_call_=false; reset(); ParticlesTemp t=pc_->get_particles(); update_list(t); } if (pc_->get_added_container()->get_number_of_particles() != 0 || pc_->get_removed_container()->get_number_of_particles() != 0) { reset(); ParticlesTemp t=pc_->get_particles(); update_list(t); } else { update_list(); } } ParticlesTemp MovedSingletonContainer::get_state_input_particles() const { return pc_->get_particles(); } ContainersTemp MovedSingletonContainer::get_state_input_containers() const { return ContainersTemp(1, pc_); } void MovedSingletonContainer::reset() { save(); ParticlesTemp t; update_list(t); first_call_=false; } void MovedSingletonContainer::reset_moved() { save_moved(); ParticlesTemp t; update_list(t); } void MovedSingletonContainer::set_threshold(double d) { threshold_= d; // could be more efficient, but why bother reset(); } IMP_ACTIVE_CONTAINER_DEF(MovedSingletonContainer); IMPCORE_END_INTERNAL_NAMESPACE