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