9#ifndef IMPKERNEL_SCOPED_H
10#define IMPKERNEL_SCOPED_H
12#include <IMP/kernel_config.h>
24IMPKERNEL_BEGIN_NAMESPACE
29template <
class Key,
class Value>
30class ScopedAddCacheAttribute :
public RAII {
37 { pi_ = get_invalid_index<ParticleIndexTag>(); },
42 m_->add_cache_attribute(key_, pi_, value);
45 if (pi_ != get_invalid_index<ParticleIndexTag>()) {
46 m_->remove_attribute(key_, pi_);
54template <
class Key,
class Value>
55class ScopedSetAttribute :
public RAII {
63 { pi_ = get_invalid_index<ParticleIndexTag>(); },
68 old_ = m_->get_attribute(key_, pi_);
69 m_->set_attribute(key_, pi_, value);
72 if (pi_ != get_invalid_index<ParticleIndexTag>()) {
73 m_->set_attribute(key_, pi_, old_);
74 pi_ = get_invalid_index<ParticleIndexTag>();
79typedef ScopedSetAttribute<FloatKey, Float> ScopedSetFloatAttribute;
81IMPKERNEL_END_NAMESPACE
Storage of a model, its restraints, constraints and particles.
A nullptr-initialized pointer to an IMP Object.
Temporarily change something; undo the change when object destroyed.
Used to hold a set of related restraints.
Helper macros for throwing and handling exceptions.
Class to handle individual particles of a Model object.
Base class for a simple primitive-like type.
Control display of deprecation information.
Control display of deprecation information.
Logging and error reporting support.
Index< ParticleIndexTag > ParticleIndex
Macros to aid in writing RAII-style classes.
#define IMP_RAII(Name, args, Initialize, Set, Reset, Show)
Declares RAII-style methods in a class.
A smart pointer to a reference counted object.