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