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