Changeset 4415da for src/World.hpp


Ignore:
Timestamp:
Apr 1, 2010, 12:16:29 PM (16 years ago)
Author:
Saskia Metzler <metzler@…>
Branches:
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
Children:
b8d4a3
Parents:
9131f3 (diff), f9352d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge Till's structure refactoring

Merge commit 'till/StructureRefactoring' into StateAndFormatParser

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/unittests/Makefile.am

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.hpp

    r9131f3 r4415da  
    1616#include <boost/shared_ptr.hpp>
    1717
    18 #include "defs.hpp"
     18#include "types.hpp"
     19#include "Descriptors/SelectiveIterator.hpp"
    1920#include "Patterns/Observer.hpp"
    2021#include "Patterns/Cacheable.hpp"
     22#include "Patterns/Singleton.hpp"
     23
    2124
    2225// forward declarations
     
    3336class AtomsCalculation;
    3437
    35 class World : public Observable
     38
     39
     40class World : public Singleton<World>, public Observable
    3641{
     42
     43// Make access to constructor and destructor possible from inside the singleton
     44friend class Singleton<World>;
     45
    3746// necessary for coupling with descriptors
    3847friend class AtomDescriptor_impl;
     
    4554template<typename> friend class AtomsCalculation;
    4655public:
     56
     57  // Types for Atom and Molecule structures
    4758  typedef std::map<atomId_t,atom*> AtomSet;
    4859  typedef std::map<moleculeId_t,molecule*> MoleculeSet;
     
    150161
    151162  // Atoms
    152 
    153   class AtomIterator :
    154     public std::iterator<std::iterator_traits<AtomSet::iterator>::difference_type,
    155                          std::iterator_traits<AtomSet::iterator>::value_type,
    156                          std::iterator_traits<AtomSet::iterator>::pointer,
    157                          std::iterator_traits<AtomSet::iterator>::reference>
    158   {
    159   public:
    160 
    161     typedef AtomSet::iterator _Iter;
    162     typedef _Iter::value_type value_type;
    163     typedef _Iter::difference_type difference_type;
    164     typedef _Iter::pointer pointer;
    165     typedef _Iter::reference reference;
    166     typedef _Iter::iterator_category iterator_category;
    167 
    168 
    169     AtomIterator();
    170     AtomIterator(AtomDescriptor, World*);
    171     AtomIterator(const AtomIterator&);
    172     AtomIterator& operator=(const AtomIterator&);
    173     AtomIterator& operator++();     // prefix
    174     AtomIterator  operator++(int);  // postfix with dummy parameter
    175     bool operator==(const AtomIterator&);
    176     bool operator==(const AtomSet::iterator&);
    177     bool operator!=(const AtomIterator&);
    178     bool operator!=(const AtomSet::iterator&);
    179     atom* operator*();
    180 
    181     int getCount();
    182   protected:
    183     void advanceState();
    184     AtomSet::iterator state;
    185     boost::shared_ptr<AtomDescriptor_impl>  descr;
    186     int index;
    187 
    188     World* world;
    189   };
     163  typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator;
    190164
    191165  /**
     
    201175   * used for internal purposes, like AtomProcesses and AtomCalculations.
    202176   */
    203   AtomSet::iterator atomEnd();
     177  AtomIterator atomEnd();
    204178
    205179  // Molecules
    206180
    207   class MoleculeIterator :
    208     public std::iterator<std::iterator_traits<MoleculeSet::iterator>::difference_type,
    209                          std::iterator_traits<MoleculeSet::iterator>::value_type,
    210                          std::iterator_traits<MoleculeSet::iterator>::pointer,
    211                          std::iterator_traits<MoleculeSet::iterator>::reference>
    212   {
    213   public:
    214 
    215     typedef MoleculeSet::iterator _Iter;
    216     typedef _Iter::value_type value_type;
    217     typedef _Iter::difference_type difference_type;
    218     typedef _Iter::pointer pointer;
    219     typedef _Iter::reference reference;
    220     typedef _Iter::iterator_category iterator_category;
    221 
    222     MoleculeIterator();
    223     MoleculeIterator(MoleculeDescriptor, World*);
    224     MoleculeIterator(const MoleculeIterator&);
    225     MoleculeIterator& operator=(const MoleculeIterator&);
    226     MoleculeIterator& operator++();     // prefix
    227     MoleculeIterator  operator++(int);  // postfix with dummy parameter
    228     bool operator==(const MoleculeIterator&);
    229     bool operator==(const MoleculeSet::iterator&);
    230     bool operator!=(const MoleculeIterator&);
    231     bool operator!=(const MoleculeSet::iterator&);
    232     molecule* operator*();
    233 
    234     int getCount();
    235   protected:
    236     void advanceState();
    237     MoleculeSet::iterator state;
    238     boost::shared_ptr<MoleculeDescriptor_impl>  descr;
    239     int index;
    240 
    241     World* world;
    242   };
     181  typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator;
    243182
    244183  /**
     
    254193   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
    255194   */
    256   MoleculeSet::iterator moleculeEnd();
     195  MoleculeIterator moleculeEnd();
    257196
    258197
     
    267206
    268207  periodentafel *periode;
     208public:
    269209  AtomSet atoms;
     210private:
    270211  std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId
    271212  atomId_t currAtomId; //!< stores the next available Id for atoms
    272213  MoleculeSet molecules;
    273214  moleculeId_t currMoleculeId;
    274 
    275 
    276   /***** singleton Stuff *****/
    277 public:
    278 
    279   /**
    280    * get the currently active instance of the World.
    281    */
    282   static World* get();
    283 
    284   /**
    285    * destroy the currently active instance of the World.
    286    */
    287   static void destroy();
    288 
    289   /**
    290    * destroy the currently active instance of the World and immidiately
    291    * create a new one. Use this to reset while somebody is still Observing
    292    * the world and should reset the observed instance. All observers will be
    293    * sent the subjectKille() message from the old world.
    294    */
    295   static World* reset();
    296 
    297215private:
    298216  /**
     
    307225   */
    308226  virtual ~World();
    309 
    310   static World *theWorld;
    311   // this mutex only saves the singleton pattern...
    312   // use other mutexes to protect internal data as well
    313   // this mutex handles access to the pointer, not to the object!!!
    314   static boost::mutex worldLock;
    315227
    316228  /*****
Note: See TracChangeset for help on using the changeset viewer.