IMP logo
IMP Reference Guide  2.11.0
The Integrative Modeling Platform
pair_macros.h
Go to the documentation of this file.
1 // Autogenerated by ../../../../tmp/nightly-build-82993/imp-2.11.0/tools/build/make_containers.py
2 // from ../../../../tmp/nightly-build-82993/imp-2.11.0/tools/build/container_templates/kernel/classname_macros.h
3 // Do not edit - any changes will be lost!
4 
5 /**
6  * \file IMP/pair_macros.h
7  * \brief Macros for various classes.
8  *
9  * Copyright 2007-2019 IMP Inventors. All rights reserved.
10  */
11 
12 #ifndef IMPKERNEL_PAIR_MACROS_H
13 #define IMPKERNEL_PAIR_MACROS_H
14 
15 #include "internal/TupleRestraint.h"
16 #include "internal/functors.h"
17 #include "container_macros.h"
18 #include <IMP/object_macros.h>
19 #include <algorithm>
20 
21 /** Define
22  - IMP::PairScore::evaluate_indexes()
23  - IMP::PairScore::evaluate_if_good_indexes()
24  */
25 #define IMP_PAIR_SCORE_METHODS(Name) \
26  double evaluate_indexes(Model *m, const ParticleIndexPairs &p, \
27  DerivativeAccumulator *da, unsigned int lower_bound, \
28  unsigned int upper_bound) const IMP_FINAL { \
29  double ret = 0; \
30  for (unsigned int i = lower_bound; i < upper_bound; ++i) { \
31  ret += evaluate_index(m, p[i], da); \
32  } \
33  return ret; \
34  } \
35  double evaluate_if_good_indexes( \
36  Model *m, const ParticleIndexPairs &p, DerivativeAccumulator *da, \
37  double max, unsigned int lower_bound, unsigned int upper_bound) const { \
38  double ret = 0; \
39  for (unsigned int i = lower_bound; i < upper_bound; ++i) { \
40  ret += evaluate_if_good_index(m, p[i], da, max - ret); \
41  if (ret > max) return std::numeric_limits<double>::max(); \
42  } \
43  return ret; \
44  }
45 
46 //! Define extra the functions needed for a PairPredicate
47 #define IMP_PAIR_PREDICATE_METHODS(Name) \
48  int get_value(const ParticlePair& a) const { \
49  return get_value_index(IMP::internal::get_model(a), \
50  IMP::internal::get_index(a)); \
51  } \
52  Ints get_value(const ParticlePairsTemp &o) const { \
53  Ints ret(o.size()); \
54  for (unsigned int i = 0; i < o.size(); ++i) { \
55  ret[i] += Name::get_value(o[i]); \
56  } \
57  return ret; \
58  } \
59  Ints get_value_index(Model *m, const ParticleIndexPairs &o) const { \
60  Ints ret(o.size()); \
61  for (unsigned int i = 0; i < o.size(); ++i) { \
62  ret[i] += Name::get_value_index(m, o[i]); \
63  } \
64  return ret; \
65  } \
66  IMP_IMPLEMENT_INLINE_NO_SWIG( \
67  void remove_if_equal(Model *m, ParticleIndexPairs &ps, \
68  int value) const, \
69  { \
70  ps.erase( \
71  std::remove_if(ps.begin(), ps.end(), \
72  IMP::internal::PredicateEquals<Name, true>( \
73  this, m, value)), \
74  ps.end()); \
75  }); \
76  IMP_IMPLEMENT_INLINE_NO_SWIG(void remove_if_not_equal(Model *m, \
77  ParticleIndexPairs &ps, \
78  int value) const, \
79  { \
80  ps.erase( \
81  std::remove_if(ps.begin(), ps.end(), \
82  IMP::internal::PredicateEquals<Name, false>( \
83  this, m, value)), \
84  ps.end()); \
85  });
86 
87 //! Use IMP_PAIR_MODIFIER() instead
88 #define IMP_PAIR_DERIVATIVE_MODIFIER(Name) IMP_PAIR_MODIFIER(Name)
89 
90 /** Define
91  - IMP::PairModifier::apply_indexes()
92 */
93 #define IMP_PAIR_MODIFIER_METHODS(Name) \
94  virtual void apply_indexes(Model *m, const ParticleIndexPairs &o, \
95  unsigned int lower_bound, \
96  unsigned int upper_bound) const IMP_FINAL { \
97  for (unsigned int i = lower_bound; i < upper_bound; ++i) { \
98  apply_index(m, o[i]); \
99  } \
100  }
101 
102 //! Use IMP_INDEX_PAIR_MODIFIER instead
103 #define IMP_INDEX_PAIR_DERIVATIVE_MODIFIER(Name) \
104  IMP_INDEX_PAIR_MODIFIER(Name)
105 
106 #ifndef IMP_DOXYGEN
107 #define IMP_IMPLEMENT_PAIR_CONTAINER(Name) \
108  IMP_IMPLEMENT_INLINE(void do_apply(const PairModifier *sm) const, \
109  { apply_generic(sm); }); \
110  virtual ParticleIndexes get_all_possible_indexes() const IMP_OVERRIDE; \
111  IMP_OBJECT_METHODS(Name)
112 #endif
113 
114 /** Use this to fill in container methods
115  IMP::PairContainer::do_apply()
116 */
117 #define IMP_PAIR_CONTAINER_METHODS(Name) \
118  void do_apply(const PairModifier *sm) const { apply_generic(sm); }
119 
120 #endif /* IMPKERNEL_PAIR_MACROS_H */
Various general useful macros for IMP.
Macros to define containers of objects.