IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
kernel/refiner_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/kernel/refiner_macros.h
3
* \brief Various general useful macros for IMP.
4
*
5
* Copyright 2007-2013 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPKERNEL_REFINER_MACROS_H
10
#define IMPKERNEL_REFINER_MACROS_H
11
#include <IMP/kernel/kernel_config.h>
12
#include "
Refiner.h
"
13
#include "
container_base.h
"
14
#include <
IMP/base/object_macros.h
>
15
16
17
18
//! Define the basics needed for a particle refiner
19
/** In addition to the methods done by all the macros, it declares
20
- IMP::Refiner::get_can_refine()
21
- IMP::Refiner::get_number_of_refined()
22
- IMP::Refiner::get_refined()
23
- IMP::Refiner::get_input_particles()
24
\see IMP_SIMPLE_REFINER
25
*/
26
#define IMP_REFINER(Name) \
27
virtual bool get_can_refine(Particle*) const; \
28
virtual const ParticlesTemp get_refined(Particle *) const; \
29
virtual Particle* get_refined(Particle *, unsigned int) const; \
30
virtual unsigned int get_number_of_refined(Particle *) const; \
31
IMP_BACKWARDS_MACRO_INPUTS; \
32
IMP_OBJECT(Name)
33
34
35
//! Define the basics needed for a particle refiner
36
/** In contrast to IMP_REFINER, if this macro is used, the
37
Refiner::get_refined(Particle*) method is implemented using the
38
other Refiner::get_refined() method and so does not have to be
39
provided.
40
41
\see IMP_REFINER
42
*/
43
#define IMP_SIMPLE_REFINER(Name) \
44
virtual bool get_can_refine(Particle*) const; \
45
virtual Particle* get_refined(Particle *, unsigned int) const; \
46
virtual const ParticlesTemp get_refined(Particle *a) const { \
47
ParticlesTemp ret(get_number_of_refined(a)); \
48
for (unsigned int i=0; i< ret.size(); ++i) { \
49
ret[i]= get_refined(a,i); \
50
} \
51
return ret; \
52
} \
53
virtual unsigned int get_number_of_refined(Particle *) const; \
54
IMP_BACKWARDS_MACRO_INPUTS; \
55
IMP_OBJECT(Name)
56
57
58
59
60
61
62
63
64
65
//! Add interaction methods to a SingletonModifer
66
/** This macro is designed to be used in conjunction with
67
IMP_SINGLETON_MODIFIER or IMP_SINGLETON_MODIFIER_DA. It adds
68
definitions for the methods:
69
- IMP::SingletonModifier::get_input_particles()
70
- IMP::SingletonModifier::get_output_particles()
71
for a modifier which updates the passed particle based on the results
72
of refinement.
73
*/
74
#define IMP_SINGLETON_MODIFIER_FROM_REFINED(Name, refiner) \
75
ModelObjectsTemp Name::do_get_inputs(Model *m, \
76
const ParticleIndexes &pis) const { \
77
ModelObjectsTemp ret; \
78
ret+= refiner->get_inputs(m, pis); \
79
ret+= IMP::kernel::get_particles(m, pis); \
80
for (unsigned int i=0; i< pis.size(); ++i) { \
81
ret+=refiner->get_refined(m->get_particle(pis[i])); \
82
} \
83
return ret; \
84
} \
85
ModelObjectsTemp Name::do_get_outputs(Model *m, \
86
const ParticleIndexes &pis) const { \
87
ModelObjectsTemp ret; \
88
ret+=IMP::kernel::get_particles(m, pis); \
89
return ret; \
90
} \
91
IMP_NO_DOXYGEN(void Name::do_show(std::ostream &out) const { \
92
out <<"refiner " << *refiner << std::endl; \
93
}) \
94
IMP_REQUIRE_SEMICOLON_NAMESPACE
95
96
//! Add interaction methods to a SingletonModifer
97
/** This macro is designed to be used in conjunction with
98
IMP_SINGLETON_MODIFIER or IMP_SINGLETON_MODIFIER_DA. It adds
99
definitions for the methods:
100
- IMP::SingletonModifier::get_input_particles()
101
- IMP::SingletonModifier::get_output_particles()
102
- IMP::base::Object::do_show()
103
for a modifier which updates the refined particles based on the one
104
they are refined from.
105
106
This macro should appear in a .cpp file.
107
*/
108
#define IMP_SINGLETON_MODIFIER_TO_REFINED(Name, refiner) \
109
ModelObjectsTemp Name::do_get_inputs(Model *m, \
110
const ParticleIndexes &pis) const { \
111
ModelObjectsTemp ret; \
112
ret+= refiner->get_inputs(m, pis); \
113
for (unsigned int i=0; i< pis.size(); ++i) { \
114
ret+=refiner->get_refined(m->get_particle(pis[i])); \
115
} \
116
ret+= IMP::kernel::get_particles(m, pis); \
117
return ret; \
118
} \
119
ModelObjectsTemp Name::do_get_outputs(Model *m, \
120
const ParticleIndexes &pis) const { \
121
ModelObjectsTemp ret; \
122
for (unsigned int i=0; i< pis.size(); ++i) { \
123
ret+=refiner->get_refined(m->get_particle(pis[i])); \
124
} \
125
return ret; \
126
} \
127
IMP_NO_DOXYGEN(void Name::do_show(std::ostream &out) const { \
128
out << "refiner " << *refiner << std::endl; \
129
}) \
130
IMP_REQUIRE_SEMICOLON_NAMESPACE
131
132
133
134
#endif
/* IMPKERNEL_REFINER_MACROS_H */