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 | atom *Walker = start;
|
---|
27 | while (Walker->next != end) {
|
---|
28 | Walker = Walker->next;
|
---|
29 | ((Walker->node)->*f)();
|
---|
30 | }
|
---|
31 | };
|
---|
32 | template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
|
---|
33 | {
|
---|
34 | atom *Walker = start;
|
---|
35 | while (Walker->next != end) {
|
---|
36 | Walker = Walker->next;
|
---|
37 | ((Walker->node)->*f)();
|
---|
38 | }
|
---|
39 | };
|
---|
40 | // one argument
|
---|
41 | template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
|
---|
42 | {
|
---|
43 | atom *Walker = start;
|
---|
44 | while (Walker->next != end) {
|
---|
45 | Walker = Walker->next;
|
---|
46 | ((Walker->node)->*f)(t);
|
---|
47 | }
|
---|
48 | };
|
---|
49 | template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
|
---|
50 | {
|
---|
51 | atom *Walker = start;
|
---|
52 | while (Walker->next != end) {
|
---|
53 | Walker = Walker->next;
|
---|
54 | ((Walker->node)->*f)(t);
|
---|
55 | }
|
---|
56 | };
|
---|
57 | template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const
|
---|
58 | {
|
---|
59 | atom *Walker = start;
|
---|
60 | while (Walker->next != end) {
|
---|
61 | Walker = Walker->next;
|
---|
62 | ((Walker->node)->*f)(t);
|
---|
63 | }
|
---|
64 | };
|
---|
65 | template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const
|
---|
66 | {
|
---|
67 | atom *Walker = start;
|
---|
68 | while (Walker->next != end) {
|
---|
69 | Walker = Walker->next;
|
---|
70 | ((Walker->node)->*f)(t);
|
---|
71 | }
|
---|
72 | };
|
---|
73 | // two arguments
|
---|
74 | template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
|
---|
75 | {
|
---|
76 | atom *Walker = start;
|
---|
77 | while (Walker->next != end) {
|
---|
78 | Walker = Walker->next;
|
---|
79 | ((Walker->node)->*f)(t, u);
|
---|
80 | }
|
---|
81 | };
|
---|
82 | template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
|
---|
83 | {
|
---|
84 | atom *Walker = start;
|
---|
85 | while (Walker->next != end) {
|
---|
86 | Walker = Walker->next;
|
---|
87 | ((Walker->node)->*f)(t, u);
|
---|
88 | }
|
---|
89 | };
|
---|
90 | // three arguments
|
---|
91 | 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
|
---|
92 | {
|
---|
93 | atom *Walker = start;
|
---|
94 | while (Walker->next != end) {
|
---|
95 | Walker = Walker->next;
|
---|
96 | ((Walker->node)->*f)(t, u, v);
|
---|
97 | }
|
---|
98 | };
|
---|
99 | 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
|
---|
100 | {
|
---|
101 | atom *Walker = start;
|
---|
102 | while (Walker->next != end) {
|
---|
103 | Walker = Walker->next;
|
---|
104 | ((Walker->node)->*f)(t, u, v);
|
---|
105 | }
|
---|
106 | };
|
---|
107 |
|
---|
108 | // ========================= Summing over each Atoms =================================== //
|
---|
109 |
|
---|
110 | // zero arguments
|
---|
111 | template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
|
---|
112 | {
|
---|
113 | res result = 0;
|
---|
114 | atom *Walker = start;
|
---|
115 | while (Walker->next != end) {
|
---|
116 | Walker = Walker->next;
|
---|
117 | result += (Walker->*f)();
|
---|
118 | }
|
---|
119 | return result;
|
---|
120 | };
|
---|
121 | template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
|
---|
122 | {
|
---|
123 | res result = 0;
|
---|
124 | atom *Walker = start;
|
---|
125 | while (Walker->next != end) {
|
---|
126 | Walker = Walker->next;
|
---|
127 | result += (Walker->*f)();
|
---|
128 | }
|
---|
129 | return result;
|
---|
130 | };
|
---|
131 | // one argument
|
---|
132 | template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
|
---|
133 | {
|
---|
134 | res result = 0;
|
---|
135 | atom *Walker = start;
|
---|
136 | while (Walker->next != end) {
|
---|
137 | Walker = Walker->next;
|
---|
138 | result += (Walker->*f)(t);
|
---|
139 | }
|
---|
140 | return result;
|
---|
141 | };
|
---|
142 | template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
|
---|
143 | {
|
---|
144 | res result = 0;
|
---|
145 | atom *Walker = start;
|
---|
146 | while (Walker->next != end) {
|
---|
147 | Walker = Walker->next;
|
---|
148 | result += (Walker->*f)(t);
|
---|
149 | }
|
---|
150 | return result;
|
---|
151 | };
|
---|
152 |
|
---|
153 |
|
---|
154 | // ================== Acting with each Atoms on same molecule ========================== //
|
---|
155 |
|
---|
156 | // zero arguments
|
---|
157 | template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
|
---|
158 | {
|
---|
159 | atom *Walker = start;
|
---|
160 | while (Walker->next != end) {
|
---|
161 | Walker = Walker->next;
|
---|
162 | (*f)(Walker);
|
---|
163 | }
|
---|
164 | };
|
---|
165 | template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
|
---|
166 | {
|
---|
167 | atom *Walker = start;
|
---|
168 | while (Walker->next != end) {
|
---|
169 | Walker = Walker->next;
|
---|
170 | (*f)(Walker);
|
---|
171 | }
|
---|
172 | };
|
---|
173 |
|
---|
174 | // ================== Acting with each Atoms on copy molecule ========================== //
|
---|
175 |
|
---|
176 | // zero arguments
|
---|
177 | template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
|
---|
178 | {
|
---|
179 | atom *Walker = start;
|
---|
180 | while (Walker->next != end) {
|
---|
181 | Walker = Walker->next;
|
---|
182 | (copy->*f)(Walker);
|
---|
183 | }
|
---|
184 | };
|
---|
185 | template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
|
---|
186 | {
|
---|
187 | atom *Walker = start;
|
---|
188 | while (Walker->next != end) {
|
---|
189 | Walker = Walker->next;
|
---|
190 | (copy->*f)(Walker);
|
---|
191 | }
|
---|
192 | };
|
---|
193 |
|
---|
194 | // ================== Acting with each Atoms on copy molecule if true ========================== //
|
---|
195 |
|
---|
196 | // zero arguments
|
---|
197 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
|
---|
198 | {
|
---|
199 | atom *Walker = start;
|
---|
200 | while (Walker->next != end) {
|
---|
201 | Walker = Walker->next;
|
---|
202 | if ((Walker->*condition)())
|
---|
203 | (copy->*f)(Walker);
|
---|
204 | }
|
---|
205 | };
|
---|
206 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
|
---|
207 | {
|
---|
208 | atom *Walker = start;
|
---|
209 | while (Walker->next != end) {
|
---|
210 | Walker = Walker->next;
|
---|
211 | if ((Walker->*condition)())
|
---|
212 | (copy->*f)(Walker);
|
---|
213 | }
|
---|
214 | };
|
---|
215 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
|
---|
216 | {
|
---|
217 | atom *Walker = start;
|
---|
218 | while (Walker->next != end) {
|
---|
219 | Walker = Walker->next;
|
---|
220 | if ((Walker->*condition)())
|
---|
221 | (copy->*f)(Walker);
|
---|
222 | }
|
---|
223 | };
|
---|
224 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
|
---|
225 | {
|
---|
226 | atom *Walker = start;
|
---|
227 | while (Walker->next != end) {
|
---|
228 | Walker = Walker->next;
|
---|
229 | if ((Walker->*condition)())
|
---|
230 | (copy->*f)(Walker);
|
---|
231 | }
|
---|
232 | };
|
---|
233 | // one argument
|
---|
234 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
|
---|
235 | {
|
---|
236 | atom *Walker = start;
|
---|
237 | while (Walker->next != end) {
|
---|
238 | Walker = Walker->next;
|
---|
239 | if ((Walker->*condition)(t))
|
---|
240 | (copy->*f)(Walker);
|
---|
241 | }
|
---|
242 | };
|
---|
243 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
|
---|
244 | {
|
---|
245 | atom *Walker = start;
|
---|
246 | while (Walker->next != end) {
|
---|
247 | Walker = Walker->next;
|
---|
248 | if ((Walker->*condition)(t))
|
---|
249 | (copy->*f)(Walker);
|
---|
250 | }
|
---|
251 | };
|
---|
252 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
|
---|
253 | {
|
---|
254 | atom *Walker = start;
|
---|
255 | while (Walker->next != end) {
|
---|
256 | Walker = Walker->next;
|
---|
257 | if ((Walker->*condition)(t))
|
---|
258 | (copy->*f)(Walker);
|
---|
259 | }
|
---|
260 | };
|
---|
261 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
|
---|
262 | {
|
---|
263 | atom *Walker = start;
|
---|
264 | while (Walker->next != end) {
|
---|
265 | Walker = Walker->next;
|
---|
266 | if ((Walker->*condition)(t))
|
---|
267 | (copy->*f)(Walker);
|
---|
268 | }
|
---|
269 | };
|
---|
270 | // two arguments
|
---|
271 | 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
|
---|
272 | {
|
---|
273 | atom *Walker = start;
|
---|
274 | while (Walker->next != end) {
|
---|
275 | Walker = Walker->next;
|
---|
276 | if ((Walker->*condition)(t,u))
|
---|
277 | (copy->*f)(Walker);
|
---|
278 | }
|
---|
279 | };
|
---|
280 | 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
|
---|
281 | {
|
---|
282 | atom *Walker = start;
|
---|
283 | while (Walker->next != end) {
|
---|
284 | Walker = Walker->next;
|
---|
285 | if ((Walker->*condition)(t,u))
|
---|
286 | (copy->*f)(Walker);
|
---|
287 | }
|
---|
288 | };
|
---|
289 | 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
|
---|
290 | {
|
---|
291 | atom *Walker = start;
|
---|
292 | while (Walker->next != end) {
|
---|
293 | Walker = Walker->next;
|
---|
294 | if ((Walker->*condition)(t,u))
|
---|
295 | (copy->*f)(Walker);
|
---|
296 | }
|
---|
297 | };
|
---|
298 | 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
|
---|
299 | {
|
---|
300 | atom *Walker = start;
|
---|
301 | while (Walker->next != end) {
|
---|
302 | Walker = Walker->next;
|
---|
303 | if ((Walker->*condition)(t,u))
|
---|
304 | (copy->*f)(Walker);
|
---|
305 | }
|
---|
306 | };
|
---|
307 | // three arguments
|
---|
308 | 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
|
---|
309 | {
|
---|
310 | atom *Walker = start;
|
---|
311 | while (Walker->next != end) {
|
---|
312 | Walker = Walker->next;
|
---|
313 | if ((Walker->*condition)(t,u,v))
|
---|
314 | (copy->*f)(Walker);
|
---|
315 | }
|
---|
316 | };
|
---|
317 | 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
|
---|
318 | {
|
---|
319 | atom *Walker = start;
|
---|
320 | while (Walker->next != end) {
|
---|
321 | Walker = Walker->next;
|
---|
322 | if ((Walker->*condition)(t,u,v))
|
---|
323 | (copy->*f)(Walker);
|
---|
324 | }
|
---|
325 | };
|
---|
326 | 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
|
---|
327 | {
|
---|
328 | atom *Walker = start;
|
---|
329 | while (Walker->next != end) {
|
---|
330 | Walker = Walker->next;
|
---|
331 | if ((Walker->*condition)(t,u,v))
|
---|
332 | (copy->*f)(Walker);
|
---|
333 | }
|
---|
334 | };
|
---|
335 | 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
|
---|
336 | {
|
---|
337 | atom *Walker = start;
|
---|
338 | while (Walker->next != end) {
|
---|
339 | Walker = Walker->next;
|
---|
340 | if ((Walker->*condition)(t,u,v))
|
---|
341 | (copy->*f)(Walker);
|
---|
342 | }
|
---|
343 | };
|
---|
344 |
|
---|
345 | // ================== Acting on all Atoms ========================== //
|
---|
346 |
|
---|
347 | // zero arguments
|
---|
348 | template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
|
---|
349 | {
|
---|
350 | atom *Walker = start;
|
---|
351 | while (Walker->next != end) {
|
---|
352 | Walker = Walker->next;
|
---|
353 | (Walker->*f)();
|
---|
354 | }
|
---|
355 | };
|
---|
356 | template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
|
---|
357 | {
|
---|
358 | atom *Walker = start;
|
---|
359 | while (Walker->next != end) {
|
---|
360 | Walker = Walker->next;
|
---|
361 | (Walker->*f)();
|
---|
362 | }
|
---|
363 | };
|
---|
364 | // one argument
|
---|
365 | template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
|
---|
366 | {
|
---|
367 | atom *Walker = start;
|
---|
368 | while (Walker->next != end) {
|
---|
369 | Walker = Walker->next;
|
---|
370 | (Walker->*f)(t);
|
---|
371 | }
|
---|
372 | };
|
---|
373 | template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
|
---|
374 | {
|
---|
375 | atom *Walker = start;
|
---|
376 | while (Walker->next != end) {
|
---|
377 | Walker = Walker->next;
|
---|
378 | (Walker->*f)(t);
|
---|
379 | }
|
---|
380 | };
|
---|
381 | // two argument
|
---|
382 | template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
|
---|
383 | {
|
---|
384 | atom *Walker = start;
|
---|
385 | while (Walker->next != end) {
|
---|
386 | Walker = Walker->next;
|
---|
387 | (Walker->*f)(t, u);
|
---|
388 | }
|
---|
389 | };
|
---|
390 | template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
|
---|
391 | {
|
---|
392 | atom *Walker = start;
|
---|
393 | while (Walker->next != end) {
|
---|
394 | Walker = Walker->next;
|
---|
395 | (Walker->*f)(t, u);
|
---|
396 | }
|
---|
397 | };
|
---|
398 | // three argument
|
---|
399 | 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
|
---|
400 | {
|
---|
401 | atom *Walker = start;
|
---|
402 | while (Walker->next != end) {
|
---|
403 | Walker = Walker->next;
|
---|
404 | (Walker->*f)(t, u, v);
|
---|
405 | }
|
---|
406 | };
|
---|
407 | 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
|
---|
408 | {
|
---|
409 | atom *Walker = start;
|
---|
410 | while (Walker->next != end) {
|
---|
411 | Walker = Walker->next;
|
---|
412 | (Walker->*f)(t, u, v);
|
---|
413 | }
|
---|
414 | };
|
---|
415 | // four arguments
|
---|
416 | 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
|
---|
417 | {
|
---|
418 | atom *Walker = start;
|
---|
419 | while (Walker->next != end) {
|
---|
420 | Walker = Walker->next;
|
---|
421 | (Walker->*f)(t, u, v, w);
|
---|
422 | }
|
---|
423 | };
|
---|
424 | 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
|
---|
425 | {
|
---|
426 | atom *Walker = start;
|
---|
427 | while (Walker->next != end) {
|
---|
428 | Walker = Walker->next;
|
---|
429 | (Walker->*f)(t, u, v, w);
|
---|
430 | }
|
---|
431 | };
|
---|
432 |
|
---|
433 | // ===================== Accessing arrays indexed by some integer for each atom ======================
|
---|
434 |
|
---|
435 | // for atom ints
|
---|
436 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
|
---|
437 | {
|
---|
438 | atom *Walker = start;
|
---|
439 | int inc = 1;
|
---|
440 | while (Walker->next != end) {
|
---|
441 | Walker = Walker->next;
|
---|
442 | (*Setor) (&array[(Walker->*index)], &inc);
|
---|
443 | }
|
---|
444 | };
|
---|
445 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
|
---|
446 | {
|
---|
447 | atom *Walker = start;
|
---|
448 | while (Walker->next != end) {
|
---|
449 | Walker = Walker->next;
|
---|
450 | (*Setor) (&array[(Walker->*index)], &value);
|
---|
451 | }
|
---|
452 | };
|
---|
453 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
|
---|
454 | {
|
---|
455 | atom *Walker = start;
|
---|
456 | while (Walker->next != end) {
|
---|
457 | Walker = Walker->next;
|
---|
458 | (*Setor) (&array[(Walker->*index)], value);
|
---|
459 | }
|
---|
460 | };
|
---|
461 | // for element ints
|
---|
462 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
|
---|
463 | {
|
---|
464 | atom *Walker = start;
|
---|
465 | int inc = 1;
|
---|
466 | while (Walker->next != end) {
|
---|
467 | Walker = Walker->next;
|
---|
468 | (*Setor) (&array[(Walker->type->*index)], &inc);
|
---|
469 | }
|
---|
470 | };
|
---|
471 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
|
---|
472 | {
|
---|
473 | atom *Walker = start;
|
---|
474 | while (Walker->next != end) {
|
---|
475 | Walker = Walker->next;
|
---|
476 | (*Setor) (&array[(Walker->type->*index)], &value);
|
---|
477 | }
|
---|
478 | };
|
---|
479 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
|
---|
480 | {
|
---|
481 | atom *Walker = start;
|
---|
482 | while (Walker->next != end) {
|
---|
483 | Walker = Walker->next;
|
---|
484 | (*Setor) (&array[(Walker->type->*index)], value);
|
---|
485 | }
|
---|
486 | };
|
---|
487 |
|
---|
488 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
|
---|
489 | {
|
---|
490 | atom *Walker = start;
|
---|
491 | while (Walker->next != end) {
|
---|
492 | Walker = Walker->next;
|
---|
493 | array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
|
---|
494 | }
|
---|
495 | };
|
---|
496 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
|
---|
497 | {
|
---|
498 | atom *Walker = start;
|
---|
499 | while (Walker->next != end) {
|
---|
500 | Walker = Walker->next;
|
---|
501 | array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
|
---|
502 | }
|
---|
503 | };
|
---|
504 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
|
---|
505 | {
|
---|
506 | atom *Walker = start;
|
---|
507 | while (Walker->next != end) {
|
---|
508 | Walker = Walker->next;
|
---|
509 | array[(Walker->*index)] = (Walker->*Setor) (vect);
|
---|
510 | }
|
---|
511 | };
|
---|
512 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
|
---|
513 | {
|
---|
514 | atom *Walker = start;
|
---|
515 | while (Walker->next != end) {
|
---|
516 | Walker = Walker->next;
|
---|
517 | array[(Walker->*index)] = (Walker->*Setor) (vect);
|
---|
518 | }
|
---|
519 | };
|
---|
520 | template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
|
---|
521 | {
|
---|
522 | atom *Walker = start;
|
---|
523 | while (Walker->next != end) {
|
---|
524 | Walker = Walker->next;
|
---|
525 | Walker->*value = array[(Walker->*index)];
|
---|
526 | //Log() << Verbose(2) << *Walker << " gets " << (Walker->*value); << endl;
|
---|
527 | }
|
---|
528 | };
|
---|
529 |
|
---|
530 | template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
|
---|
531 | {
|
---|
532 | atom *Walker = start;
|
---|
533 | while (Walker->next != end) {
|
---|
534 | Walker = Walker->next;
|
---|
535 | Walker->*ptr = value;
|
---|
536 | //Log() << Verbose(2) << *Walker << " gets " << (Walker->*ptr) << endl;
|
---|
537 | }
|
---|
538 | };
|
---|
539 |
|
---|
540 |
|
---|
541 | #endif /* MOLECULE_TEMPLATE_HPP_ */
|
---|