12 #ifndef IMPKERNEL_SINGLETON_CONTAINER_H
13 #define IMPKERNEL_SINGLETON_CONTAINER_H
15 #include <IMP/kernel_config.h>
16 #include "internal/IndexingIterator.h"
19 #include "internal/container_helpers.h"
30 IMPKERNEL_BEGIN_NAMESPACE
31 class SingletonModifier;
61 if (get_provides_access())
65 if (contents_hash_ != nhash || !cache_initialized_) {
66 contents_hash_ = nhash;
67 cache_initialized_ =
true;
68 get_indexes_in_place(contents_cache_);
70 return contents_cache_;
86 return IMP::internal::get_particle(get_model(),
get_indexes());
89 Particle*
get(
unsigned int i)
const {
90 return IMP::internal::get_particle(get_model(),
get_indexes()[i]);
96 unsigned int get_number()
const {
return get_indexes().size(); }
98 bool get_provides_access()
const;
103 template <
class Functor>
104 Functor for_each(Functor f) {
107 return std::for_each(vs.begin(), vs.end(), f);
121 IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
122 Particle* get_particle(
unsigned int i)
const;
126 std::string name =
"SingletonContainer %1%");
129 virtual bool do_get_provides_access()
const {
return false; }
131 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
143 mutable std::size_t contents_hash_;
145 mutable bool cache_initialized_;
152 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
153 public Pointer<SingletonContainer>
186 void set_name_if_default(std::string name);
189 IMPKERNEL_END_NAMESPACE
A base class for modifiers of ParticlesTemp.
Control display of deprecation information.
Various general useful macros for IMP.
Class for adding derivatives from restraints to the model.
std::size_t get_contents_hash() const
ParticlesTemp get_particles(Model *m, const ParticleIndexes &ps)
A smart pointer to a reference counted object.
Class for storing model, its restraints, constraints, and particles.
Various general useful macros for IMP.
An exception for a request for an invalid member of a container.
A shared container for Singletons.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
Abstract base class for containers of particles.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
A nullptr-initialized pointer to an IMP Object.
Exception definitions and assertions.
Class to handle individual particles of a Model object.
#define IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(Name)
SingletonContainerAdaptor(IMP::internal::PointerBase< C > c)
ParticleIndexes get_indexes(const ParticlesTemp &ps)
Abstract class for containers of particles.