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