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