/** * \file DiscreteSet.cpp * \brief Holds a discrete sampling space. * * Copyright 2007-2010 IMP Inventors. All rights reserved. */ #include "IMP/domino/DiscreteSet.h" IMPDOMINO_BEGIN_NAMESPACE DiscreteSet::DiscreteSet(FloatKeys atts) { atts_.insert(atts_.begin(),atts.begin(),atts.end()); } void DiscreteSet::add_state(Particle* p) { //check that the particle holds of the necessary attributes //TODO - this loop should probably not be there all of the times // -use IMP_USAGE_CHECK std::stringstream err_msg; for (std::vector::iterator it = atts_.begin(); it != atts_.end(); it++) { err_msg.clear(); err_msg <<"DiscreteSet::add_state The particle does not have the attribute"; it->show(err_msg); IMP_INTERNAL_CHECK(p->has_attribute(*it),err_msg.str()); //p->get_value(*it); } states_.push_back(p); } Particle * DiscreteSet::get_state(long state_ind) const { std::stringstream err_msg; err_msg <<"DiscreteSet::get_state the input state index: " << state_ind; err_msg << " is out of range ( " << states_.size() << " ) " ; IMP_INTERNAL_CHECK(static_cast(state_ind)(state_ind) get_value(key); // if the key does not exist Particle will raise an exception } void DiscreteSet::show(std::ostream& out) const { out<<"DiscreteSet::show number of states : "; out<::const_iterator it2 = atts_.begin(); it2 != atts_.end(); it2++) { out<<*it2<<"|"<<(*it1)->get_value(*it2)<<","; } out<