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