IMP  2.1.1
The Integrative Modeling Platform
kernel/TripletContainer.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/TripletContainer.h
3  * \brief A container for Triplets.
4  *
5  * WARNING This file was generated from TripletContainer.h
6  * in /tmp/nightly-build-61576/imp-2.1.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_TRIPLET_CONTAINER_H
13 #define IMPKERNEL_DECLARE_TRIPLET_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 "ParticleTuple.h"
23 #include <IMP/base/check_macros.h>
24 #include <IMP/base/Pointer.h>
25 #include <IMP/base/InputAdaptor.h>
28 #include <algorithm>
29 
30 IMPKERNEL_BEGIN_NAMESPACE
31 class TripletModifier;
32 class TripletScore;
33 
34 //! A shared container for Triplets
35 /** Stores a shared collection of Triplets.
36  */
37 class IMPKERNELEXPORT TripletContainer : public Container {
38  protected:
40  std::string name = "TripletContainer %1%");
41 
42  public:
47 
48  //! Just use apply() in the base class
49  void apply_generic(const TripletModifier *m) const;
50 
51  //! Apply a SingletonModifier to the contents
52  void apply(const TripletModifier *sm) const;
53 
54  /** Get all the indexes contained in the container.*/
55  virtual ParticleIndexTriplets get_indexes() const = 0;
56  /** Get all the indexes that might possibly be contained in the
57  container, useful with dynamic containers. For example,
58  with a container::ClosePairContainer, this is the list
59  of all pairs taken from input list (those that are far apart
60  in addition to those that are close).
61  */
62  virtual ParticleIndexTriplets get_range_indexes() const = 0;
63 
64 #ifndef IMP_DOXYGEN
65  ParticleTripletsTemp get() const {
66  return IMP::kernel::internal::get_particle(get_model(), get_indexes());
67  }
68 
69  ParticleTriplet get(unsigned int i) const {
70  return IMP::kernel::internal::get_particle(get_model(), get_indexes()[i]);
71  }
72  unsigned int get_number() const { return get_indexes().size(); }
73 #ifndef SWIG
74  bool get_provides_access() const;
75  virtual const ParticleIndexTriplets &get_access() const {
76  IMP_THROW("Object not implemented properly.", base::IndexException);
77  }
78 
79  template <class Functor> Functor for_each(Functor f) {
81  // use boost range instead
82  return std::for_each(vs.begin(), vs.end(), f);
83  }
84 
85 #endif
86 #endif
87 
88  /** \deprecated_at{2.1} Use get_indexes() instead.
89  */
90  ParticleTripletsTemp get_particle_triplets() const;
91 
92  /** \brief This function is very slow and you should think hard about using
93  it.
94 
95  \deprecated_at{2.1} This is slow and dependent on the order of elements
96  in the tuple.
97 
98  Return whether the container has the given element.*/
99  IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
100  bool get_contains_particle_triplet(ParticleTriplet v) const;
101 
102  /** \deprecated_at{2.1} This can be very slow and is probably not useful
103  */
104  IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
105  unsigned int get_number_of_particle_triplets() const;
106 
107  /** \deprecated_at{2.1}Use get_indexes() instead and thing about using the
108  IMP_CONTAINER_FOREACH() macro.*/
109  IMPKERNEL_DEPRECATED_METHOD_DECL(2.1)
110  ParticleTriplet get_particle_triplet(unsigned int i) const;
111 
112  protected:
113  virtual void do_apply(const TripletModifier *sm) const = 0;
114  virtual bool do_get_provides_access() const { return false; }
115 
117 };
118 
119 /** This class allows either a list or a container to be
120  accepted as input.
121 */
122 class IMPKERNELEXPORT TripletContainerAdaptor :
123 #if !defined(SWIG) && !defined(IMP_DOXYGEN)
124  public base::Pointer<TripletContainer>
125 #else
126  public base::InputAdaptor
127 #endif
128  {
130 
131  public:
133 
134  /**
135  Constructs the adaptor pointing to c (so if the contents of c are changed
136  dynamically, so do the contents of the adaptor, and vice versa)
137  */
139 
140  /**
141  Constructs the adaptor pointing to c (so if the contents of c are changed
142  dynamically, so do the contents of the adaptor, and vice versa)
143  */
144  template <class C>
145  TripletContainerAdaptor(base::internal::PointerBase<C> c)
146  : P(c) {}
147 
148  /**
149  Adapts the non-empty list t to TripletContainer
150 
151  @param t a non-empty list of ParticleTripletsTemp
152  @param name name for the constructed TripletContainer
153  */
155  std::string name = "TripletContainerAdaptor%1%");
156 };
157 
158 IMPKERNEL_END_NAMESPACE
159 
160 #endif /* IMPKERNEL_DECLARE_TRIPLET_CONTAINER_H */
An exception for a request for an invalid member of a container.
Class for adding derivatives from restraints to the model.
ParticleIndexes get_indexes(const ParticlesTemp &ps)
A shared container for Triplets.
Abstract base class for containers of particles.
A base class for modifiers of ParticleTripletsTemp.
Classes to handle individual model particles.
A nullptr-initialized pointer to an IMP Object.
TripletContainerAdaptor(base::internal::PointerBase< C > c)
IMP::kernel::TripletContainer TripletContainer
A smart pointer to a reference counted object.
Definition: base/Pointer.h:87
IMP::kernel::TripletModifier TripletModifier
Control display of deprecation information.
A class to store an fixed array of same-typed values.
Definition: base/Array.h:33
Abstract class for containers of particles.
Basic types used by IMP.
Various general useful macros for IMP.
#define IMP_REF_COUNTED_NONTRIVIAL_DESTRUCTOR(Name)
Various general useful macros for IMP.
IMP::kernel::TripletScore TripletScore
Classes to handle individual model particles.
#define IMP_THROW(message, exception_name)
Throw an exception with a message.
Exception definitions and assertions.
Class for storing model, its restraints, constraints, and particles.