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