home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.14.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
include
IMP
version 2.14.0
singleton_macros.h
Go to the documentation of this file.
1
// Autogenerated by ../../../../tmp/nightly-build-16408/imp-2.14.0/tools/build/make_containers.py
2
// from ../../../../tmp/nightly-build-16408/imp-2.14.0/tools/build/container_templates/kernel/classname_macros.h
3
// Do not edit - any changes will be lost!
4
5
/**
6
* \file IMP/singleton_macros.h
7
* \brief Macros for various classes.
8
*
9
* Copyright 2007-2020 IMP Inventors. All rights reserved.
10
*/
11
12
#ifndef IMPKERNEL_SINGLETON_MACROS_H
13
#define IMPKERNEL_SINGLETON_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::SingletonScore::evaluate_indexes()
23
- IMP::SingletonScore::evaluate_if_good_indexes()
24
*/
25
#define IMP_SINGLETON_SCORE_METHODS(Name) \
26
double evaluate_indexes(Model *m, const ParticleIndexes &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 ParticleIndexes &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 SingletonPredicate
47
#define IMP_SINGLETON_PREDICATE_METHODS(Name) \
48
int get_value(Particle* a) const { \
49
return get_value_index(IMP::internal::get_model(a), \
50
IMP::internal::get_index(a)); \
51
} \
52
Ints get_value(const ParticlesTemp &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 ParticleIndexes &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, ParticleIndexes &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
ParticleIndexes &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_SINGLETON_MODIFIER() instead
88
#define IMP_SINGLETON_DERIVATIVE_MODIFIER(Name) IMP_SINGLETON_MODIFIER(Name)
89
90
/** Define
91
- IMP::SingletonModifier::apply_indexes()
92
*/
93
#define IMP_SINGLETON_MODIFIER_METHODS(Name) \
94
virtual void apply_indexes(Model *m, const ParticleIndexes &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_SINGLETON_MODIFIER instead
103
#define IMP_INDEX_SINGLETON_DERIVATIVE_MODIFIER(Name) \
104
IMP_INDEX_SINGLETON_MODIFIER(Name)
105
106
#ifndef IMP_DOXYGEN
107
#define IMP_IMPLEMENT_SINGLETON_CONTAINER(Name) \
108
IMP_IMPLEMENT_INLINE(void do_apply(const SingletonModifier *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::SingletonContainer::do_apply()
116
*/
117
#define IMP_SINGLETON_CONTAINER_METHODS(Name) \
118
void do_apply(const SingletonModifier *sm) const { apply_generic(sm); }
119
120
#endif
/* IMPKERNEL_SINGLETON_MACROS_H */
object_macros.h
Various general useful macros for IMP.
container_macros.h
Macros to define containers of objects.