9 #ifndef IMPKERNEL_SCOPED_H
10 #define IMPKERNEL_SCOPED_H
12 #include <IMP/kernel/kernel_config.h>
24 IMPKERNEL_BEGIN_NAMESPACE
38 m->add_score_state(ss);
41 if (ss_ && ss_->get_model()) {
44 ss_->get_model()->remove_score_state(ss_);
50 out <<
"(Scoped " << ss_->get_name() <<
")";
52 out <<
"(Unset scoped score state)";
54 bool get_is_set()
const {
return ss_; }
56 const SS* operator->()
const {
return ss_; }
57 const SS&
operator*()
const {
return *ss_; }
58 SS* operator->() {
return ss_; }
81 rs_->add_restraint(ss);
84 if (ss_ && ss_->get_model()) {
87 rs_->remove_restraint(ss_);
94 out <<
"(Scoped " << ss_->get_name() <<
")";
96 out <<
"(Unset scoped restraint)";
98 bool get_is_set()
const {
return ss_; }
100 const SS* operator->()
const {
return ss_; }
101 const SS&
operator*()
const {
return *ss_; }
102 SS* operator->() {
return ss_; }
118 if (rs_ && rs_->get_model()) {
120 << rs_->get_name() << std::endl);
123 rs_->add_restraint(ss_);
134 rs_->remove_restraint(ss);
136 << rs_->get_name() << std::endl);
142 {}, { setup(ss, rs); }, { cleanup(); }, {
144 out <<
"(Scoped removal of " << ss_->get_name() <<
")";
146 out <<
"(Unset scoped restraint)";
148 bool get_is_set()
const {
return ss_; }
150 const SS* operator->()
const {
return ss_; }
151 const SS&
operator*()
const {
return *ss_; }
152 SS* operator->() {
return ss_; }
166 << rs_->get_name() << std::endl);
169 rs_->add_score_state(ss_);
177 rs_->remove_score_state(ss);
179 << rs_->get_name() << std::endl);
186 IMPKERNEL_DEPRECATED_VALUE_DEF(
187 2.1,
"This doesn't do anything any more");
192 out <<
"(Scoped removal of " << ss_->get_name() <<
")";
194 out <<
"(Unset scoped restraint)";
196 bool get_is_set()
const {
return ss_; }
198 const SS* operator->()
const {
return ss_; }
199 const SS&
operator*()
const {
return *ss_; }
200 SS* operator->() {
return ss_; }
217 template <
class Key,
class Value>
225 { pi_ = base::get_invalid_index<ParticleIndexTag>(); },
228 pi_ = p->get_index();
230 m_->add_cache_attribute(key_, pi_, value);
233 if (pi_ != base::get_invalid_index<ParticleIndexTag>()) {
234 m_->remove_attribute(key_, pi_);
242 template <
class Key,
class Value>
251 { pi_ = base::get_invalid_index<ParticleIndexTag>(); },
254 pi_ = p->get_index();
256 old_ = m_->get_attribute(key_, pi_);
257 m_->set_attribute(key_, pi_, value);
260 if (pi_ != base::get_invalid_index<ParticleIndexTag>()) {
261 m_->set_attribute(key_, pi_, old_);
268 IMPKERNEL_END_NAMESPACE
A nullptr-initialized pointer to an IMP Object.
IMP::kernel::ScopedSetFloatAttribute ScopedSetFloatAttribute
Object used to hold a set of restraints.
IMP::kernel::ScopedRemoveRestraint ScopedRemoveRestraint
#define IMP_DEPRECATED_RAII(version, help_message, MODULE, Name, args,Initialize, Set, Reset, Show)
ScoreStates maintian invariants in the Model.
Removes the Restraint when the RAII object is destroyed.
Control display of deprecation information.
Removes the Restraint until RAII object is destroyed.
Various general useful macros for IMP.
VectorD< D > operator*(double s, const VectorD< D > &o)
IMP::kernel::ScopedRemoveScoreState ScopedRemoveScoreState
Control display of deprecation information.
#define IMP_CHECK_OBJECT(obj)
Perform some basic validity checks on the object for memory debugging.
Logging and error reporting support.
A restraint is a term in an IMP ScoringFunction.
Used to hold a set of related restraints.
Class to handle individual model particles.
Storage of a model, its restraints, constraints and particles.
#define IMP_RAII(Name, args, Initialize, Set, Reset, Show)
Declares RAII-style methods in a class.
Exception definitions and assertions.
IMP::kernel::ScopedRestraint ScopedRestraint
IMP::kernel::ScopedScoreState ScopedScoreState
#define IMP_LOG_VERBOSE(expr)
Class for storing model, its restraints, constraints, and particles.