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