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