IMP  2.0.1
The Integrative Modeling Platform
kernel/declare_QuadContainer.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/declare_QuadContainer.h
3  * \brief A container for Quads.
4  *
5  * WARNING This file was generated from declare_QuadContainer.h
6  * in /tmp/nightly-build-36540/imp-2.0.1/tools/build/container_templates/kernel
7  * by tools/maintenance/setup_containers.py.
8  *
9  * Copyright 2007-2013 IMP Inventors. All rights reserved.
10  */
11 
12 #ifndef IMPKERNEL_DECLARE_QUAD_CONTAINER_H
13 #define IMPKERNEL_DECLARE_QUAD_CONTAINER_H
14 
15 #include <IMP/kernel/kernel_config.h>
16 #include "internal/IndexingIterator.h"
17 #include "declare_Particle.h"
18 #include "container_base.h"
19 #include "internal/container_helpers.h"
20 #include "DerivativeAccumulator.h"
21 #include "internal/OwnerPointer.h"
22 #include "ParticleTuple.h"
24 #include <IMP/base/check_macros.h>
25 #include <IMP/base/Pointer.h>
26 #include <IMP/base/InputAdaptor.h>
29 #include <algorithm>
30 
31 
32 IMPKERNEL_BEGIN_NAMESPACE
33 class QuadModifier;
34 class QuadScore;
35 
36 //! A shared container for Quads
37 /** Stores a searchable shared collection of Quads.
38  \headerfile QuadContainer.h "IMP/kernel/QuadContainer.h"
39  \implementationwithoutexample{QuadContainer, IMP_QUAD_CONTAINER}
40  */
41 class IMPKERNELEXPORT QuadContainer : public Container
42 {
43 protected:
45  std::string name="QuadContainer %1%");
46 public:
51 
52  //! Just use apply() in the base class
53  void apply_generic(const QuadModifier *m) const;
54 
55  //! Apply a SingletonModifier to the contents
56  void apply(const QuadModifier *sm) const;
57 
58  /** Get all the indexes contained in the container.*/
59  virtual ParticleIndexQuads get_indexes() const=0;
60  /** Get all the indexes that might possibly be contained in the
61  container, useful with dynamic containers. For example,
62  with a container::ClosePairContainer, this is the list
63  of all pairs taken from input list (those that are far apart
64  in addition to those that are close).
65  */
66  virtual ParticleIndexQuads get_range_indexes() const=0;
67 
68 #ifndef IMP_DOXYGEN
69  ParticleQuadsTemp get() const {
70  return IMP::kernel::internal::get_particle(get_model(),
71  get_indexes());
72  }
73 
74  ParticleQuad get(unsigned int i) const {
75  return IMP::kernel::internal::get_particle(get_model(),
76  get_indexes()[i]);
77  }
78  unsigned int get_number() const {return get_indexes().size();}
79 #ifndef SWIG
80  bool get_provides_access() const;
81  virtual const ParticleIndexQuads& get_access() const {
82  IMP_THROW("Object not implemented properly.", base::IndexException);
83  }
84 
85 
86  template <class Functor>
87  Functor for_each(Functor f) {
89  // use boost range instead
90  return std::for_each(vs.begin(), vs.end(), f);
91  }
92 
93 #endif
94 #endif
95 
96  /** Use this for debugging only.
97  */
98  ParticleQuadsTemp get_particle_quads() const;
99 
100 #if IMP_HAS_DEPRECATED
101  /** \brief This function is very slow and you should think hard about using
102  it.
103 
104  \deprecated This is slow and dependent on the order of elements in the
105  tuple.
106 
107  Return whether the container has the given element.*/
109  bool get_contains_particle_quad(ParticleQuad v) const;
110 
111  /** \deprecated This can be very slow and is probably not useful
112  */
113  IMP_DEPRECATED_WARN unsigned int get_number_of_particle_quads() const;
114 
115  /** \deprecated Use indexes instead and thing about using the
116  IMP_CONTAINER_FOREACH() macro.*/
118  get_particle_quad(unsigned int i) const;
119 
120 #endif
121 protected:
122  virtual void do_apply(const QuadModifier *sm) const=0;
123  virtual bool do_get_provides_access() const {return false;}
124 
126 };
127 
128 
129 /** This class allows either a list or a container to be
130  accepted as input.
131 */
132 class IMPKERNELEXPORT QuadContainerAdaptor:
133 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
134 public base::Pointer<QuadContainer>
135 #else
136 public base::InputAdaptor
137 #endif
138 {
140  public:
143  template <class C>
144  QuadContainerAdaptor(base::internal::PointerBase<C> c): P(c){}
146  std::string name="QuadContainerAdaptor%1%");
147 };
148 
149 
150 IMPKERNEL_END_NAMESPACE
151 
152 #endif /* IMPKERNEL_DECLARE_QUAD_CONTAINER_H */