1 | /*
|
---|
2 | * molecule_template.hpp
|
---|
3 | *
|
---|
4 | * Created on: Oct 6, 2009
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef MOLECULE_TEMPLATE_HPP_
|
---|
9 | #define MOLECULE_TEMPLATE_HPP_
|
---|
10 |
|
---|
11 | /*********************************************** includes ***********************************/
|
---|
12 |
|
---|
13 | // include config.h
|
---|
14 | #ifdef HAVE_CONFIG_H
|
---|
15 | #include <config.h>
|
---|
16 | #endif
|
---|
17 |
|
---|
18 | #include "atom.hpp"
|
---|
19 | /********************************************** declarations *******************************/
|
---|
20 |
|
---|
21 | // ================== Acting on all Vectors ========================== //
|
---|
22 |
|
---|
23 | // zero arguments
|
---|
24 | template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
|
---|
25 | {
|
---|
26 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
27 | (((*iter)->node)->*f)();
|
---|
28 | }
|
---|
29 | };
|
---|
30 | template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
|
---|
31 | {
|
---|
32 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
33 | (((*iter)->node)->*f)();
|
---|
34 | }
|
---|
35 | };
|
---|
36 | // one argument
|
---|
37 | template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
|
---|
38 | {
|
---|
39 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
40 | (((*iter)->node)->*f)(t);
|
---|
41 | }
|
---|
42 | };
|
---|
43 | template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
|
---|
44 | {
|
---|
45 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
46 | (((*iter)->node)->*f)(t);
|
---|
47 | }
|
---|
48 | };
|
---|
49 | template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const
|
---|
50 | {
|
---|
51 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
52 | (((*iter)->node)->*f)(t);
|
---|
53 | }
|
---|
54 | };
|
---|
55 | template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const
|
---|
56 | {
|
---|
57 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
58 | (((*iter)->node)->*f)(t);
|
---|
59 | }
|
---|
60 | };
|
---|
61 | // two arguments
|
---|
62 | template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
|
---|
63 | {
|
---|
64 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
65 | (((*iter)->node)->*f)(t, u);
|
---|
66 | }
|
---|
67 | };
|
---|
68 | template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
|
---|
69 | {
|
---|
70 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
71 | (((*iter)->node)->*f)(t, u);
|
---|
72 | }
|
---|
73 | };
|
---|
74 | // three arguments
|
---|
75 | template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
|
---|
76 | {
|
---|
77 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
78 | (((*iter)->node)->*f)(t, u, v);
|
---|
79 | }
|
---|
80 | };
|
---|
81 | template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
|
---|
82 | {
|
---|
83 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
84 | (((*iter)->node)->*f)(t, u, v);
|
---|
85 | }
|
---|
86 | };
|
---|
87 |
|
---|
88 | // ========================= Summing over each Atoms =================================== //
|
---|
89 |
|
---|
90 | // zero arguments
|
---|
91 | template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
|
---|
92 | {
|
---|
93 | res result = 0;
|
---|
94 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
95 | result += ((*iter)->*f)();
|
---|
96 | }
|
---|
97 | return result;
|
---|
98 | };
|
---|
99 | template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
|
---|
100 | {
|
---|
101 | res result = 0;
|
---|
102 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
103 | result += ((*iter)->*f)();
|
---|
104 | }
|
---|
105 | return result;
|
---|
106 | };
|
---|
107 | // one argument
|
---|
108 | template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
|
---|
109 | {
|
---|
110 | res result = 0;
|
---|
111 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
112 | result += ((*iter)->*f)(t);
|
---|
113 | }
|
---|
114 | return result;
|
---|
115 | };
|
---|
116 | template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
|
---|
117 | {
|
---|
118 | res result = 0;
|
---|
119 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
120 | result += ((*iter)->*f)(t);
|
---|
121 | }
|
---|
122 | return result;
|
---|
123 | };
|
---|
124 |
|
---|
125 |
|
---|
126 | // ================== Acting with each Atoms on same molecule ========================== //
|
---|
127 |
|
---|
128 | // zero arguments
|
---|
129 | template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
|
---|
130 | {
|
---|
131 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
132 | (*f)((*iter));
|
---|
133 | }
|
---|
134 | };
|
---|
135 | template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
|
---|
136 | {
|
---|
137 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
138 | (*f)((*iter));
|
---|
139 | }
|
---|
140 | };
|
---|
141 |
|
---|
142 | // ================== Acting with each Atoms on copy molecule ========================== //
|
---|
143 |
|
---|
144 | // zero arguments
|
---|
145 | template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
|
---|
146 | {
|
---|
147 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
148 | (copy->*f)((*iter));
|
---|
149 | }
|
---|
150 | };
|
---|
151 | template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
|
---|
152 | {
|
---|
153 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
154 | (copy->*f)((*iter));
|
---|
155 | }
|
---|
156 | };
|
---|
157 |
|
---|
158 | // ================== Acting with each Atoms on copy molecule if true ========================== //
|
---|
159 |
|
---|
160 | // zero arguments
|
---|
161 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
|
---|
162 | {
|
---|
163 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
164 | if (((*iter)->*condition)())
|
---|
165 | (copy->*f)((*iter));
|
---|
166 | }
|
---|
167 | };
|
---|
168 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
|
---|
169 | {
|
---|
170 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
171 | if (((*iter)->*condition)())
|
---|
172 | (copy->*f)((*iter));
|
---|
173 | }
|
---|
174 | };
|
---|
175 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
|
---|
176 | {
|
---|
177 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
178 | if (((*iter)->*condition)())
|
---|
179 | (copy->*f)((*iter));
|
---|
180 | }
|
---|
181 | };
|
---|
182 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
|
---|
183 | {
|
---|
184 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
185 | if (((*iter)->*condition)())
|
---|
186 | (copy->*f)((*iter));
|
---|
187 | }
|
---|
188 | };
|
---|
189 | // one argument
|
---|
190 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
|
---|
191 | {
|
---|
192 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
193 | if (((*iter)->*condition)(t))
|
---|
194 | (copy->*f)((*iter));
|
---|
195 | }
|
---|
196 | };
|
---|
197 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
|
---|
198 | {
|
---|
199 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
200 | if (((*iter)->*condition)(t))
|
---|
201 | (copy->*f)((*iter));
|
---|
202 | }
|
---|
203 | };
|
---|
204 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
|
---|
205 | {
|
---|
206 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
207 | if (((*iter)->*condition)(t))
|
---|
208 | (copy->*f)((*iter));
|
---|
209 | }
|
---|
210 | };
|
---|
211 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
|
---|
212 | {
|
---|
213 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
214 | if (((*iter)->*condition)(t))
|
---|
215 | (copy->*f)((*iter));
|
---|
216 | }
|
---|
217 | };
|
---|
218 | // two arguments
|
---|
219 | template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
|
---|
220 | {
|
---|
221 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
222 | if (((*iter)->*condition)(t,u))
|
---|
223 | (copy->*f)((*iter));
|
---|
224 | }
|
---|
225 | };
|
---|
226 | template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
|
---|
227 | {
|
---|
228 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
229 | if (((*iter)->*condition)(t,u))
|
---|
230 | (copy->*f)((*iter));
|
---|
231 | }
|
---|
232 | };
|
---|
233 | template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
|
---|
234 | {
|
---|
235 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
236 | if (((*iter)->*condition)(t,u))
|
---|
237 | (copy->*f)((*iter));
|
---|
238 | }
|
---|
239 | };
|
---|
240 | template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
|
---|
241 | {
|
---|
242 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
243 | if (((*iter)->*condition)(t,u))
|
---|
244 | (copy->*f)((*iter));
|
---|
245 | }
|
---|
246 | };
|
---|
247 | // three arguments
|
---|
248 | template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
|
---|
249 | {
|
---|
250 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
251 | if (((*iter)->*condition)(t,u,v))
|
---|
252 | (copy->*f)((*iter));
|
---|
253 | }
|
---|
254 | };
|
---|
255 | template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
|
---|
256 | {
|
---|
257 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
258 | if (((*iter)->*condition)(t,u,v))
|
---|
259 | (copy->*f)((*iter));
|
---|
260 | }
|
---|
261 | };
|
---|
262 | template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
|
---|
263 | {
|
---|
264 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
265 | if (((*iter)->*condition)(t,u,v))
|
---|
266 | (copy->*f)((*iter));
|
---|
267 | }
|
---|
268 | };
|
---|
269 | template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
|
---|
270 | {
|
---|
271 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
272 | if (((*iter)->*condition)(t,u,v))
|
---|
273 | (copy->*f)((*iter));
|
---|
274 | }
|
---|
275 | };
|
---|
276 |
|
---|
277 | // ================== Acting on all Atoms ========================== //
|
---|
278 |
|
---|
279 | // zero arguments
|
---|
280 | template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
|
---|
281 | {
|
---|
282 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
283 | ((*iter)->*f)();
|
---|
284 | }
|
---|
285 | };
|
---|
286 | template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
|
---|
287 | {
|
---|
288 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
289 | ((*iter)->*f)();
|
---|
290 | }
|
---|
291 | };
|
---|
292 | // one argument
|
---|
293 | template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
|
---|
294 | {
|
---|
295 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
296 | ((*iter)->*f)(t);
|
---|
297 | }
|
---|
298 | };
|
---|
299 | template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
|
---|
300 | {
|
---|
301 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
302 | ((*iter)->*f)(t);
|
---|
303 | }
|
---|
304 | };
|
---|
305 | // two argument
|
---|
306 | template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
|
---|
307 | {
|
---|
308 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
309 | ((*iter)->*f)(t, u);
|
---|
310 | }
|
---|
311 | };
|
---|
312 | template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
|
---|
313 | {
|
---|
314 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
315 | ((*iter)->*f)(t, u);
|
---|
316 | }
|
---|
317 | };
|
---|
318 | // three argument
|
---|
319 | template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
|
---|
320 | {
|
---|
321 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
322 | ((*iter)->*f)(t, u, v);
|
---|
323 | }
|
---|
324 | };
|
---|
325 | template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
|
---|
326 | {
|
---|
327 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
328 | ((*iter)->*f)(t, u, v);
|
---|
329 | }
|
---|
330 | };
|
---|
331 | // four arguments
|
---|
332 | template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
|
---|
333 | {
|
---|
334 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
335 | ((*iter)->*f)(t, u, v, w);
|
---|
336 | }
|
---|
337 | };
|
---|
338 | template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
|
---|
339 | {
|
---|
340 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
341 | ((*iter)->*f)(t, u, v, w);
|
---|
342 | }
|
---|
343 | };
|
---|
344 |
|
---|
345 | // ===================== Accessing arrays indexed by some integer for each atom ======================
|
---|
346 |
|
---|
347 | // for atom ints
|
---|
348 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
|
---|
349 | {
|
---|
350 | int inc = 1;
|
---|
351 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
352 | (*Setor) (&array[((*iter)->*index)], &inc);
|
---|
353 | }
|
---|
354 | };
|
---|
355 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
|
---|
356 | {
|
---|
357 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
358 | (*Setor) (&array[((*iter)->*index)], &value);
|
---|
359 | }
|
---|
360 | };
|
---|
361 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
|
---|
362 | {
|
---|
363 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
364 | (*Setor) (&array[((*iter)->*index)], value);
|
---|
365 | }
|
---|
366 | };
|
---|
367 | // for element ints
|
---|
368 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
|
---|
369 | {
|
---|
370 | int inc = 1;
|
---|
371 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
372 | (*Setor) (&array[((*iter)->type->*index)], &inc);
|
---|
373 | }
|
---|
374 | };
|
---|
375 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
|
---|
376 | {
|
---|
377 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
378 | (*Setor) (&array[((*iter)->type->*index)], &value);
|
---|
379 | }
|
---|
380 | };
|
---|
381 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
|
---|
382 | {
|
---|
383 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
384 | (*Setor) (&array[((*iter)->type->*index)], value);
|
---|
385 | }
|
---|
386 | };
|
---|
387 |
|
---|
388 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
|
---|
389 | {
|
---|
390 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
391 | array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
|
---|
392 | }
|
---|
393 | };
|
---|
394 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
|
---|
395 | {
|
---|
396 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
397 | array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
|
---|
398 | }
|
---|
399 | };
|
---|
400 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
|
---|
401 | {
|
---|
402 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
403 | array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
|
---|
404 | }
|
---|
405 | };
|
---|
406 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
|
---|
407 | {
|
---|
408 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
409 | array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
|
---|
410 | }
|
---|
411 | };
|
---|
412 | template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
|
---|
413 | {
|
---|
414 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
415 | (*iter)->*value = array[((*iter)->*index)];
|
---|
416 | //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*value); << endl;
|
---|
417 | }
|
---|
418 | };
|
---|
419 |
|
---|
420 | template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
|
---|
421 | {
|
---|
422 | for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
|
---|
423 | (*iter)->*ptr = value;
|
---|
424 | //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*ptr) << endl;
|
---|
425 | }
|
---|
426 | };
|
---|
427 |
|
---|
428 |
|
---|
429 | #endif /* MOLECULE_TEMPLATE_HPP_ */
|
---|