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