IMP
2.1.1
The Integrative Modeling Platform
IMP Mainpage
All IMP Modules
Related Pages
Modules
Namespaces
Classes
Files
Examples
Indexes
File List
File Members
domino_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/domino/domino_macros.h \brief Various important macros
3
* for implementing decorators.
4
*
5
* Copyright 2007-2013 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPDOMINO_MACROS_H
10
#define IMPDOMINO_MACROS_H
11
12
#include <IMP/domino/domino_config.h>
13
14
/** \deprecated_at{2.1} Expand the macro inline
15
*/
16
#define IMP_PARTICLE_STATES(Name) \
17
public: \
18
IMPDOMINO_DEPRECATED_MACRO(2.1, \
19
"Expand the macro inline.") virtual unsigned int \
20
get_number_of_particle_states() const IMP_OVERRIDE; \
21
virtual void load_particle_state(unsigned int, kernel::Particle *) const \
22
IMP_OVERRIDE; \
23
IMP_OBJECT_NO_WARNING(Name)
24
25
/** \deprecated_at{2.1} Expand the macro inline
26
*/
27
#define IMP_ASSIGNMENTS_TABLE(Name) \
28
public: \
29
IMPDOMINO_DEPRECATED_MACRO(2.1, "Expand the macro inline.") virtual void \
30
load_assignments(const IMP::domino::Subset &s, \
31
AssignmentContainer *ac) const IMP_OVERRIDE; \
32
IMP_OBJECT_NO_WARNING(Name)
33
34
/** \deprecated_at{2.1} Expand the macro inline
35
*/
36
#define IMP_SUBSET_FILTER_TABLE(Name) \
37
public: \
38
IMPDOMINO_DEPRECATED_MACRO( \
39
2.1, "Expand the macro inline.") virtual IMP::domino::SubsetFilter * \
40
get_subset_filter(const IMP::domino::Subset &s, \
41
const IMP::domino::Subsets &excluded) const \
42
IMP_OVERRIDE; \
43
virtual double get_strength(const IMP::domino::Subset &s, \
44
const IMP::domino::Subsets &excluded) const \
45
IMP_OVERRIDE; \
46
IMP_OBJECT_NO_WARNING(Name)
47
48
/** This macro defines a class NameSubsetFilterTable from a method
49
which is applied to disjoint sets. The code should assume there is
50
a Assignment state and an Ints members which ordered indices into
51
the Assignment for the current set.
52
*/
53
#define IMP_DISJOINT_SUBSET_FILTER_TABLE_DECL(Name) \
54
class IMPDOMINOEXPORT Name##SubsetFilterTable \
55
: public DisjointSetsSubsetFilterTable { \
56
typedef DisjointSetsSubsetFilterTable P; \
57
\
58
public: \
59
Name##SubsetFilterTable(IMP::domino::ParticleStatesTable *pst) \
60
: P(pst, std::string(#Name) + std::string(" %1%")) {} \
61
Name##SubsetFilterTable() : P(std::string(#Name) + std::string(" %1%")) {} \
62
virtual IMP::domino::SubsetFilter *get_subset_filter( \
63
const IMP::domino::Subset &s, \
64
const IMP::domino::Subsets &excluded) const IMP_OVERRIDE; \
65
virtual double get_strength(const IMP::domino::Subset &s, \
66
const IMP::domino::Subsets &excluded) const \
67
IMP_OVERRIDE; \
68
IMP_OBJECT_METHODS(Name##SubsetFilterTable); \
69
}; \
70
IMP_OBJECTS(Name##SubsetFilterTable, Name##SubsetFilterTables)
71
72
#define IMP_DISJOINT_SUBSET_FILTER_TABLE_DEF(Name, filter, strength, next) \
73
struct Name##Filter { \
74
bool operator()(const Assignment &state, const Ints &members) const { \
75
filter; \
76
} \
77
}; \
78
struct Name##Strength { \
79
double operator()(const Subset &s, const Subsets &excluded, \
80
const Ints &members) const { \
81
strength; \
82
} \
83
}; \
84
struct Name##Next { \
85
int operator()(int pos, const Assignment &state, const Ints &set) const { \
86
next; \
87
} \
88
}; \
89
IMP::domino::SubsetFilter *Name##SubsetFilterTable::get_subset_filter( \
90
const IMP::domino::Subset &s, \
91
const IMP::domino::Subsets &excluded) const { \
92
IMP_OBJECT_LOG; \
93
set_was_used(true); \
94
base::Vector<Ints> all; \
95
Ints used; \
96
get_indexes(s, excluded, all, 1, used); \
97
return get_disjoint_set_filter<Name##Filter, Name##Next>( \
98
#Name, s, get_log_level(), all, used); \
99
} \
100
double Name##SubsetFilterTable::get_strength( \
101
const IMP::domino::Subset &s, \
102
const IMP::domino::Subsets &excluded) const { \
103
IMP_OBJECT_LOG; \
104
set_was_used(true); \
105
base::Vector<Ints> all; \
106
Ints used; \
107
get_indexes(s, excluded, all, 0, used); \
108
return get_disjoint_set_strength<Name##Strength>(s, excluded, all, used); \
109
}
110
111
/** \deprecated_at{2.1} Expand the macro inline
112
*/
113
#define IMP_SUBSET_FILTER(Name) \
114
IMPDOMINO_DEPRECATED_MACRO(2.1, "Expand the macro inline.") public \
115
: virtual bool get_is_ok( \
116
const IMP::domino::Assignment &assignment) const IMP_OVERRIDE; \
117
IMP_OBJECT_NO_WARNING(Name)
118
119
/** \deprecated_at{2.1} Expand the macro inline
120
*/
121
#define IMP_DISCRETE_SAMPLER(Name) \
122
IMPDOMINO_DEPRECATED_MACRO(2.1, "Expand the macro inline.") public \
123
: Assignments do_get_sample_assignments( \
124
const IMP::domino::Subset &known) const IMP_OVERRIDE; \
125
IMP_OBJECT_NO_WARNING(Name)
126
127
/** \deprecated_at{2.1} Expand the macro inline
128
*/
129
#define IMP_SUBSET_GRAPH_TABLE(Name) \
130
IMPDOMINO_DEPRECATED_MACRO(2.1, "Expand the macro inline.") public \
131
: IMP_IMPLEMENT(SubsetGraph get_subset_graph( \
132
IMP::domino::ParticleStatesTable *pst) const); \
133
IMP_OBJECT_NO_WARNING(Name)
134
135
/** This macro defines:
136
- AssignmentsContainer::get_assignments(IntRange)
137
- AssignmentsContainer::add_assignments()
138
- AssignmentsContainer::get_assignments(unsigned int)
139
*/
140
#define IMP_ASSIGNMENT_CONTAINER_METHODS(Name) \
141
public: \
142
virtual Assignments get_assignments(IntRange r) const IMP_OVERRIDE { \
143
Assignments ret(r.second - r.first); \
144
for (unsigned int i = 0; i != ret.size(); ++i) { \
145
ret[i] = Name::get_assignment(r.first + i); \
146
} \
147
return ret; \
148
} \
149
virtual Assignments get_assignments() const IMP_OVERRIDE { \
150
return get_assignments(IntRange(0, get_number_of_assignments())); \
151
} \
152
; \
153
virtual void add_assignments(const Assignments &as) IMP_OVERRIDE { \
154
for (unsigned int i = 0; i < as.size(); ++i) { \
155
Name::add_assignment(as[i]); \
156
} \
157
} \
158
virtual Ints get_particle_assignments(unsigned int index) const \
159
IMP_OVERRIDE { \
160
Ints ret(Name::get_number_of_assignments()); \
161
for (unsigned int i = 0; i < Name::get_number_of_assignments(); ++i) { \
162
ret[i] = get_assignment(i)[index]; \
163
} \
164
return ret; \
165
}
166
167
/** \deprecated_at{2.1} Use IMP_ASSIGNMENT_CONTAINER_METHODS instead
168
*/
169
#define IMP_ASSIGNMENT_CONTAINER(Name) \
170
virtual unsigned int get_number_of_assignments() const IMP_OVERRIDE; \
171
virtual Assignment get_assignment(unsigned int i) const IMP_OVERRIDE; \
172
virtual void add_assignment(const Assignment &a) IMP_OVERRIDE; \
173
IMPDOMINO_DEPRECATED_MACRO(2.1, \
174
"Use IMP_ASSIGNMENT_CONTAINER_METHODS instead"); \
175
IMP_ASSIGNMENT_CONTAINER_METHODS(Name); \
176
IMP_OBJECT_NO_WARNING(Name)
177
178
/** \deprecated_at{2.1} Use IMP_ASSIGNMENT_CONTAINER_METHODS instead
179
*/
180
#define IMP_ASSIGNMENT_CONTAINER_INLINE(Name, show, dest) \
181
virtual unsigned int get_number_of_assignments() const IMP_OVERRIDE; \
182
virtual Assignment get_assignment(unsigned int i) const IMP_OVERRIDE; \
183
virtual void add_assignment(const Assignment &a) IMP_OVERRIDE; \
184
IMPDOMINO_DEPRECATED_MACRO("Use IMP_ASSIGNMENT_CONTAINER_METHODS instead"); \
185
IMP_ASSIGNMENT_CONTAINER_METHODS(Name); \
186
IMP_OBJECT_METHODS(Name)
187
188
#endif
/* IMPDOMINO_MACROS_H */