IMP logo
IMP Reference Guide  develop.d97d4ead1f,2024/11/21
The Integrative Modeling Platform
AllBipartitePairContainer.h
Go to the documentation of this file.
1 /**
2  * \file IMP/container/AllBipartitePairContainer.h
3  * \brief Return all bipartite pairs between two containers
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPCONTAINER_ALL_BIPARTITE_PAIR_CONTAINER_H
9 #define IMPCONTAINER_ALL_BIPARTITE_PAIR_CONTAINER_H
10 
11 #include <IMP/container/container_config.h>
12 
13 #include <IMP/PairContainer.h>
14 #include <IMP/SingletonContainer.h>
17 #include <IMP/pair_macros.h>
18 #include <IMP/singleton_macros.h>
19 #include <boost/functional/hash/hash.hpp>
20 
21 IMPCONTAINER_BEGIN_NAMESPACE
22 
23 //! Return all bipartite pairs (a,b) for all a in container A
24 //! and b in container B
25 /** \see AllPairContainer, ClosePairContainer,
26  CloseBipartitePairContainer for variants on the functionality provided.
27  */
28 class IMPCONTAINEREXPORT AllBipartitePairContainer : public PairContainer {
30 
31  protected:
32  virtual std::size_t do_get_contents_hash() const override {
33  std::size_t ret = a_->get_contents_hash();
34  boost::hash_combine(ret, b_->get_contents_hash());
35  return ret;
36  }
37 
38  public:
39  template <class F>
40  void apply_generic(F* f) const {
41  // Note: currently assumes putting all pairs in memory is
42  // feasible+reasonable but this could be easily made in chunks if
43  // needed.
44  validate_readable();
45  ParticleIndexPairs pips;
46  for(ParticleIndex pa : a_->get_contents()) {
47  for(ParticleIndex pb : b_->get_contents()) {
48  pips.push_back(ParticleIndexPair(pa, pb));
49  }
50  }
51  f->apply_indexes(get_model(), pips,
52  0, pips.size());
53  }
56  std::string name = "AllBipartitePairContainer%1%");
57  virtual ParticleIndexPairs get_indexes() const override;
58  virtual ParticleIndexPairs get_range_indexes() const override;
59  virtual ModelObjectsTemp do_get_inputs() const override;
60  virtual ParticleIndexes get_all_possible_indexes() const override;
63 };
64 
66 
67 IMPCONTAINER_END_NAMESPACE
68 
69 #endif /* IMPCONTAINER_ALL_BIPARTITE_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
Store a set of PairContainers.
Macros for various classes.
#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
virtual ParticleIndexes get_all_possible_indexes() const =0
Get contained particles.
virtual ParticleIndexPairs get_indexes() const =0
virtual ModelObjectsTemp do_get_inputs() const =0