source: src/World.hpp@ b2cfdb

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 Candidate_v1.7.0 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since b2cfdb was 865a945, checked in by Tillmann Crueger <crueger@…>, 16 years ago

Added iterator structure that allows iterating over selected atoms in the World.

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[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
11#include <boost/thread.hpp>
[d346b6]12#include <map>
[fc1b24]13#include <vector>
[354859]14#include <set>
[865a945]15#include <boost/shared_ptr.hpp>
[5d1611]16
17#include "Patterns/Observer.hpp"
18#include "Patterns/Cacheable.hpp"
19
20// forward declarations
21class periodentafel;
22class MoleculeListClass;
[4d9c01]23class atom;
[354859]24class molecule;
[fc1b24]25class AtomDescriptor;
[7a1ce5]26class AtomDescriptor_impl;
[5d1611]27
28class World : public Observable
29{
[7a1ce5]30friend class AtomDescriptor_impl;
[865a945]31friend class AtomDescriptor;
32
33typedef std::map<int,atom*> AtomList;
[5d1611]34public:
35
36 /***** getter and setter *****/
[354859]37 // reference to pointer is used for legacy reason... reference will be removed latter to keep encapsulation of World object
38 periodentafel *&getPeriode();
[7a1ce5]39 atom* getAtom(AtomDescriptor descriptor);
40 std::vector<atom*> getAllAtoms(AtomDescriptor descriptor);
[354859]41 int numAtoms();
42 int numMolecules();
43
44 /***** Methods to work with the World *****/
45 molecule *createMolecule();
[865a945]46
47protected:
48 /**** Iterators to use internal data structures */
49 class AtomIterator {
50 public:
51 AtomIterator(AtomDescriptor, World*);
52 AtomIterator(const AtomIterator&);
53 AtomIterator& operator++();
54 bool operator==(const AtomIterator&);
55 bool operator!=(const AtomIterator&);
56 atom* operator*();
57 protected:
58 void advanceState();
59 World* world;
60 AtomList::iterator state;
61 boost::shared_ptr<AtomDescriptor_impl> descr;
62 };
63
64 AtomIterator getAtomIter(AtomDescriptor descr);
65
[5d1611]66private:
67 periodentafel *periode;
[865a945]68 AtomList atoms;
[354859]69 std::set<molecule*> molecules;
[5d1611]70
71
72 /***** singleton Stuff *****/
73public:
74 static World* get();
75 static void destroy();
76 static World* reset();
77
78private:
79 World();
80 virtual ~World();
81
82 static World *theWorld;
83 // this mutex only saves the singleton pattern...
84 // use other mutexes to protect internal data as well
85 // this mutex handles access to the pointer, not to the object!!!
86 static boost::mutex worldLock;
87
88 /*****
89 * some legacy stuff that is include for now but will be removed later
90 *****/
91public:
[354859]92 MoleculeListClass *&getMolecules();
[4d9c01]93
94 // functions used for the WorldContent template mechanism
[d346b6]95 void registerAtom(atom *theAtom);
96 void unregisterAtom(atom *theAtom);
[5d1611]97private:
[354859]98 // this function cleans up anything that cannot be cleaned while the lock is active
99 // at a later point all these cleanups have to be moved to the World Class so the deadlock and
100 // race condition can both be avoided.
101 void destroyLegacy();
102
103 MoleculeListClass *molecules_deprecated;
[7a1ce5]104
105 // this is needed to assign unique IDs to atoms... so far
106 // IDs are not assigned upon Atom creation, so we cannot query the ID
107 // during construction. By using the dummy ID we can make sure all atoms
108 // are actually stored in the map and don't overwrite each other.
109 int dummyId;
[5d1611]110};
111
112#endif /* WORLD_HPP_ */
Note: See TracBrowser for help on using the repository browser.