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