IMP logo
IMP Reference Guide  2.22.0
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  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCONTAINER_ALL_PAIR_CONTAINER_H
9 #define IMPCONTAINER_ALL_PAIR_CONTAINER_H
10 
11 #include <IMP/container/container_config.h>
12 #include <IMP/generic.h>
13 #include <IMP/PairContainer.h>
14 #include <IMP/SingletonContainer.h>
16 #include <IMP/Pointer.h>
17 #include <IMP/pair_macros.h>
18 IMPCONTAINER_BEGIN_NAMESPACE
19 
20 //! Return all unordered pairs of particles taken from the SingletonContainer
21 /* \see AllBipartitePairContainer, ClosePairContainer,
22  CloseBipartitePairContainer for variants on the functionality provided.
23  */
24 class IMPCONTAINEREXPORT AllPairContainer : public PairContainer {
26 
27  protected:
28  virtual std::size_t do_get_contents_hash() const override {
29  return c_->get_contents_hash();
30  }
31 
32  public:
33  template <class F>
34  void apply_generic(F* f) const {
35  validate_readable();
36  const ParticleIndexes& pis = c_->get_contents();
37  for (unsigned int i = 0; i < pis.size(); ++i) {
38  for (unsigned int j = 0; j < i; ++j) {
39  f->apply_index(get_model(), ParticleIndexPair(pis[i], pis[j]));
40  }
41  }
42  }
43  //! Get the individual particles from the passed SingletonContainer
45  std::string name = "AllPairContainer%1%");
46  virtual ParticleIndexPairs get_indexes() const override;
47  virtual ParticleIndexPairs get_range_indexes() const override;
48  virtual ModelObjectsTemp do_get_inputs() const override;
49  virtual ParticleIndexes get_all_possible_indexes() const override;
52 };
53 
55 
56 IMPCONTAINER_END_NAMESPACE
57 
58 #endif /* IMPCONTAINER_ALL_PAIR_CONTAINER_H */
virtual ParticleIndexPairs get_range_indexes() const =0
A shared container for Pairs.
Definition: PairContainer.h:39
Macros for various classes.
A container for Singletons.
void apply_generic(const PairModifier *m) const
Just use apply() in the base class.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Return all unordered pairs of particles taken from the SingletonContainer.
#define IMP_PAIR_CONTAINER_METHODS(Name)
Definition: pair_macros.h:154
A container for Pairs.
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:143
Store a list of ParticleIndexPairs.
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
A nullptr-initialized pointer to an IMP Object.
virtual ParticleIndexes get_all_possible_indexes() const =0
Get contained particles.
virtual ParticleIndexPairs get_indexes() const =0
virtual ModelObjectsTemp do_get_inputs() const =0
Compile-time generic restraint and constraint support.