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