IMP  2.0.1
The Integrative Modeling Platform
AllPairContainer.h
Go to the documentation of this file.
1 /**
2  * \file IMP/container/AllPairContainer.h
3  * \brief Return all pairs from a SingletonContainer
4  *
5  * This file is generated by a script (core/tools/make-container).
6  * Do not edit directly.
7  *
8  * Copyright 2007-2013 IMP Inventors. All rights reserved.
9  */
10 
11 #ifndef IMPCONTAINER_ALL_PAIR_CONTAINER_H
12 #define IMPCONTAINER_ALL_PAIR_CONTAINER_H
13 
14 #include <IMP/container/container_config.h>
15 #include <IMP/generic.h>
16 #include <IMP/PairContainer.h>
17 #include <IMP/SingletonContainer.h>
19 #include <IMP/base/Pointer.h>
20 #include <IMP/pair_macros.h>
21 IMPCONTAINER_BEGIN_NAMESPACE
22 
23 //! Return all unordered pairs of particles taken from the SingletonContainer
24 /** Here is an example using this container to restrain all particles in a set
25  to be within a a certain distance of one another.
26  \verbinclude restrain_diameter.py
27 
28  \note Sequential access is much more efficient than random access which is
29  suicidally slow for now. Complain if you want fast(er) random access.
30  We might listen.
31 
32  \usesconstraint
33  */
34 class IMPCONTAINEREXPORT AllPairContainer : public PairContainer
35 {
37  friend class AllBipartitePairContainer;
38 public:
39  template <class F>
40  void apply_generic(F* f) const {
41  validate_readable();
42  ParticleIndexes pis= c_->get_indexes();
43  for (unsigned int i=0; i< pis.size(); ++i) {
44  for (unsigned int j=0; j< i; ++j) {
45  f->apply_index(get_model(), ParticleIndexPair(pis[i], pis[j]));
46  }
47  }
48  }
49  //! Get the individual particles from the passed SingletonContainer
50  AllPairContainer(SingletonContainerAdaptor c,
51  std::string name="AllPairContainer%1%");
52 
54 };
55 
57 
58 IMPCONTAINER_END_NAMESPACE
59 
60 #endif /* IMPCONTAINER_ALL_PAIR_CONTAINER_H */