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