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