IMP logo
IMP Reference Guide  2.13.0
The Integrative Modeling Platform
quad_macros.h
Go to the documentation of this file.
1 // Autogenerated by ../../../../tmp/nightly-build-40786/imp-2.13.0/tools/build/make_containers.py
2 // from ../../../../tmp/nightly-build-40786/imp-2.13.0/tools/build/container_templates/kernel/classname_macros.h
3 // Do not edit - any changes will be lost!
4 
5 /**
6  * \file IMP/quad_macros.h
7  * \brief Macros for various classes.
8  *
9  * Copyright 2007-2020 IMP Inventors. All rights reserved.
10  */
11 
12 #ifndef IMPKERNEL_QUAD_MACROS_H
13 #define IMPKERNEL_QUAD_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::QuadScore::evaluate_indexes()
23  - IMP::QuadScore::evaluate_if_good_indexes()
24  */
25 #define IMP_QUAD_SCORE_METHODS(Name) \
26  double evaluate_indexes(Model *m, const ParticleIndexQuads &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 ParticleIndexQuads &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 QuadPredicate
47 #define IMP_QUAD_PREDICATE_METHODS(Name) \
48  int get_value(const ParticleQuad& a) const { \
49  return get_value_index(IMP::internal::get_model(a), \
50  IMP::internal::get_index(a)); \
51  } \
52  Ints get_value(const ParticleQuadsTemp &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 ParticleIndexQuads &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, ParticleIndexQuads &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  ParticleIndexQuads &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_QUAD_MODIFIER() instead
88 #define IMP_QUAD_DERIVATIVE_MODIFIER(Name) IMP_QUAD_MODIFIER(Name)
89 
90 /** Define
91  - IMP::QuadModifier::apply_indexes()
92 */
93 #define IMP_QUAD_MODIFIER_METHODS(Name) \
94  virtual void apply_indexes(Model *m, const ParticleIndexQuads &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_QUAD_MODIFIER instead
103 #define IMP_INDEX_QUAD_DERIVATIVE_MODIFIER(Name) \
104  IMP_INDEX_QUAD_MODIFIER(Name)
105 
106 #ifndef IMP_DOXYGEN
107 #define IMP_IMPLEMENT_QUAD_CONTAINER(Name) \
108  IMP_IMPLEMENT_INLINE(void do_apply(const QuadModifier *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::QuadContainer::do_apply()
116 */
117 #define IMP_QUAD_CONTAINER_METHODS(Name) \
118  void do_apply(const QuadModifier *sm) const { apply_generic(sm); }
119 
120 #endif /* IMPKERNEL_QUAD_MACROS_H */
Various general useful macros for IMP.
Macros to define containers of objects.