| [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 |  | 
|---|
| [2a8731] | 243 | /** | 
|---|
|  | 244 | * get the current time of the world. | 
|---|
|  | 245 | * | 
|---|
|  | 246 | * @return current time step | 
|---|
|  | 247 | */ | 
|---|
|  | 248 | const unsigned getTime() const; | 
|---|
|  | 249 |  | 
|---|
| [5f612ee] | 250 | /** | 
|---|
|  | 251 | * get the default name | 
|---|
|  | 252 | */ | 
|---|
| [387b36] | 253 | std::string getDefaultName(); | 
|---|
| [5f612ee] | 254 |  | 
|---|
|  | 255 | /** | 
|---|
|  | 256 | * set the default name | 
|---|
|  | 257 | */ | 
|---|
| [387b36] | 258 | void setDefaultName(std::string name); | 
|---|
| [5f612ee] | 259 |  | 
|---|
| [43dad6] | 260 | /** | 
|---|
|  | 261 | * get pointer to World's ThermoStatContainer | 
|---|
|  | 262 | */ | 
|---|
|  | 263 | ThermoStatContainer * getThermostats(); | 
|---|
|  | 264 |  | 
|---|
| [e4b5de] | 265 | /* | 
|---|
|  | 266 | * get the ExitFlag | 
|---|
|  | 267 | */ | 
|---|
|  | 268 | int getExitFlag(); | 
|---|
|  | 269 |  | 
|---|
|  | 270 | /* | 
|---|
|  | 271 | * set the ExitFlag | 
|---|
|  | 272 | */ | 
|---|
|  | 273 | void setExitFlag(int flag); | 
|---|
|  | 274 |  | 
|---|
| [354859] | 275 | /***** Methods to work with the World *****/ | 
|---|
| [02ee15] | 276 |  | 
|---|
|  | 277 | /** | 
|---|
|  | 278 | * create a new molecule. This method should be used whenever any kind of molecule is needed. Assigns a unique | 
|---|
|  | 279 | * ID to the molecule and stores it in the World for later retrieval. Do not create molecules directly. | 
|---|
|  | 280 | */ | 
|---|
| [354859] | 281 | molecule *createMolecule(); | 
|---|
| [02ee15] | 282 |  | 
|---|
| [cbc5fb] | 283 | void destroyMolecule(molecule*); | 
|---|
|  | 284 | void destroyMolecule(moleculeId_t); | 
|---|
|  | 285 |  | 
|---|
| [02ee15] | 286 | /** | 
|---|
|  | 287 | * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores | 
|---|
|  | 288 | * the atom in the World. If the atom is not destroyed it will automatically be destroyed when the world ends. | 
|---|
|  | 289 | */ | 
|---|
| [46d958] | 290 | atom *createAtom(); | 
|---|
| [02ee15] | 291 |  | 
|---|
|  | 292 | /** | 
|---|
|  | 293 | * Registers a Atom unknown to world. Needed in some rare cases, e.g. when cloning atoms, or in some unittests. | 
|---|
|  | 294 | * Do not re-register Atoms already known to the world since this will cause double-frees. | 
|---|
|  | 295 | */ | 
|---|
| [46d958] | 296 | int registerAtom(atom*); | 
|---|
| [02ee15] | 297 |  | 
|---|
|  | 298 | /** | 
|---|
|  | 299 | * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on | 
|---|
|  | 300 | * atom directly since this will leave the pointer inside the world. | 
|---|
|  | 301 | */ | 
|---|
| [46d958] | 302 | void destroyAtom(atom*); | 
|---|
| [02ee15] | 303 |  | 
|---|
|  | 304 | /** | 
|---|
|  | 305 | * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on | 
|---|
|  | 306 | * atom directly since this will leave the pointer inside the world. | 
|---|
|  | 307 | */ | 
|---|
| [cbc5fb] | 308 | void destroyAtom(atomId_t); | 
|---|
| [865a945] | 309 |  | 
|---|
| [88d586] | 310 | /** | 
|---|
|  | 311 | * used when changing an atom Id. | 
|---|
|  | 312 | * Unless you are calling this method from inside an atom don't fiddle with the third parameter. | 
|---|
|  | 313 | * | 
|---|
| [992bd5] | 314 | * Return value indicates whether the change could be done or not. | 
|---|
| [88d586] | 315 | */ | 
|---|
|  | 316 | bool changeAtomId(atomId_t oldId, atomId_t newId, atom* target=0); | 
|---|
|  | 317 |  | 
|---|
| [a7a087] | 318 | /** | 
|---|
|  | 319 | * used when changing an molecule Id. | 
|---|
| [992bd5] | 320 | * Unless you are calling this method from inside an molecule don't fiddle with the third parameter. | 
|---|
| [a7a087] | 321 | * | 
|---|
| [992bd5] | 322 | * Return value indicates whether the change could be done or not. | 
|---|
| [a7a087] | 323 | */ | 
|---|
|  | 324 | bool changeMoleculeId(moleculeId_t oldId, moleculeId_t newId, molecule* target=0); | 
|---|
|  | 325 |  | 
|---|
| [02ee15] | 326 | /** | 
|---|
|  | 327 | * Produces a process that calls a function on all Atoms matching a given descriptor. The process is not | 
|---|
|  | 328 | * called at this time, so it can be passed around, stored inside menuItems etc. | 
|---|
|  | 329 | */ | 
|---|
| [ce7fdc] | 330 | MoleCuilder::ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string,AtomDescriptor); | 
|---|
|  | 331 | MoleCuilder::ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string); | 
|---|
| [7c4e29] | 332 |  | 
|---|
| [fa0b18] | 333 | /**** | 
|---|
|  | 334 | * Iterators to use internal data structures | 
|---|
|  | 335 | * All these iterators are observed to track changes. | 
|---|
|  | 336 | * There is a corresponding protected section with unobserved iterators, | 
|---|
| [90c4280] | 337 | * which can be used internally when the extra speed is needed | 
|---|
| [fa0b18] | 338 | */ | 
|---|
|  | 339 |  | 
|---|
|  | 340 | typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor>       AtomIterator; | 
|---|
| [feb5d0] | 341 | typedef SelectiveConstIterator<atom*,AtomSet,AtomDescriptor>       AtomConstIterator; | 
|---|
| [fa0b18] | 342 |  | 
|---|
|  | 343 | /** | 
|---|
|  | 344 | * returns an iterator over all Atoms matching a given descriptor. | 
|---|
|  | 345 | * This iterator is observed, so don't keep it around unnecessary to | 
|---|
|  | 346 | * avoid unintended blocking. | 
|---|
|  | 347 | */ | 
|---|
|  | 348 | AtomIterator getAtomIter(AtomDescriptor descr); | 
|---|
| [feb5d0] | 349 | AtomConstIterator getAtomIter(AtomDescriptor descr) const; | 
|---|
| [fa0b18] | 350 | AtomIterator getAtomIter(); | 
|---|
| [feb5d0] | 351 | AtomConstIterator getAtomIter() const; | 
|---|
| [fa0b18] | 352 |  | 
|---|
|  | 353 | AtomIterator atomEnd(); | 
|---|
| [feb5d0] | 354 | AtomConstIterator atomEnd() const; | 
|---|
| [fa0b18] | 355 |  | 
|---|
| [e3d865] | 356 | typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor>   MoleculeIterator; | 
|---|
| [feb5d0] | 357 | typedef SelectiveConstIterator<molecule*,MoleculeSet,MoleculeDescriptor>   MoleculeConstIterator; | 
|---|
| [51be2a] | 358 |  | 
|---|
| [90c4280] | 359 | /** | 
|---|
|  | 360 | * returns an iterator over all Molecules matching a given descriptor. | 
|---|
|  | 361 | * This iterator is observed, so don't keep it around unnecessary to | 
|---|
|  | 362 | * avoid unintended blocking. | 
|---|
|  | 363 | */ | 
|---|
| [5d880e] | 364 | MoleculeIterator getMoleculeIter(MoleculeDescriptor descr); | 
|---|
| [feb5d0] | 365 | MoleculeConstIterator getMoleculeIter(MoleculeDescriptor descr) const; | 
|---|
| [5d880e] | 366 | MoleculeIterator getMoleculeIter(); | 
|---|
| [feb5d0] | 367 | MoleculeConstIterator getMoleculeIter() const; | 
|---|
| [5d880e] | 368 |  | 
|---|
|  | 369 | MoleculeIterator moleculeEnd(); | 
|---|
| [feb5d0] | 370 | MoleculeConstIterator moleculeEnd() const; | 
|---|
| [5d880e] | 371 |  | 
|---|
| [90c4280] | 372 | /******** Selections of molecules and Atoms *************/ | 
|---|
|  | 373 | void clearAtomSelection(); | 
|---|
| [ebc499] | 374 | void invertAtomSelection(); | 
|---|
| [e4afb4] | 375 | void selectAtom(const atom*); | 
|---|
|  | 376 | void selectAtom(const atomId_t); | 
|---|
| [90c4280] | 377 | void selectAllAtoms(AtomDescriptor); | 
|---|
| [e4afb4] | 378 | void selectAtomsOfMolecule(const molecule*); | 
|---|
|  | 379 | void selectAtomsOfMolecule(const moleculeId_t); | 
|---|
|  | 380 | void unselectAtom(const atom*); | 
|---|
|  | 381 | void unselectAtom(const atomId_t); | 
|---|
| [61d655e] | 382 | void unselectAllAtoms(AtomDescriptor); | 
|---|
| [e4afb4] | 383 | void unselectAtomsOfMolecule(const molecule*); | 
|---|
|  | 384 | void unselectAtomsOfMolecule(const moleculeId_t); | 
|---|
| [e472eab] | 385 | size_t countSelectedAtoms() const; | 
|---|
| [e4afb4] | 386 | bool isSelected(const atom *_atom) const; | 
|---|
| [89643d] | 387 | bool isAtomSelected(const atomId_t no) const; | 
|---|
| [e472eab] | 388 | const std::vector<atom *> getSelectedAtoms() const; | 
|---|
| [90c4280] | 389 |  | 
|---|
|  | 390 | void clearMoleculeSelection(); | 
|---|
| [ebc499] | 391 | void invertMoleculeSelection(); | 
|---|
| [e4afb4] | 392 | void selectMolecule(const molecule*); | 
|---|
|  | 393 | void selectMolecule(const moleculeId_t); | 
|---|
| [e472eab] | 394 | void selectAllMolecules(MoleculeDescriptor); | 
|---|
| [e4afb4] | 395 | void selectMoleculeOfAtom(const atom*); | 
|---|
|  | 396 | void selectMoleculeOfAtom(const atomId_t); | 
|---|
|  | 397 | void unselectMolecule(const molecule*); | 
|---|
|  | 398 | void unselectMolecule(const moleculeId_t); | 
|---|
| [e472eab] | 399 | void unselectAllMolecules(MoleculeDescriptor); | 
|---|
| [e4afb4] | 400 | void unselectMoleculeOfAtom(const atom*); | 
|---|
|  | 401 | void unselectMoleculeOfAtom(const atomId_t); | 
|---|
| [e472eab] | 402 | size_t countSelectedMolecules() const; | 
|---|
| [e4afb4] | 403 | bool isSelected(const molecule *_mol) const; | 
|---|
| [89643d] | 404 | bool isMoleculeSelected(const moleculeId_t no) const; | 
|---|
| [e472eab] | 405 | const std::vector<molecule *> getSelectedMolecules() const; | 
|---|
| [90c4280] | 406 |  | 
|---|
| [3839e5] | 407 | /******************** Iterators to selections *****************/ | 
|---|
|  | 408 | typedef AtomSet::iterator AtomSelectionIterator; | 
|---|
|  | 409 | AtomSelectionIterator beginAtomSelection(); | 
|---|
|  | 410 | AtomSelectionIterator endAtomSelection(); | 
|---|
| [38f991] | 411 | typedef AtomSet::const_iterator AtomSelectionConstIterator; | 
|---|
|  | 412 | AtomSelectionConstIterator beginAtomSelection() const; | 
|---|
|  | 413 | AtomSelectionConstIterator endAtomSelection() const; | 
|---|
| [3839e5] | 414 |  | 
|---|
|  | 415 | typedef MoleculeSet::iterator MoleculeSelectionIterator; | 
|---|
|  | 416 | MoleculeSelectionIterator beginMoleculeSelection(); | 
|---|
|  | 417 | MoleculeSelectionIterator endMoleculeSelection(); | 
|---|
| [38f991] | 418 | typedef MoleculeSet::const_iterator MoleculeSelectionConstIterator; | 
|---|
|  | 419 | MoleculeSelectionConstIterator beginMoleculeSelection() const; | 
|---|
|  | 420 | MoleculeSelectionConstIterator endMoleculeSelection() const; | 
|---|
| [3839e5] | 421 |  | 
|---|
| [865a945] | 422 | protected: | 
|---|
| [fa0b18] | 423 | /**** | 
|---|
|  | 424 | * Iterators to use internal data structures | 
|---|
|  | 425 | * All these iterators are unobserved for speed reasons. | 
|---|
|  | 426 | * There is a corresponding public section to these methods, | 
|---|
|  | 427 | * which produce observed iterators.*/ | 
|---|
| [1c51c8] | 428 |  | 
|---|
|  | 429 | // Atoms | 
|---|
| [e3d865] | 430 | typedef SelectiveIterator<atom*,AtomSet::set_t,AtomDescriptor>        internal_AtomIterator; | 
|---|
| [865a945] | 431 |  | 
|---|
| [02ee15] | 432 | /** | 
|---|
|  | 433 | * returns an iterator over all Atoms matching a given descriptor. | 
|---|
|  | 434 | * used for internal purposes, like AtomProcesses and AtomCalculations. | 
|---|
|  | 435 | */ | 
|---|
| [fa0b18] | 436 | internal_AtomIterator getAtomIter_internal(AtomDescriptor descr); | 
|---|
| [02ee15] | 437 |  | 
|---|
|  | 438 | /** | 
|---|
| [d2dbac0] | 439 | * returns an iterator to the end of the AtomSet. Due to overloading this iterator | 
|---|
| [02ee15] | 440 | * can be compared to iterators produced by getAtomIter (see the mis-matching types). | 
|---|
|  | 441 | * Thus it can be used to detect when such an iterator is at the end of the list. | 
|---|
|  | 442 | * used for internal purposes, like AtomProcesses and AtomCalculations. | 
|---|
|  | 443 | */ | 
|---|
| [fa0b18] | 444 | internal_AtomIterator atomEnd_internal(); | 
|---|
| [865a945] | 445 |  | 
|---|
| [1c51c8] | 446 | // Molecules | 
|---|
| [e3d865] | 447 | typedef SelectiveIterator<molecule*,MoleculeSet::set_t,MoleculeDescriptor>   internal_MoleculeIterator; | 
|---|
| [51be2a] | 448 |  | 
|---|
| [1c51c8] | 449 |  | 
|---|
|  | 450 | /** | 
|---|
|  | 451 | * returns an iterator over all Molecules matching a given descriptor. | 
|---|
|  | 452 | * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. | 
|---|
|  | 453 | */ | 
|---|
| [e3d865] | 454 | internal_MoleculeIterator getMoleculeIter_internal(MoleculeDescriptor descr); | 
|---|
| [1c51c8] | 455 |  | 
|---|
|  | 456 | /** | 
|---|
|  | 457 | * returns an iterator to the end of the MoleculeSet. Due to overloading this iterator | 
|---|
|  | 458 | * can be compared to iterators produced by getMoleculeIter (see the mis-matching types). | 
|---|
|  | 459 | * Thus it can be used to detect when such an iterator is at the end of the list. | 
|---|
|  | 460 | * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. | 
|---|
|  | 461 | */ | 
|---|
| [e3d865] | 462 | internal_MoleculeIterator moleculeEnd_internal(); | 
|---|
| [1c51c8] | 463 |  | 
|---|
|  | 464 |  | 
|---|
| [afb47f] | 465 | /******* Internal manipulation routines for double callback and Observer mechanism ******/ | 
|---|
| [ce7fdc] | 466 | void doManipulate(MoleCuilder::ManipulateAtomsProcess *); | 
|---|
| [afb47f] | 467 |  | 
|---|
| [5d1611] | 468 | private: | 
|---|
| [88d586] | 469 |  | 
|---|
| [7188b1] | 470 | friend const atom *detail::lastChanged<atom>(); | 
|---|
|  | 471 | friend const molecule *detail::lastChanged<molecule>(); | 
|---|
|  | 472 | static atom *_lastchangedatom; | 
|---|
|  | 473 | static molecule*_lastchangedmol; | 
|---|
|  | 474 |  | 
|---|
| [f71baf] | 475 | BondGraph *BG; | 
|---|
| [5d1611] | 476 | periodentafel *periode; | 
|---|
| [8e1f7af] | 477 | config *configuration; | 
|---|
| [98dbee] | 478 | HomologyContainer *homologies; | 
|---|
| [84c494] | 479 | Box *cell_size; | 
|---|
| [4834f4] | 480 | LinkedCell::LinkedCell_Controller *LCcontroller; | 
|---|
| [387b36] | 481 | std::string defaultName; | 
|---|
| [43dad6] | 482 | class ThermoStatContainer *Thermostats; | 
|---|
| [e4b5de] | 483 | int ExitFlag; | 
|---|
| [6e97e5] | 484 | private: | 
|---|
| [127a8e] | 485 |  | 
|---|
| [1a76a6] | 486 | AtomSet atoms; | 
|---|
| [90c4280] | 487 | AtomSet selectedAtoms; | 
|---|
| [127a8e] | 488 | /** | 
|---|
|  | 489 | * stores the pool for all available AtomIds below currAtomId | 
|---|
|  | 490 | * | 
|---|
|  | 491 | * The pool contains ranges of free ids in the form [bottom,top). | 
|---|
|  | 492 | */ | 
|---|
| [b97a60] | 493 | IdPool<atomId_t, uniqueId> atomIdPool; | 
|---|
| [127a8e] | 494 |  | 
|---|
| [d2dbac0] | 495 | MoleculeSet molecules; | 
|---|
| [90c4280] | 496 | MoleculeSet selectedMolecules; | 
|---|
| [1a76a6] | 497 | /** | 
|---|
|  | 498 | * stores the pool for all available AtomIds below currAtomId | 
|---|
|  | 499 | * | 
|---|
|  | 500 | * The pool contains ranges of free ids in the form [bottom,top). | 
|---|
|  | 501 | */ | 
|---|
| [b97a60] | 502 | IdPool<moleculeId_t, continuousId> moleculeIdPool; | 
|---|
| [3e4fb6] | 503 |  | 
|---|
| [5d1611] | 504 | private: | 
|---|
| [02ee15] | 505 | /** | 
|---|
|  | 506 | * private constructor to ensure creation of the world using | 
|---|
|  | 507 | * the singleton pattern. | 
|---|
|  | 508 | */ | 
|---|
| [5d1611] | 509 | World(); | 
|---|
| [02ee15] | 510 |  | 
|---|
|  | 511 | /** | 
|---|
|  | 512 | * private destructor to ensure destruction of the world using the | 
|---|
|  | 513 | * singleton pattern. | 
|---|
|  | 514 | */ | 
|---|
| [5d1611] | 515 | virtual ~World(); | 
|---|
|  | 516 |  | 
|---|
|  | 517 | /***** | 
|---|
|  | 518 | * some legacy stuff that is include for now but will be removed later | 
|---|
|  | 519 | *****/ | 
|---|
|  | 520 | public: | 
|---|
| [354859] | 521 | MoleculeListClass *&getMolecules(); | 
|---|
| [4d9c01] | 522 |  | 
|---|
| [5d1611] | 523 | private: | 
|---|
| [354859] | 524 | MoleculeListClass *molecules_deprecated; | 
|---|
| [5d1611] | 525 | }; | 
|---|
|  | 526 |  | 
|---|
| [7188b1] | 527 | /** Externalized stuff as member functions cannot be specialized without | 
|---|
|  | 528 | *  specializing the class, too. | 
|---|
|  | 529 | */ | 
|---|
|  | 530 | namespace detail { | 
|---|
|  | 531 | template <>       inline  const atom* lastChanged<atom>() { return World::_lastchangedatom; } | 
|---|
|  | 532 | template <>       inline  const molecule* lastChanged<molecule>() { return World::_lastchangedmol; } | 
|---|
|  | 533 | } | 
|---|
|  | 534 |  | 
|---|
|  | 535 |  | 
|---|
| [5d1611] | 536 | #endif /* WORLD_HPP_ */ | 
|---|