Changes in src/World.hpp [387b36:4d72e4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/World.hpp
r387b36 r4d72e4 23 23 #include "Patterns/Cacheable.hpp" 24 24 #include "Patterns/Singleton.hpp" 25 #include "Patterns/ObservedContainer.hpp" 26 #include "Helpers/Range.hpp" 27 #include "AtomSet.hpp" 25 28 26 29 // include config.h … … 30 33 31 34 // forward declarations 32 class config;33 class periodentafel;34 class MoleculeListClass;35 35 class atom; 36 class molecule;37 36 class AtomDescriptor; 38 37 class AtomDescriptor_impl; 38 template<typename T> class AtomsCalculation; 39 class Box; 40 class config; 41 class ManipulateAtomsProcess; 42 class Matrix; 43 class molecule; 39 44 class MoleculeDescriptor; 40 45 class MoleculeDescriptor_impl; 41 class ManipulateAtomsProcess; 42 template<typename T> 43 class AtomsCalculation; 46 class MoleculeListClass; 47 class periodentafel; 48 class ThermoStatContainer; 49 44 50 45 51 /****************************************** forward declarations *****************************/ … … 58 64 friend class MoleculeDescriptor_impl; 59 65 friend class MoleculeDescriptor; 66 // coupling with descriptors over selection 67 friend class AtomSelectionDescriptor_impl; 68 friend class MoleculeSelectionDescriptor_impl; 60 69 61 70 // Actions, calculations etc associated with the World … … 65 74 66 75 // Types for Atom and Molecule structures 67 typedef std::map<atomId_t,atom*> AtomSet; 68 typedef std::map<moleculeId_t,molecule*> MoleculeSet; 76 typedef ObservedContainer<std::map<atomId_t,atom*> > AtomSet; 77 typedef ObservedContainer<std::map<moleculeId_t,molecule*> > MoleculeSet; 78 79 typedef ATOMSET(std::vector) AtomComposite; 69 80 70 81 /***** getter and setter *****/ … … 89 100 * returns a vector containing all atoms that match a given descriptor 90 101 */ 91 std::vector<atom*>getAllAtoms(AtomDescriptor descriptor);92 std::vector<atom*>getAllAtoms();102 AtomComposite getAllAtoms(AtomDescriptor descriptor); 103 AtomComposite getAllAtoms(); 93 104 94 105 /** … … 125 136 * get the domain size as a symmetric matrix (6 components) 126 137 */ 127 double * getDomain(); 138 Box& getDomain(); 139 140 /** 141 * Set the domain size from a matrix object 142 * 143 * Matrix needs to be symmetric 144 */ 145 void setDomain(const Matrix &mat); 128 146 129 147 /** … … 141 159 */ 142 160 void setDefaultName(std::string name); 161 162 /** 163 * get pointer to World's ThermoStatContainer 164 */ 165 ThermoStatContainer * getThermostats(); 143 166 144 167 /* … … 202 225 ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string); 203 226 227 /**** 228 * Iterators to use internal data structures 229 * All these iterators are observed to track changes. 230 * There is a corresponding protected section with unobserved iterators, 231 * which can be used internally when the extra speed is needed 232 */ 233 234 typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator; 235 236 /** 237 * returns an iterator over all Atoms matching a given descriptor. 238 * This iterator is observed, so don't keep it around unnecessary to 239 * avoid unintended blocking. 240 */ 241 AtomIterator getAtomIter(AtomDescriptor descr); 242 AtomIterator getAtomIter(); 243 244 AtomIterator atomEnd(); 245 246 typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator; 247 248 /** 249 * returns an iterator over all Molecules matching a given descriptor. 250 * This iterator is observed, so don't keep it around unnecessary to 251 * avoid unintended blocking. 252 */ 253 MoleculeIterator getMoleculeIter(MoleculeDescriptor descr); 254 MoleculeIterator getMoleculeIter(); 255 256 MoleculeIterator moleculeEnd(); 257 258 /******** Selections of molecules and Atoms *************/ 259 void clearAtomSelection(); 260 void selectAtom(atom*); 261 void selectAtom(atomId_t); 262 void selectAllAtoms(AtomDescriptor); 263 void selectAtomsOfMolecule(molecule*); 264 void selectAtomsOfMolecule(moleculeId_t); 265 void unselectAtom(atom*); 266 void unselectAtom(atomId_t); 267 void unselectAllAtoms(AtomDescriptor); 268 void unselectAtomsOfMolecule(molecule*); 269 void unselectAtomsOfMolecule(moleculeId_t); 270 size_t countSelectedAtoms() const; 271 bool isSelected(atom *_atom) const; 272 const std::vector<atom *> getSelectedAtoms() const; 273 274 void clearMoleculeSelection(); 275 void selectMolecule(molecule*); 276 void selectMolecule(moleculeId_t); 277 void selectAllMolecules(MoleculeDescriptor); 278 void selectMoleculeOfAtom(atom*); 279 void selectMoleculeOfAtom(atomId_t); 280 void unselectMolecule(molecule*); 281 void unselectMolecule(moleculeId_t); 282 void unselectAllMolecules(MoleculeDescriptor); 283 void unselectMoleculeOfAtom(atom*); 284 void unselectMoleculeOfAtom(atomId_t); 285 size_t countSelectedMolecules() const; 286 bool isSelected(molecule *_mol) const; 287 const std::vector<molecule *> getSelectedMolecules() const; 288 289 /******************** Iterators to selections *****************/ 290 typedef AtomSet::iterator AtomSelectionIterator; 291 AtomSelectionIterator beginAtomSelection(); 292 AtomSelectionIterator endAtomSelection(); 293 294 typedef MoleculeSet::iterator MoleculeSelectionIterator; 295 MoleculeSelectionIterator beginMoleculeSelection(); 296 MoleculeSelectionIterator endMoleculeSelection(); 297 204 298 protected: 205 /**** Iterators to use internal data structures */ 299 /**** 300 * Iterators to use internal data structures 301 * All these iterators are unobserved for speed reasons. 302 * There is a corresponding public section to these methods, 303 * which produce observed iterators.*/ 206 304 207 305 // Atoms 208 typedef SelectiveIterator<atom*,AtomSet ,AtomDescriptor>AtomIterator;306 typedef SelectiveIterator<atom*,AtomSet::set_t,AtomDescriptor> internal_AtomIterator; 209 307 210 308 /** … … 212 310 * used for internal purposes, like AtomProcesses and AtomCalculations. 213 311 */ 214 AtomIterator getAtomIter(AtomDescriptor descr);312 internal_AtomIterator getAtomIter_internal(AtomDescriptor descr); 215 313 216 314 /** … … 220 318 * used for internal purposes, like AtomProcesses and AtomCalculations. 221 319 */ 222 AtomIterator atomEnd();320 internal_AtomIterator atomEnd_internal(); 223 321 224 322 // Molecules 225 226 typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator; 323 typedef SelectiveIterator<molecule*,MoleculeSet::set_t,MoleculeDescriptor> internal_MoleculeIterator; 324 227 325 228 326 /** … … 230 328 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. 231 329 */ 232 MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);330 internal_MoleculeIterator getMoleculeIter_internal(MoleculeDescriptor descr); 233 331 234 332 /** … … 238 336 * used for internal purposes, like MoleculeProcesses and MoleculeCalculations. 239 337 */ 240 MoleculeIterator moleculeEnd();338 internal_MoleculeIterator moleculeEnd_internal(); 241 339 242 340 … … 249 347 void releaseAtomId(atomId_t); 250 348 bool reserveAtomId(atomId_t); 349 void defragAtomIdPool(); 350 351 moleculeId_t getNextMoleculeId(); 352 void releaseMoleculeId(moleculeId_t); 353 bool reserveMoleculeId(moleculeId_t); 354 void defragMoleculeIdPool(); 251 355 252 356 periodentafel *periode; 253 357 config *configuration; 254 static double*cell_size;358 Box *cell_size; 255 359 std::string defaultName; 360 class ThermoStatContainer *Thermostats; 256 361 int ExitFlag; 257 public: 362 private: 363 258 364 AtomSet atoms; 259 private: 260 std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId 365 AtomSet selectedAtoms; 366 typedef std::set<range<atomId_t> > atomIdPool_t; 367 /** 368 * stores the pool for all available AtomIds below currAtomId 369 * 370 * The pool contains ranges of free ids in the form [bottom,top). 371 */ 372 atomIdPool_t atomIdPool; 261 373 atomId_t currAtomId; //!< stores the next available Id for atoms 374 size_t lastAtomPoolSize; //!< size of the pool after last defrag, to skip some defrags 375 unsigned int numAtomDefragSkips; 376 262 377 MoleculeSet molecules; 378 MoleculeSet selectedMolecules; 379 typedef std::set<range<atomId_t> > moleculeIdPool_t; 380 /** 381 * stores the pool for all available AtomIds below currAtomId 382 * 383 * The pool contains ranges of free ids in the form [bottom,top). 384 */ 385 moleculeIdPool_t moleculeIdPool; 263 386 moleculeId_t currMoleculeId; 387 size_t lastMoleculePoolSize; //!< size of the pool after last defrag, to skip some defrags 388 unsigned int numMoleculeDefragSkips; 264 389 private: 265 390 /**
Note:
See TracChangeset
for help on using the changeset viewer.