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