| [5d1611] | 1 | /* | 
|---|
|  | 2 | * World.hpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: Feb 3, 2010 | 
|---|
|  | 5 | *      Author: crueger | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #ifndef WORLD_HPP_ | 
|---|
|  | 9 | #define WORLD_HPP_ | 
|---|
|  | 10 |  | 
|---|
| [3e4fb6] | 11 | // include config.h | 
|---|
|  | 12 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 13 | #include <config.h> | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
| [b34306] | 16 | /*********************************************** includes ***********************************/ | 
|---|
|  | 17 |  | 
|---|
| [7c4e29] | 18 | #include <string> | 
|---|
| [d346b6] | 19 | #include <map> | 
|---|
| [fc1b24] | 20 | #include <vector> | 
|---|
| [354859] | 21 | #include <set> | 
|---|
| [7c4e29] | 22 | #include <boost/thread.hpp> | 
|---|
| [865a945] | 23 | #include <boost/shared_ptr.hpp> | 
|---|
| [5d1611] | 24 |  | 
|---|
| [3139b2] | 25 | #include "Actions/ActionTrait.hpp" | 
|---|
| [6f0841] | 26 | #include "Atom/AtomSet.hpp" | 
|---|
| [6e97e5] | 27 | #include "Descriptors/SelectiveIterator.hpp" | 
|---|
| [02ce36] | 28 | #include "CodePatterns/Observer/Observable.hpp" | 
|---|
|  | 29 | #include "CodePatterns/Observer/Observer.hpp" | 
|---|
| [ad011c] | 30 | #include "CodePatterns/Cacheable.hpp" | 
|---|
|  | 31 | #include "CodePatterns/Singleton.hpp" | 
|---|
| [02ce36] | 32 | #include "CodePatterns/Observer/ObservedContainer.hpp" | 
|---|
| [ad011c] | 33 | #include "CodePatterns/Range.hpp" | 
|---|
| [3e4fb6] | 34 | #include "IdPool.hpp" | 
|---|
| [4834f4] | 35 | #include "LinkedCell/LinkedCell_View.hpp" | 
|---|
| [3e4fb6] | 36 | #include "types.hpp" | 
|---|
| [5d1611] | 37 |  | 
|---|
| [4834f4] | 38 |  | 
|---|
| [5d1611] | 39 | // forward declarations | 
|---|
| [4d9c01] | 40 | class atom; | 
|---|
| [fc1b24] | 41 | class AtomDescriptor; | 
|---|
| [7a1ce5] | 42 | class AtomDescriptor_impl; | 
|---|
| [f71baf] | 43 | class BondGraph; | 
|---|
| [84c494] | 44 | class Box; | 
|---|
| [43dad6] | 45 | class config; | 
|---|
| [cca9ef] | 46 | class RealSpaceMatrix; | 
|---|
| [43dad6] | 47 | class molecule; | 
|---|
| [1c51c8] | 48 | class MoleculeDescriptor; | 
|---|
|  | 49 | class MoleculeDescriptor_impl; | 
|---|
| [43dad6] | 50 | class MoleculeListClass; | 
|---|
|  | 51 | class periodentafel; | 
|---|
|  | 52 | class ThermoStatContainer; | 
|---|
| [5d1611] | 53 |  | 
|---|
| [4834f4] | 54 | namespace LinkedCell { | 
|---|
|  | 55 | class LinkedCell_Controller; | 
|---|
|  | 56 | } | 
|---|
|  | 57 |  | 
|---|
| [ce7fdc] | 58 | namespace MoleCuilder { | 
|---|
|  | 59 | class ManipulateAtomsProcess; | 
|---|
|  | 60 | template<typename T> class AtomsCalculation; | 
|---|
|  | 61 | } | 
|---|
| [fa0b18] | 62 |  | 
|---|
| [b34306] | 63 | /****************************************** forward declarations *****************************/ | 
|---|
| [23b547] | 64 |  | 
|---|
| [b34306] | 65 | /********************************************** Class World *******************************/ | 
|---|
| [23b547] | 66 |  | 
|---|
| [7188b1] | 67 | namespace detail { | 
|---|
|  | 68 | template <class T> const T* lastChanged() | 
|---|
|  | 69 | { | 
|---|
|  | 70 | ASSERT(0, "detail::lastChanged() - only specializations may be used."); | 
|---|
|  | 71 | return NULL; | 
|---|
|  | 72 | } | 
|---|
|  | 73 | } | 
|---|
|  | 74 |  | 
|---|
| [23b547] | 75 | class World : public Singleton<World>, public Observable | 
|---|
| [5d1611] | 76 | { | 
|---|
| [23b547] | 77 |  | 
|---|
|  | 78 | // Make access to constructor and destructor possible from inside the singleton | 
|---|
|  | 79 | friend class Singleton<World>; | 
|---|
|  | 80 |  | 
|---|
| [b54ac8] | 81 | // necessary for coupling with descriptors | 
|---|
| [7a1ce5] | 82 | friend class AtomDescriptor_impl; | 
|---|
| [865a945] | 83 | friend class AtomDescriptor; | 
|---|
| [1c51c8] | 84 | friend class MoleculeDescriptor_impl; | 
|---|
|  | 85 | friend class MoleculeDescriptor; | 
|---|
| [41aa39] | 86 | // coupling with descriptors over selection | 
|---|
|  | 87 | friend class AtomSelectionDescriptor_impl; | 
|---|
| [cf0ca1] | 88 | friend class MoleculeSelectionDescriptor_impl; | 
|---|
| [865a945] | 89 |  | 
|---|
| [b54ac8] | 90 | // Actions, calculations etc associated with the World | 
|---|
| [ce7fdc] | 91 | friend class MoleCuilder::ManipulateAtomsProcess; | 
|---|
|  | 92 | template<typename> friend class MoleCuilder::AtomsCalculation; | 
|---|
| [5d1611] | 93 | public: | 
|---|
| [5f1d5b8] | 94 | // some typedefs for the CONSTRUCT_... macros (no "," allows in a single parameter name) | 
|---|
|  | 95 | typedef std::map<atomId_t,atom*> AtomSTLSet; | 
|---|
|  | 96 | typedef std::map<moleculeId_t,molecule*> MoleculeSTLSet; | 
|---|
| [23b547] | 97 |  | 
|---|
|  | 98 | // Types for Atom and Molecule structures | 
|---|
| [5f1d5b8] | 99 | typedef ObservedContainer< AtomSTLSet > AtomSet; | 
|---|
|  | 100 | typedef ObservedContainer< MoleculeSTLSet > MoleculeSet; | 
|---|
| [5d1611] | 101 |  | 
|---|
| [4d72e4] | 102 | typedef ATOMSET(std::vector) AtomComposite; | 
|---|
|  | 103 |  | 
|---|
| [7188b1] | 104 | /******* Notifications *******/ | 
|---|
|  | 105 |  | 
|---|
|  | 106 | //!> enumeration of present notification types | 
|---|
|  | 107 | enum NotificationType { | 
|---|
|  | 108 | AtomInserted, | 
|---|
|  | 109 | AtomRemoved, | 
|---|
| [5dfabd] | 110 | AtomPositionChanged, | 
|---|
| [7188b1] | 111 | AtomChanged, | 
|---|
|  | 112 | MoleculeInserted, | 
|---|
|  | 113 | MoleculeRemoved, | 
|---|
|  | 114 | MoleculeChanged, | 
|---|
|  | 115 | NotificationType_MAX | 
|---|
|  | 116 | }; | 
|---|
|  | 117 |  | 
|---|
|  | 118 | //>! access to last changed element (atom or molecule) | 
|---|
|  | 119 | template <class T> const T* lastChanged() const | 
|---|
|  | 120 | { return detail::lastChanged<T>(); } | 
|---|
|  | 121 |  | 
|---|
|  | 122 | /***** getter and setter *****/ | 
|---|
| [354859] | 123 | // reference to pointer is used for legacy reason... reference will be removed latter to keep encapsulation of World object | 
|---|
| [02ee15] | 124 | /** | 
|---|
|  | 125 | * returns the periodentafel for the world. | 
|---|
|  | 126 | */ | 
|---|
| [354859] | 127 | periodentafel *&getPeriode(); | 
|---|
| [02ee15] | 128 |  | 
|---|
| [f71baf] | 129 | /** Returns the BondGraph for the World. | 
|---|
|  | 130 | * | 
|---|
|  | 131 | * @return reference to BondGraph | 
|---|
|  | 132 | */ | 
|---|
|  | 133 | BondGraph *&getBondGraph(); | 
|---|
|  | 134 |  | 
|---|
|  | 135 | /** Sets the World's BondGraph. | 
|---|
|  | 136 | * | 
|---|
|  | 137 | * @param _BG new BondGraph | 
|---|
|  | 138 | */ | 
|---|
|  | 139 | void setBondGraph(BondGraph *_BG); | 
|---|
| [8e1f7af] | 140 | /** | 
|---|
|  | 141 | * returns the configuration for the world. | 
|---|
|  | 142 | */ | 
|---|
|  | 143 | config *&getConfig(); | 
|---|
|  | 144 |  | 
|---|
| [7188b1] | 145 | /** Returns a notification_ptr for a specific type. | 
|---|
|  | 146 | * | 
|---|
|  | 147 | * @param type request type | 
|---|
|  | 148 | * @return reference to instance | 
|---|
|  | 149 | */ | 
|---|
|  | 150 | Notification_ptr getNotification(enum NotificationType type) const; | 
|---|
|  | 151 |  | 
|---|
| [02ee15] | 152 | /** | 
|---|
|  | 153 | * returns the first atom that matches a given descriptor. | 
|---|
|  | 154 | * Do not rely on ordering for descriptors that match more than one atom. | 
|---|
|  | 155 | */ | 
|---|
| [7a1ce5] | 156 | atom* getAtom(AtomDescriptor descriptor); | 
|---|
| [02ee15] | 157 |  | 
|---|
|  | 158 | /** | 
|---|
|  | 159 | * returns a vector containing all atoms that match a given descriptor | 
|---|
|  | 160 | */ | 
|---|
| [4d72e4] | 161 | AtomComposite getAllAtoms(AtomDescriptor descriptor); | 
|---|
|  | 162 | AtomComposite getAllAtoms(); | 
|---|
| [b54ac8] | 163 |  | 
|---|
| [02ee15] | 164 | /** | 
|---|
|  | 165 | * returns a calculation that calls a given function on all atoms matching a descriptor. | 
|---|
|  | 166 | * the calculation is not called at this point and can be used as an action, i.e. be stored in | 
|---|
|  | 167 | * menus, be kept around for later use etc. | 
|---|
|  | 168 | */ | 
|---|
| [3139b2] | 169 | template<typename T> MoleCuilder::AtomsCalculation<T>* calcOnAtoms(boost::function<T(atom*)>,const MoleCuilder::ActionTrait &_trait,AtomDescriptor); | 
|---|
|  | 170 | template<typename T> MoleCuilder::AtomsCalculation<T>* calcOnAtoms(boost::function<T(atom*)>,const MoleCuilder::ActionTrait &_trait); | 
|---|
| [b54ac8] | 171 |  | 
|---|
| [02ee15] | 172 | /** | 
|---|
|  | 173 | * get the number of atoms in the World | 
|---|
|  | 174 | */ | 
|---|
| [354859] | 175 | int numAtoms(); | 
|---|
| [02ee15] | 176 |  | 
|---|
| [1c51c8] | 177 | /** | 
|---|
|  | 178 | * returns the first molecule that matches a given descriptor. | 
|---|
|  | 179 | * Do not rely on ordering for descriptors that match more than one molecule. | 
|---|
|  | 180 | */ | 
|---|
|  | 181 | molecule *getMolecule(MoleculeDescriptor descriptor); | 
|---|
|  | 182 |  | 
|---|
|  | 183 | /** | 
|---|
|  | 184 | * returns a vector containing all molecules that match a given descriptor | 
|---|
|  | 185 | */ | 
|---|
|  | 186 | std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor); | 
|---|
| [97ebf8] | 187 | std::vector<molecule*> getAllMolecules(); | 
|---|
| [1c51c8] | 188 |  | 
|---|
| [02ee15] | 189 | /** | 
|---|
|  | 190 | * get the number of molecules in the World | 
|---|
|  | 191 | */ | 
|---|
| [354859] | 192 | int numMolecules(); | 
|---|
|  | 193 |  | 
|---|
| [5f612ee] | 194 | /** | 
|---|
|  | 195 | * get the domain size as a symmetric matrix (6 components) | 
|---|
|  | 196 | */ | 
|---|
| [84c494] | 197 | Box& getDomain(); | 
|---|
|  | 198 |  | 
|---|
|  | 199 | /** | 
|---|
|  | 200 | * Set the domain size from a matrix object | 
|---|
|  | 201 | * | 
|---|
|  | 202 | * Matrix needs to be symmetric | 
|---|
|  | 203 | */ | 
|---|
| [cca9ef] | 204 | void setDomain(const RealSpaceMatrix &mat); | 
|---|
| [5f612ee] | 205 |  | 
|---|
|  | 206 | /** | 
|---|
|  | 207 | * set the domain size as a symmetric matrix (6 components) | 
|---|
|  | 208 | */ | 
|---|
|  | 209 | void setDomain(double * matrix); | 
|---|
|  | 210 |  | 
|---|
| [4834f4] | 211 | /** Returns a LinkedCell structure for obtaining neighbors quickly. | 
|---|
|  | 212 | * | 
|---|
|  | 213 | * @param distance desired linked cell edge length | 
|---|
|  | 214 | * @return view of restricted underlying LinkedCell_Model | 
|---|
|  | 215 | */ | 
|---|
|  | 216 | LinkedCell::LinkedCell_View getLinkedCell(const double distance); | 
|---|
|  | 217 |  | 
|---|
| [d297a3] | 218 | /** | 
|---|
|  | 219 | * set the current time of the world. | 
|---|
|  | 220 | * | 
|---|
|  | 221 | * @param _step time step to set to | 
|---|
|  | 222 | */ | 
|---|
|  | 223 | void setTime(const unsigned int _step); | 
|---|
|  | 224 |  | 
|---|
| [5f612ee] | 225 | /** | 
|---|
|  | 226 | * get the default name | 
|---|
|  | 227 | */ | 
|---|
| [387b36] | 228 | std::string getDefaultName(); | 
|---|
| [5f612ee] | 229 |  | 
|---|
|  | 230 | /** | 
|---|
|  | 231 | * set the default name | 
|---|
|  | 232 | */ | 
|---|
| [387b36] | 233 | void setDefaultName(std::string name); | 
|---|
| [5f612ee] | 234 |  | 
|---|
| [43dad6] | 235 | /** | 
|---|
|  | 236 | * get pointer to World's ThermoStatContainer | 
|---|
|  | 237 | */ | 
|---|
|  | 238 | ThermoStatContainer * getThermostats(); | 
|---|
|  | 239 |  | 
|---|
| [e4b5de] | 240 | /* | 
|---|
|  | 241 | * get the ExitFlag | 
|---|
|  | 242 | */ | 
|---|
|  | 243 | int getExitFlag(); | 
|---|
|  | 244 |  | 
|---|
|  | 245 | /* | 
|---|
|  | 246 | * set the ExitFlag | 
|---|
|  | 247 | */ | 
|---|
|  | 248 | void setExitFlag(int flag); | 
|---|
|  | 249 |  | 
|---|
| [354859] | 250 | /***** Methods to work with the World *****/ | 
|---|
| [02ee15] | 251 |  | 
|---|
|  | 252 | /** | 
|---|
|  | 253 | * create a new molecule. This method should be used whenever any kind of molecule is needed. Assigns a unique | 
|---|
|  | 254 | * ID to the molecule and stores it in the World for later retrieval. Do not create molecules directly. | 
|---|
|  | 255 | */ | 
|---|
| [354859] | 256 | molecule *createMolecule(); | 
|---|
| [02ee15] | 257 |  | 
|---|
| [cbc5fb] | 258 | void destroyMolecule(molecule*); | 
|---|
|  | 259 | void destroyMolecule(moleculeId_t); | 
|---|
|  | 260 |  | 
|---|
| [02ee15] | 261 | /** | 
|---|
|  | 262 | * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores | 
|---|
|  | 263 | * the atom in the World. If the atom is not destroyed it will automatically be destroyed when the world ends. | 
|---|
|  | 264 | */ | 
|---|
| [46d958] | 265 | atom *createAtom(); | 
|---|
| [02ee15] | 266 |  | 
|---|
|  | 267 | /** | 
|---|
|  | 268 | * Registers a Atom unknown to world. Needed in some rare cases, e.g. when cloning atoms, or in some unittests. | 
|---|
|  | 269 | * Do not re-register Atoms already known to the world since this will cause double-frees. | 
|---|
|  | 270 | */ | 
|---|
| [46d958] | 271 | int registerAtom(atom*); | 
|---|
| [02ee15] | 272 |  | 
|---|
|  | 273 | /** | 
|---|
|  | 274 | * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on | 
|---|
|  | 275 | * atom directly since this will leave the pointer inside the world. | 
|---|
|  | 276 | */ | 
|---|
| [46d958] | 277 | void destroyAtom(atom*); | 
|---|
| [02ee15] | 278 |  | 
|---|
|  | 279 | /** | 
|---|
|  | 280 | * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on | 
|---|
|  | 281 | * atom directly since this will leave the pointer inside the world. | 
|---|
|  | 282 | */ | 
|---|
| [cbc5fb] | 283 | void destroyAtom(atomId_t); | 
|---|
| [865a945] | 284 |  | 
|---|
| [88d586] | 285 | /** | 
|---|
|  | 286 | * used when changing an atom Id. | 
|---|
|  | 287 | * Unless you are calling this method from inside an atom don't fiddle with the third parameter. | 
|---|
|  | 288 | * | 
|---|
|  | 289 | * Return value indicates wether the change could be done or not. | 
|---|
|  | 290 | */ | 
|---|
|  | 291 | bool changeAtomId(atomId_t oldId, atomId_t newId, atom* target=0); | 
|---|
|  | 292 |  | 
|---|
| [a7a087] | 293 | /** | 
|---|
|  | 294 | * used when changing an molecule Id. | 
|---|
|  | 295 | * Unless you are calling this method from inside an moleucle don't fiddle with the third parameter. | 
|---|
|  | 296 | * | 
|---|
|  | 297 | * Return value indicates wether the change could be done or not. | 
|---|
|  | 298 | */ | 
|---|
|  | 299 | bool changeMoleculeId(moleculeId_t oldId, moleculeId_t newId, molecule* target=0); | 
|---|
|  | 300 |  | 
|---|
| [02ee15] | 301 | /** | 
|---|
|  | 302 | * Produces a process that calls a function on all Atoms matching a given descriptor. The process is not | 
|---|
|  | 303 | * called at this time, so it can be passed around, stored inside menuItems etc. | 
|---|
|  | 304 | */ | 
|---|
| [ce7fdc] | 305 | MoleCuilder::ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string,AtomDescriptor); | 
|---|
|  | 306 | MoleCuilder::ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string); | 
|---|
| [7c4e29] | 307 |  | 
|---|
| [fa0b18] | 308 | /**** | 
|---|
|  | 309 | * Iterators to use internal data structures | 
|---|
|  | 310 | * All these iterators are observed to track changes. | 
|---|
|  | 311 | * There is a corresponding protected section with unobserved iterators, | 
|---|
| [90c4280] | 312 | * which can be used internally when the extra speed is needed | 
|---|
| [fa0b18] | 313 | */ | 
|---|
|  | 314 |  | 
|---|
|  | 315 | typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor>       AtomIterator; | 
|---|
|  | 316 |  | 
|---|
|  | 317 | /** | 
|---|
|  | 318 | * returns an iterator over all Atoms matching a given descriptor. | 
|---|
|  | 319 | * This iterator is observed, so don't keep it around unnecessary to | 
|---|
|  | 320 | * avoid unintended blocking. | 
|---|
|  | 321 | */ | 
|---|
|  | 322 | AtomIterator getAtomIter(AtomDescriptor descr); | 
|---|
|  | 323 | AtomIterator getAtomIter(); | 
|---|
|  | 324 |  | 
|---|
|  | 325 | AtomIterator atomEnd(); | 
|---|
|  | 326 |  | 
|---|
| [e3d865] | 327 | typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor>   MoleculeIterator; | 
|---|
| [51be2a] | 328 |  | 
|---|
| [90c4280] | 329 | /** | 
|---|
|  | 330 | * returns an iterator over all Molecules matching a given descriptor. | 
|---|
|  | 331 | * This iterator is observed, so don't keep it around unnecessary to | 
|---|
|  | 332 | * avoid unintended blocking. | 
|---|
|  | 333 | */ | 
|---|
| [5d880e] | 334 | MoleculeIterator getMoleculeIter(MoleculeDescriptor descr); | 
|---|
|  | 335 | MoleculeIterator getMoleculeIter(); | 
|---|
|  | 336 |  | 
|---|
|  | 337 | MoleculeIterator moleculeEnd(); | 
|---|
|  | 338 |  | 
|---|
| [90c4280] | 339 | /******** Selections of molecules and Atoms *************/ | 
|---|
|  | 340 | void clearAtomSelection(); | 
|---|
| [e4afb4] | 341 | void selectAtom(const atom*); | 
|---|
|  | 342 | void selectAtom(const atomId_t); | 
|---|
| [90c4280] | 343 | void selectAllAtoms(AtomDescriptor); | 
|---|
| [e4afb4] | 344 | void selectAtomsOfMolecule(const molecule*); | 
|---|
|  | 345 | void selectAtomsOfMolecule(const moleculeId_t); | 
|---|
|  | 346 | void unselectAtom(const atom*); | 
|---|
|  | 347 | void unselectAtom(const atomId_t); | 
|---|
| [61d655e] | 348 | void unselectAllAtoms(AtomDescriptor); | 
|---|
| [e4afb4] | 349 | void unselectAtomsOfMolecule(const molecule*); | 
|---|
|  | 350 | void unselectAtomsOfMolecule(const moleculeId_t); | 
|---|
| [e472eab] | 351 | size_t countSelectedAtoms() const; | 
|---|
| [e4afb4] | 352 | bool isSelected(const atom *_atom) const; | 
|---|
| [89643d] | 353 | bool isAtomSelected(const atomId_t no) const; | 
|---|
| [e472eab] | 354 | const std::vector<atom *> getSelectedAtoms() const; | 
|---|
| [90c4280] | 355 |  | 
|---|
|  | 356 | void clearMoleculeSelection(); | 
|---|
| [e4afb4] | 357 | void selectMolecule(const molecule*); | 
|---|
|  | 358 | void selectMolecule(const moleculeId_t); | 
|---|
| [e472eab] | 359 | void selectAllMolecules(MoleculeDescriptor); | 
|---|
| [e4afb4] | 360 | void selectMoleculeOfAtom(const atom*); | 
|---|
|  | 361 | void selectMoleculeOfAtom(const atomId_t); | 
|---|
|  | 362 | void unselectMolecule(const molecule*); | 
|---|
|  | 363 | void unselectMolecule(const moleculeId_t); | 
|---|
| [e472eab] | 364 | void unselectAllMolecules(MoleculeDescriptor); | 
|---|
| [e4afb4] | 365 | void unselectMoleculeOfAtom(const atom*); | 
|---|
|  | 366 | void unselectMoleculeOfAtom(const atomId_t); | 
|---|
| [e472eab] | 367 | size_t countSelectedMolecules() const; | 
|---|
| [e4afb4] | 368 | bool isSelected(const molecule *_mol) const; | 
|---|
| [89643d] | 369 | bool isMoleculeSelected(const moleculeId_t no) const; | 
|---|
| [e472eab] | 370 | const std::vector<molecule *> getSelectedMolecules() const; | 
|---|
| [90c4280] | 371 |  | 
|---|
| [3839e5] | 372 | /******************** Iterators to selections *****************/ | 
|---|
|  | 373 | typedef AtomSet::iterator AtomSelectionIterator; | 
|---|
|  | 374 | AtomSelectionIterator beginAtomSelection(); | 
|---|
|  | 375 | AtomSelectionIterator endAtomSelection(); | 
|---|
| [38f991] | 376 | typedef AtomSet::const_iterator AtomSelectionConstIterator; | 
|---|
|  | 377 | AtomSelectionConstIterator beginAtomSelection() const; | 
|---|
|  | 378 | AtomSelectionConstIterator endAtomSelection() const; | 
|---|
| [3839e5] | 379 |  | 
|---|
|  | 380 | typedef MoleculeSet::iterator MoleculeSelectionIterator; | 
|---|
|  | 381 | MoleculeSelectionIterator beginMoleculeSelection(); | 
|---|
|  | 382 | MoleculeSelectionIterator endMoleculeSelection(); | 
|---|
| [38f991] | 383 | typedef MoleculeSet::const_iterator MoleculeSelectionConstIterator; | 
|---|
|  | 384 | MoleculeSelectionConstIterator beginMoleculeSelection() const; | 
|---|
|  | 385 | MoleculeSelectionConstIterator endMoleculeSelection() const; | 
|---|
| [3839e5] | 386 |  | 
|---|
| [865a945] | 387 | protected: | 
|---|
| [fa0b18] | 388 | /**** | 
|---|
|  | 389 | * Iterators to use internal data structures | 
|---|
|  | 390 | * All these iterators are unobserved for speed reasons. | 
|---|
|  | 391 | * There is a corresponding public section to these methods, | 
|---|
|  | 392 | * which produce observed iterators.*/ | 
|---|
| [1c51c8] | 393 |  | 
|---|
|  | 394 | // Atoms | 
|---|
| [e3d865] | 395 | typedef SelectiveIterator<atom*,AtomSet::set_t,AtomDescriptor>        internal_AtomIterator; | 
|---|
| [865a945] | 396 |  | 
|---|
| [02ee15] | 397 | /** | 
|---|
|  | 398 | * returns an iterator over all Atoms matching a given descriptor. | 
|---|
|  | 399 | * used for internal purposes, like AtomProcesses and AtomCalculations. | 
|---|
|  | 400 | */ | 
|---|
| [fa0b18] | 401 | internal_AtomIterator getAtomIter_internal(AtomDescriptor descr); | 
|---|
| [02ee15] | 402 |  | 
|---|
|  | 403 | /** | 
|---|
| [d2dbac0] | 404 | * returns an iterator to the end of the AtomSet. Due to overloading this iterator | 
|---|
| [02ee15] | 405 | * can be compared to iterators produced by getAtomIter (see the mis-matching types). | 
|---|
|  | 406 | * Thus it can be used to detect when such an iterator is at the end of the list. | 
|---|
|  | 407 | * used for internal purposes, like AtomProcesses and AtomCalculations. | 
|---|
|  | 408 | */ | 
|---|
| [fa0b18] | 409 | internal_AtomIterator atomEnd_internal(); | 
|---|
| [865a945] | 410 |  | 
|---|
| [1c51c8] | 411 | // Molecules | 
|---|
| [e3d865] | 412 | typedef SelectiveIterator<molecule*,MoleculeSet::set_t,MoleculeDescriptor>   internal_MoleculeIterator; | 
|---|
| [51be2a] | 413 |  | 
|---|
| [1c51c8] | 414 |  | 
|---|
|  | 415 | /** | 
|---|
|  | 416 | * returns an iterator over all Molecules matching a given descriptor. | 
|---|
|  | 417 | * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. | 
|---|
|  | 418 | */ | 
|---|
| [e3d865] | 419 | internal_MoleculeIterator getMoleculeIter_internal(MoleculeDescriptor descr); | 
|---|
| [1c51c8] | 420 |  | 
|---|
|  | 421 | /** | 
|---|
|  | 422 | * returns an iterator to the end of the MoleculeSet. Due to overloading this iterator | 
|---|
|  | 423 | * can be compared to iterators produced by getMoleculeIter (see the mis-matching types). | 
|---|
|  | 424 | * Thus it can be used to detect when such an iterator is at the end of the list. | 
|---|
|  | 425 | * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. | 
|---|
|  | 426 | */ | 
|---|
| [e3d865] | 427 | internal_MoleculeIterator moleculeEnd_internal(); | 
|---|
| [1c51c8] | 428 |  | 
|---|
|  | 429 |  | 
|---|
| [afb47f] | 430 | /******* Internal manipulation routines for double callback and Observer mechanism ******/ | 
|---|
| [ce7fdc] | 431 | void doManipulate(MoleCuilder::ManipulateAtomsProcess *); | 
|---|
| [afb47f] | 432 |  | 
|---|
| [5d1611] | 433 | private: | 
|---|
| [88d586] | 434 |  | 
|---|
|  | 435 | atomId_t getNextAtomId(); | 
|---|
|  | 436 | void releaseAtomId(atomId_t); | 
|---|
|  | 437 | bool reserveAtomId(atomId_t); | 
|---|
| [127a8e] | 438 | void defragAtomIdPool(); | 
|---|
|  | 439 |  | 
|---|
|  | 440 | moleculeId_t getNextMoleculeId(); | 
|---|
|  | 441 | void releaseMoleculeId(moleculeId_t); | 
|---|
|  | 442 | bool reserveMoleculeId(moleculeId_t); | 
|---|
|  | 443 | void defragMoleculeIdPool(); | 
|---|
| [88d586] | 444 |  | 
|---|
| [7188b1] | 445 | friend const atom *detail::lastChanged<atom>(); | 
|---|
|  | 446 | friend const molecule *detail::lastChanged<molecule>(); | 
|---|
|  | 447 | static atom *_lastchangedatom; | 
|---|
|  | 448 | static molecule*_lastchangedmol; | 
|---|
|  | 449 |  | 
|---|
| [f71baf] | 450 | BondGraph *BG; | 
|---|
| [5d1611] | 451 | periodentafel *periode; | 
|---|
| [8e1f7af] | 452 | config *configuration; | 
|---|
| [84c494] | 453 | Box *cell_size; | 
|---|
| [4834f4] | 454 | LinkedCell::LinkedCell_Controller *LCcontroller; | 
|---|
| [387b36] | 455 | std::string defaultName; | 
|---|
| [43dad6] | 456 | class ThermoStatContainer *Thermostats; | 
|---|
| [e4b5de] | 457 | int ExitFlag; | 
|---|
| [6e97e5] | 458 | private: | 
|---|
| [127a8e] | 459 |  | 
|---|
| [1a76a6] | 460 | AtomSet atoms; | 
|---|
| [90c4280] | 461 | AtomSet selectedAtoms; | 
|---|
| [127a8e] | 462 | /** | 
|---|
|  | 463 | * stores the pool for all available AtomIds below currAtomId | 
|---|
|  | 464 | * | 
|---|
|  | 465 | * The pool contains ranges of free ids in the form [bottom,top). | 
|---|
|  | 466 | */ | 
|---|
| [3e4fb6] | 467 | IdPool<atomId_t> atomIdPool; | 
|---|
| [127a8e] | 468 |  | 
|---|
| [d2dbac0] | 469 | MoleculeSet molecules; | 
|---|
| [90c4280] | 470 | MoleculeSet selectedMolecules; | 
|---|
| [1a76a6] | 471 | /** | 
|---|
|  | 472 | * stores the pool for all available AtomIds below currAtomId | 
|---|
|  | 473 | * | 
|---|
|  | 474 | * The pool contains ranges of free ids in the form [bottom,top). | 
|---|
|  | 475 | */ | 
|---|
| [3e4fb6] | 476 | IdPool<moleculeId_t> moleculeIdPool; | 
|---|
|  | 477 |  | 
|---|
| [5d1611] | 478 | private: | 
|---|
| [02ee15] | 479 | /** | 
|---|
|  | 480 | * private constructor to ensure creation of the world using | 
|---|
|  | 481 | * the singleton pattern. | 
|---|
|  | 482 | */ | 
|---|
| [5d1611] | 483 | World(); | 
|---|
| [02ee15] | 484 |  | 
|---|
|  | 485 | /** | 
|---|
|  | 486 | * private destructor to ensure destruction of the world using the | 
|---|
|  | 487 | * singleton pattern. | 
|---|
|  | 488 | */ | 
|---|
| [5d1611] | 489 | virtual ~World(); | 
|---|
|  | 490 |  | 
|---|
|  | 491 | /***** | 
|---|
|  | 492 | * some legacy stuff that is include for now but will be removed later | 
|---|
|  | 493 | *****/ | 
|---|
|  | 494 | public: | 
|---|
| [354859] | 495 | MoleculeListClass *&getMolecules(); | 
|---|
| [4d9c01] | 496 |  | 
|---|
| [5d1611] | 497 | private: | 
|---|
| [354859] | 498 | MoleculeListClass *molecules_deprecated; | 
|---|
| [5d1611] | 499 | }; | 
|---|
|  | 500 |  | 
|---|
| [7188b1] | 501 | /** Externalized stuff as member functions cannot be specialized without | 
|---|
|  | 502 | *  specializing the class, too. | 
|---|
|  | 503 | */ | 
|---|
|  | 504 | namespace detail { | 
|---|
|  | 505 | template <>       inline  const atom* lastChanged<atom>() { return World::_lastchangedatom; } | 
|---|
|  | 506 | template <>       inline  const molecule* lastChanged<molecule>() { return World::_lastchangedmol; } | 
|---|
|  | 507 | } | 
|---|
|  | 508 |  | 
|---|
|  | 509 |  | 
|---|
| [5d1611] | 510 | #endif /* WORLD_HPP_ */ | 
|---|