[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
|
---|
[273382] | 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
|
---|
[49f802c] | 66 | {
|
---|
| 67 | atom *Walker = start;
|
---|
| 68 | while (Walker->next != end) {
|
---|
| 69 | Walker = Walker->next;
|
---|
| 70 | ((Walker->node)->*f)(t);
|
---|
| 71 | }
|
---|
| 72 | };
|
---|
[e9f8f9] | 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 | };
|
---|
[49f802c] | 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 | };
|
---|
[e9f8f9] | 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 | };
|
---|
[49f802c] | 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 | };
|
---|
[e9f8f9] | 107 |
|
---|
[266237] | 108 | // ========================= Summing over each Atoms =================================== //
|
---|
| 109 |
|
---|
| 110 | // zero arguments
|
---|
[4455f4] | 111 | template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
|
---|
[266237] | 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 | };
|
---|
[4455f4] | 121 | template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
|
---|
[266237] | 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
|
---|
[4455f4] | 132 | template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
|
---|
[266237] | 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 | };
|
---|
[4455f4] | 142 | template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
|
---|
[266237] | 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 |
|
---|
[e9f8f9] | 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 | };
|
---|
[49f802c] | 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 | };
|
---|
[e9f8f9] | 173 |
|
---|
| 174 | // ================== Acting with each Atoms on copy molecule ========================== //
|
---|
| 175 |
|
---|
| 176 | // zero arguments
|
---|
[b453f9] | 177 | template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
|
---|
[e9f8f9] | 178 | {
|
---|
| 179 | atom *Walker = start;
|
---|
| 180 | while (Walker->next != end) {
|
---|
| 181 | Walker = Walker->next;
|
---|
| 182 | (copy->*f)(Walker);
|
---|
| 183 | }
|
---|
| 184 | };
|
---|
[b453f9] | 185 | template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
|
---|
[e9f8f9] | 186 | {
|
---|
| 187 | atom *Walker = start;
|
---|
| 188 | while (Walker->next != end) {
|
---|
| 189 | Walker = Walker->next;
|
---|
| 190 | (copy->*f)(Walker);
|
---|
| 191 | }
|
---|
| 192 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 198 | {
|
---|
| 199 | atom *Walker = start;
|
---|
| 200 | while (Walker->next != end) {
|
---|
| 201 | Walker = Walker->next;
|
---|
[b453f9] | 202 | if ((Walker->*condition)())
|
---|
| 203 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 204 | }
|
---|
| 205 | };
|
---|
[b453f9] | 206 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
|
---|
[49f802c] | 207 | {
|
---|
| 208 | atom *Walker = start;
|
---|
| 209 | while (Walker->next != end) {
|
---|
| 210 | Walker = Walker->next;
|
---|
[b453f9] | 211 | if ((Walker->*condition)())
|
---|
| 212 | (copy->*f)(Walker);
|
---|
[49f802c] | 213 | }
|
---|
| 214 | };
|
---|
[b453f9] | 215 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
|
---|
[e9f8f9] | 216 | {
|
---|
| 217 | atom *Walker = start;
|
---|
| 218 | while (Walker->next != end) {
|
---|
| 219 | Walker = Walker->next;
|
---|
| 220 | if ((Walker->*condition)())
|
---|
| 221 | (copy->*f)(Walker);
|
---|
| 222 | }
|
---|
| 223 | };
|
---|
[b453f9] | 224 | template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
|
---|
[e9f8f9] | 225 | {
|
---|
| 226 | atom *Walker = start;
|
---|
| 227 | while (Walker->next != end) {
|
---|
| 228 | Walker = Walker->next;
|
---|
[b453f9] | 229 | if ((Walker->*condition)())
|
---|
[e9f8f9] | 230 | (copy->*f)(Walker);
|
---|
| 231 | }
|
---|
| 232 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 235 | {
|
---|
| 236 | atom *Walker = start;
|
---|
| 237 | while (Walker->next != end) {
|
---|
| 238 | Walker = Walker->next;
|
---|
[b453f9] | 239 | if ((Walker->*condition)(t))
|
---|
[e9f8f9] | 240 | (copy->*f)(Walker);
|
---|
| 241 | }
|
---|
| 242 | };
|
---|
[b453f9] | 243 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
|
---|
[e9f8f9] | 244 | {
|
---|
| 245 | atom *Walker = start;
|
---|
| 246 | while (Walker->next != end) {
|
---|
| 247 | Walker = Walker->next;
|
---|
[b453f9] | 248 | if ((Walker->*condition)(t))
|
---|
[e9f8f9] | 249 | (copy->*f)(Walker);
|
---|
| 250 | }
|
---|
| 251 | };
|
---|
[b453f9] | 252 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
|
---|
[e9f8f9] | 253 | {
|
---|
| 254 | atom *Walker = start;
|
---|
| 255 | while (Walker->next != end) {
|
---|
| 256 | Walker = Walker->next;
|
---|
[b453f9] | 257 | if ((Walker->*condition)(t))
|
---|
| 258 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 259 | }
|
---|
| 260 | };
|
---|
[b453f9] | 261 | template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
|
---|
[e9f8f9] | 262 | {
|
---|
| 263 | atom *Walker = start;
|
---|
| 264 | while (Walker->next != end) {
|
---|
| 265 | Walker = Walker->next;
|
---|
[b453f9] | 266 | if ((Walker->*condition)(t))
|
---|
| 267 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 268 | }
|
---|
| 269 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 272 | {
|
---|
| 273 | atom *Walker = start;
|
---|
| 274 | while (Walker->next != end) {
|
---|
| 275 | Walker = Walker->next;
|
---|
[b453f9] | 276 | if ((Walker->*condition)(t,u))
|
---|
| 277 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 278 | }
|
---|
| 279 | };
|
---|
[b453f9] | 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
|
---|
[49f802c] | 281 | {
|
---|
| 282 | atom *Walker = start;
|
---|
| 283 | while (Walker->next != end) {
|
---|
| 284 | Walker = Walker->next;
|
---|
[b453f9] | 285 | if ((Walker->*condition)(t,u))
|
---|
| 286 | (copy->*f)(Walker);
|
---|
[49f802c] | 287 | }
|
---|
| 288 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 290 | {
|
---|
| 291 | atom *Walker = start;
|
---|
| 292 | while (Walker->next != end) {
|
---|
| 293 | Walker = Walker->next;
|
---|
[b453f9] | 294 | if ((Walker->*condition)(t,u))
|
---|
| 295 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 296 | }
|
---|
| 297 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 299 | {
|
---|
| 300 | atom *Walker = start;
|
---|
| 301 | while (Walker->next != end) {
|
---|
| 302 | Walker = Walker->next;
|
---|
[b453f9] | 303 | if ((Walker->*condition)(t,u))
|
---|
| 304 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 305 | }
|
---|
| 306 | };
|
---|
[b453f9] | 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
|
---|
[49f802c] | 309 | {
|
---|
| 310 | atom *Walker = start;
|
---|
| 311 | while (Walker->next != end) {
|
---|
| 312 | Walker = Walker->next;
|
---|
[b453f9] | 313 | if ((Walker->*condition)(t,u,v))
|
---|
| 314 | (copy->*f)(Walker);
|
---|
[49f802c] | 315 | }
|
---|
| 316 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 318 | {
|
---|
| 319 | atom *Walker = start;
|
---|
| 320 | while (Walker->next != end) {
|
---|
| 321 | Walker = Walker->next;
|
---|
[b453f9] | 322 | if ((Walker->*condition)(t,u,v))
|
---|
| 323 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 324 | }
|
---|
| 325 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 327 | {
|
---|
| 328 | atom *Walker = start;
|
---|
| 329 | while (Walker->next != end) {
|
---|
| 330 | Walker = Walker->next;
|
---|
[b453f9] | 331 | if ((Walker->*condition)(t,u,v))
|
---|
| 332 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 333 | }
|
---|
| 334 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 336 | {
|
---|
| 337 | atom *Walker = start;
|
---|
| 338 | while (Walker->next != end) {
|
---|
| 339 | Walker = Walker->next;
|
---|
[b453f9] | 340 | if ((Walker->*condition)(t,u,v))
|
---|
| 341 | (copy->*f)(Walker);
|
---|
[e9f8f9] | 342 | }
|
---|
| 343 | };
|
---|
[b453f9] | 344 |
|
---|
| 345 | // ================== Acting on all Atoms ========================== //
|
---|
| 346 |
|
---|
| 347 | // zero arguments
|
---|
| 348 | template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
|
---|
[e9f8f9] | 349 | {
|
---|
| 350 | atom *Walker = start;
|
---|
| 351 | while (Walker->next != end) {
|
---|
| 352 | Walker = Walker->next;
|
---|
[b453f9] | 353 | (Walker->*f)();
|
---|
[e9f8f9] | 354 | }
|
---|
| 355 | };
|
---|
[b453f9] | 356 | template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
|
---|
[49f802c] | 357 | {
|
---|
| 358 | atom *Walker = start;
|
---|
| 359 | while (Walker->next != end) {
|
---|
| 360 | Walker = Walker->next;
|
---|
[b453f9] | 361 | (Walker->*f)();
|
---|
[49f802c] | 362 | }
|
---|
| 363 | };
|
---|
[b453f9] | 364 | // one argument
|
---|
| 365 | template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
|
---|
[e9f8f9] | 366 | {
|
---|
| 367 | atom *Walker = start;
|
---|
| 368 | while (Walker->next != end) {
|
---|
| 369 | Walker = Walker->next;
|
---|
[b453f9] | 370 | (Walker->*f)(t);
|
---|
[e9f8f9] | 371 | }
|
---|
| 372 | };
|
---|
[b453f9] | 373 | template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
|
---|
[e9f8f9] | 374 | {
|
---|
| 375 | atom *Walker = start;
|
---|
| 376 | while (Walker->next != end) {
|
---|
| 377 | Walker = Walker->next;
|
---|
[b453f9] | 378 | (Walker->*f)(t);
|
---|
[e9f8f9] | 379 | }
|
---|
| 380 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 383 | {
|
---|
| 384 | atom *Walker = start;
|
---|
| 385 | while (Walker->next != end) {
|
---|
| 386 | Walker = Walker->next;
|
---|
[b453f9] | 387 | (Walker->*f)(t, u);
|
---|
[e9f8f9] | 388 | }
|
---|
| 389 | };
|
---|
[b453f9] | 390 | template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
|
---|
[49f802c] | 391 | {
|
---|
| 392 | atom *Walker = start;
|
---|
| 393 | while (Walker->next != end) {
|
---|
| 394 | Walker = Walker->next;
|
---|
[b453f9] | 395 | (Walker->*f)(t, u);
|
---|
[49f802c] | 396 | }
|
---|
| 397 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 400 | {
|
---|
| 401 | atom *Walker = start;
|
---|
| 402 | while (Walker->next != end) {
|
---|
| 403 | Walker = Walker->next;
|
---|
[b453f9] | 404 | (Walker->*f)(t, u, v);
|
---|
[e9f8f9] | 405 | }
|
---|
| 406 | };
|
---|
[b453f9] | 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
|
---|
[e9f8f9] | 408 | {
|
---|
| 409 | atom *Walker = start;
|
---|
| 410 | while (Walker->next != end) {
|
---|
| 411 | Walker = Walker->next;
|
---|
[b453f9] | 412 | (Walker->*f)(t, u, v);
|
---|
[e9f8f9] | 413 | }
|
---|
| 414 | };
|
---|
[b453f9] | 415 | // four arguments
|
---|
[4455f4] | 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
|
---|
[e9f8f9] | 417 | {
|
---|
| 418 | atom *Walker = start;
|
---|
| 419 | while (Walker->next != end) {
|
---|
| 420 | Walker = Walker->next;
|
---|
| 421 | (Walker->*f)(t, u, v, w);
|
---|
| 422 | }
|
---|
| 423 | };
|
---|
[4455f4] | 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
|
---|
[49f802c] | 425 | {
|
---|
| 426 | atom *Walker = start;
|
---|
| 427 | while (Walker->next != end) {
|
---|
| 428 | Walker = Walker->next;
|
---|
| 429 | (Walker->*f)(t, u, v, w);
|
---|
| 430 | }
|
---|
| 431 | };
|
---|
[e9f8f9] | 432 |
|
---|
[4a7776a] | 433 | // ===================== Accessing arrays indexed by some integer for each atom ======================
|
---|
[e9f8f9] | 434 |
|
---|
| 435 | // for atom ints
|
---|
[b453f9] | 436 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
|
---|
[e9f8f9] | 437 | {
|
---|
| 438 | atom *Walker = start;
|
---|
[5034e1] | 439 | int inc = 1;
|
---|
[e9f8f9] | 440 | while (Walker->next != end) {
|
---|
| 441 | Walker = Walker->next;
|
---|
[5034e1] | 442 | (*Setor) (&array[(Walker->*index)], &inc);
|
---|
[e9f8f9] | 443 | }
|
---|
| 444 | };
|
---|
[b453f9] | 445 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
|
---|
[5034e1] | 446 | {
|
---|
| 447 | atom *Walker = start;
|
---|
| 448 | while (Walker->next != end) {
|
---|
| 449 | Walker = Walker->next;
|
---|
| 450 | (*Setor) (&array[(Walker->*index)], &value);
|
---|
| 451 | }
|
---|
| 452 | };
|
---|
[b453f9] | 453 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
|
---|
[e9f8f9] | 454 | {
|
---|
| 455 | atom *Walker = start;
|
---|
| 456 | while (Walker->next != end) {
|
---|
| 457 | Walker = Walker->next;
|
---|
| 458 | (*Setor) (&array[(Walker->*index)], value);
|
---|
| 459 | }
|
---|
| 460 | };
|
---|
[4455f4] | 461 | // for element ints
|
---|
[b453f9] | 462 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
|
---|
[e9f8f9] | 463 | {
|
---|
| 464 | atom *Walker = start;
|
---|
[5034e1] | 465 | int inc = 1;
|
---|
[e9f8f9] | 466 | while (Walker->next != end) {
|
---|
| 467 | Walker = Walker->next;
|
---|
[5034e1] | 468 | (*Setor) (&array[(Walker->type->*index)], &inc);
|
---|
[e9f8f9] | 469 | }
|
---|
| 470 | };
|
---|
[b453f9] | 471 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
|
---|
[5034e1] | 472 | {
|
---|
| 473 | atom *Walker = start;
|
---|
| 474 | while (Walker->next != end) {
|
---|
| 475 | Walker = Walker->next;
|
---|
| 476 | (*Setor) (&array[(Walker->type->*index)], &value);
|
---|
| 477 | }
|
---|
| 478 | };
|
---|
[b453f9] | 479 | template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
|
---|
[e9f8f9] | 480 | {
|
---|
| 481 | atom *Walker = start;
|
---|
| 482 | while (Walker->next != end) {
|
---|
| 483 | Walker = Walker->next;
|
---|
| 484 | (*Setor) (&array[(Walker->type->*index)], value);
|
---|
| 485 | }
|
---|
| 486 | };
|
---|
[4455f4] | 487 |
|
---|
[b453f9] | 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
|
---|
[49f802c] | 497 | {
|
---|
| 498 | atom *Walker = start;
|
---|
| 499 | while (Walker->next != end) {
|
---|
| 500 | Walker = Walker->next;
|
---|
| 501 | array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
|
---|
| 502 | }
|
---|
| 503 | };
|
---|
[b453f9] | 504 | template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
|
---|
[49f802c] | 505 | {
|
---|
| 506 | atom *Walker = start;
|
---|
| 507 | while (Walker->next != end) {
|
---|
| 508 | Walker = Walker->next;
|
---|
| 509 | array[(Walker->*index)] = (Walker->*Setor) (vect);
|
---|
| 510 | }
|
---|
| 511 | };
|
---|
[b453f9] | 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
|
---|
[5034e1] | 521 | {
|
---|
| 522 | atom *Walker = start;
|
---|
| 523 | while (Walker->next != end) {
|
---|
| 524 | Walker = Walker->next;
|
---|
| 525 | Walker->*value = array[(Walker->*index)];
|
---|
[e138de] | 526 | //Log() << Verbose(2) << *Walker << " gets " << (Walker->*value); << endl;
|
---|
[5034e1] | 527 | }
|
---|
| 528 | };
|
---|
| 529 |
|
---|
[b453f9] | 530 | template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
|
---|
[df8b19] | 531 | {
|
---|
| 532 | atom *Walker = start;
|
---|
| 533 | while (Walker->next != end) {
|
---|
| 534 | Walker = Walker->next;
|
---|
| 535 | Walker->*ptr = value;
|
---|
[e138de] | 536 | //Log() << Verbose(2) << *Walker << " gets " << (Walker->*ptr) << endl;
|
---|
[df8b19] | 537 | }
|
---|
| 538 | };
|
---|
| 539 |
|
---|
[5034e1] | 540 |
|
---|
[e9f8f9] | 541 | #endif /* MOLECULE_TEMPLATE_HPP_ */
|
---|