IMP  2.1.1
The Integrative Modeling Platform
kernel/input_output_macros.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kernel/input_output_macros.h
3  * \brief macros for inputs and outputs.
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_INPUT_OUTPUT_MACROS_H
10 #define IMPKERNEL_INPUT_OUTPUT_MACROS_H
11 #include <IMP/kernel/kernel_config.h>
13 #include "particle_index.h"
14 #include "input_output.h"
15 
16 #define IMP_BACKWARDS_MACRO_INPUTS \
17  public: \
18  /** \deprecated_at{2.1} Use get_inputs() instead. */ \
19  ParticlesTemp get_input_particles(Particle *) const; \
20  /** \deprecated_at{2.1} Use get_inputs() instead. */ \
21  ContainersTemp get_input_containers(Particle *) const; \
22  ModelObjectsTemp do_get_inputs(kernel::Model *m, \
23  const ParticleIndexes &pis) const { \
24  ModelObjectsTemp ret; \
25  for (unsigned int i = 0; i < pis.size(); ++i) { \
26  ret += get_input_particles(m->get_particle(pis[i])); \
27  ret += get_input_containers(m->get_particle(pis[i])); \
28  } \
29  return ret; \
30  }
31 
32 #define IMP_BACKWARDS_MACRO_OUTPUTS \
33  public: \
34  /** \deprecated_at{2.1} Use get_inputs() instead. */ \
35  ParticlesTemp get_output_particles(Particle *) const; \
36  /** \deprecated_at{2.1} Use get_inputs() instead. */ \
37  ContainersTemp get_output_containers(Particle *) const; \
38  ModelObjectsTemp do_get_outputs(kernel::Model *m, \
39  const ParticleIndexes &pis) const { \
40  ModelObjectsTemp ret; \
41  for (unsigned int i = 0; i < pis.size(); ++i) { \
42  ret += get_output_particles(m->get_particle(pis[i])); \
43  ret += get_output_containers(m->get_particle(pis[i])); \
44  } \
45  return ret; \
46  }
47 
48 #define IMP_MODEL_OBJECT_BACKWARDS_MACRO_INPUTS \
49  public: \
50  ParticlesTemp get_input_particles() const; \
51  ContainersTemp get_input_containers() const; \
52  ModelObjectsTemp do_get_inputs() const { \
53  ModelObjectsTemp ret; \
54  ret += get_input_containers(); \
55  ret += get_input_particles(); \
56  return ret; \
57  }
58 
59 #define IMP_MODEL_OBJECT_BACKWARDS_MACRO_OUTPUTS \
60  public: \
61  /** \deprecated_at{2.1} Use get_outputs() instead. */ \
62  IMPKERNEL_DEPRECATED_METHOD_DECL( \
63  2.1) ParticlesTemp get_output_particles() const; \
64  /** \deprecated_at{2.1} Use get_outputs() instead. */ \
65  IMPKERNEL_DEPRECATED_METHOD_DECL( \
66  2.1) ContainersTemp get_output_containers() const; \
67  IMP_COMPILER_DISABLE_WARNINGS \
68  ModelObjectsTemp do_get_outputs() const { \
69  ModelObjectsTemp ret; \
70  ret += get_output_containers(); \
71  ret += get_output_particles(); \
72  return ret; \
73  } \
74  IMP_COMPILER_ENABLE_WARNINGS
75 
76 #define IMP_INPUTS_DECL_BACKWARDS(Name) \
77  public: \
78  /** Get the set of particles read when applied to \
79  the \
80  arguments. \
81  \deprecated_at{2.1} use \
82  get_inputs() \
83  instead.*/ IMPKERNEL_DEPRECATED_METHOD_DECL( \
84  2.1) ParticlesTemp get_input_particles(Particle *p) const; \
85  /** Get the set of input containers when this modifier is \
86  applied \
87  to \
88  the arguments. \
89  \deprecated_at{2.1} use \
90  get_outputs() \
91  instead.*/ IMPKERNEL_DEPRECATED_METHOD_DECL( \
92  2.0) ContainersTemp get_input_containers(Particle *p) const
93 
94 #define IMP_INPUTS_DEF_BACKWARDS(Name) \
95  ParticlesTemp Name::get_input_particles(Particle *p) const { \
96  IMPKERNEL_DEPRECATED_METHOD_DEF(2.1, "Use get_inputs() instead."); \
97  return IMP::kernel::get_input_particles( \
98  get_inputs(p->get_model(), ParticleIndexes(1, p->get_index()))); \
99  } \
100  ContainersTemp Name::get_input_containers(Particle *p) const { \
101  IMPKERNEL_DEPRECATED_METHOD_DEF(2.1, "Use get_inputs() instead."); \
102  return IMP::kernel::get_input_containers( \
103  get_inputs(p->get_model(), ParticleIndexes(1, p->get_index()))); \
104  }
105 
106 #define IMP_OUTPUTS_DECL_BACKWARDS(Name) \
107  public: \
108  /** Get the set of particles read when applied to \
109  the \
110  arguments. \
111  \deprecated_at{2.1} use \
112  get_outputs() \
113  instead.*/ IMPKERNEL_DEPRECATED_METHOD_DECL( \
114  2.0) ParticlesTemp get_output_particles(Particle *p) \
115  const; /** Get the set of output containers when this modifier is
116  applied to the arguments. \deprecated_at{2.1} use
117  get_outputs() instead.*/ \
118 IMPKERNEL_DEPRECATED_METHOD_DECL(2.0) ContainersTemp get_output_containers( \
119  Particle *p) const
120 
121 #define IMP_OUTPUTS_DEF_BACKWARDS(Name) \
122  ParticlesTemp Name::get_output_particles(Particle *p) const { \
123  IMPKERNEL_DEPRECATED_METHOD_DEF(2.1, "Use get_outputs() instead."); \
124  return IMP::kernel::get_output_particles( \
125  get_outputs(p->get_model(), ParticleIndexes(1, p->get_index()))); \
126  } \
127  IMPKERNEL_DEPRECATED_METHOD_DECL( \
128  2.1) ContainersTemp Name::get_output_containers(Particle *p) const { \
129  IMPKERNEL_DEPRECATED_METHOD_DEF(2.1, "Use get_outputs() instead."); \
130  return IMP::kernel::get_output_containers( \
131  get_outputs(p->get_model(), ParticleIndexes(1, p->get_index()))); \
132  }
133 
134 /** \deprecated_at{2.1} Just declare the methods yourself.*/
135 #define IMP_INPUTS_DECL(Name) \
136  IMPKERNEL_DEPRECATED_MACRO(2.1, \
137  "Inherit from IMP::kernel::ParticleInputs."); \
138  IMP_INPUTS_DECL_BACKWARDS(Name); \
139  \
140  public: /** Get all the ModelObject objects that are read when the \
141  referenced \
142  particles are passed in.*/ \
143  ModelObjectsTemp get_inputs(kernel::Model *m, \
144  const ParticleIndexes &pis) const; \
145  \
146  protected: /** Override if this reads other objects during evaluate.*/ \
147  virtual ModelObjectsTemp do_get_inputs(kernel::Model *m, \
148  const ParticleIndexes &pis) const = 0
149 
150 /** Define standard input methods for things that take particles as arguments
151  such as IMP::SingletonModifier and IMP::PairScore.*/
152 #define IMP_INPUTS_DEF(Name) \
153  IMP_INPUTS_DEF_BACKWARDS(Name) IMPKERNEL_DEPRECATED_MACRO( \
154  2.1, "Inherit from IMP::kernel::ParticleInputs."); \
155  ModelObjectsTemp Name::get_inputs(kernel::Model *m, \
156  const ParticleIndexes &pis) const { \
157  return do_get_inputs(m, pis); \
158  }
159 
160 /** \deprecated_at{2.1} Declare the methods yourself. */
161 #define IMP_OUTPUTS_DECL(Name) \
162  IMPKERNEL_DEPRECATED_MACRO(2.1, \
163  "Inherit from IMP::kernel::ParticleOutputs."); \
164  IMP_OUTPUTS_DECL_BACKWARDS(Name); \
165  \
166  public: /** Get all the ModelObject objects that are read when the referenced \
167  particles are passed in.*/ \
168  ModelObjectsTemp get_outputs(kernel::Model *m, \
169  const ParticleIndexes &pis) const; \
170  \
171  protected: /** Override if this reads other objects during evaluate.*/ \
172  virtual ModelObjectsTemp do_get_outputs( \
173  Model *m, const ParticleIndexes &pis) const = 0
174 
175 /** \deprecated_at{2.1} Declare the methods yourself*/
176 #define IMP_OUTPUTS_DEF(Name) \
177  IMPKERNEL_DEPRECATED_MACRO(2.1, \
178  "Inherit from IMP::kernel::ParticleOutputs."); \
179  IMP_OUTPUTS_DEF_BACKWARDS(Name) ModelObjectsTemp Name::get_outputs( \
180  Model *m, const ParticleIndexes &pis) const { \
181  return do_get_outputs(m, pis); \
182  }
183 
184 #endif /* IMPKERNEL_INPUT_OUTPUT_MACROS_H */
Various general useful functions for IMP.
Control display of deprecation information.
Single variable function.