source: src/World.hpp@ b84d5d

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 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 b84d5d was 354859, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Moved control of molecules and periode to World.

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