Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.hpp

    r23b547 r88d586  
    1919#include "Patterns/Observer.hpp"
    2020#include "Patterns/Cacheable.hpp"
    21 #include "Patterns/Singleton.hpp"
    22 
    2321
    2422// forward declarations
     
    3533class AtomsCalculation;
    3634
    37 
    38 
    39 class World : public Singleton<World>, public Observable
     35class World : public Observable
    4036{
    41 
    42 // Make access to constructor and destructor possible from inside the singleton
    43 friend class Singleton<World>;
    44 
    4537// necessary for coupling with descriptors
    4638friend class AtomDescriptor_impl;
     
    5345template<typename> friend class AtomsCalculation;
    5446public:
    55 
    56   // Types for Atom and Molecule structures
    5747  typedef std::map<atomId_t,atom*> AtomSet;
    5848  typedef std::map<moleculeId_t,molecule*> MoleculeSet;
     
    161151  // Atoms
    162152
    163   class AtomIterator :
    164     public std::iterator<std::iterator_traits<AtomSet::iterator>::difference_type,
    165                          std::iterator_traits<AtomSet::iterator>::value_type,
    166                          std::iterator_traits<AtomSet::iterator>::pointer,
    167                          std::iterator_traits<AtomSet::iterator>::reference>
    168   {
     153  class AtomIterator {
    169154  public:
    170 
    171     typedef AtomSet::iterator _Iter;
    172     typedef _Iter::value_type value_type;
    173     typedef _Iter::difference_type difference_type;
    174     typedef _Iter::pointer pointer;
    175     typedef _Iter::reference reference;
    176     typedef _Iter::iterator_category iterator_category;
    177 
    178 
    179155    AtomIterator();
    180156    AtomIterator(AtomDescriptor, World*);
     
    215191  // Molecules
    216192
    217   class MoleculeIterator :
    218     public std::iterator<std::iterator_traits<MoleculeSet::iterator>::difference_type,
    219                          std::iterator_traits<MoleculeSet::iterator>::value_type,
    220                          std::iterator_traits<MoleculeSet::iterator>::pointer,
    221                          std::iterator_traits<MoleculeSet::iterator>::reference>
    222   {
     193  class MoleculeIterator {
    223194  public:
    224 
    225     typedef MoleculeSet::iterator _Iter;
    226     typedef _Iter::value_type value_type;
    227     typedef _Iter::difference_type difference_type;
    228     typedef _Iter::pointer pointer;
    229     typedef _Iter::reference reference;
    230     typedef _Iter::iterator_category iterator_category;
    231 
    232195    MoleculeIterator();
    233196    MoleculeIterator(MoleculeDescriptor, World*);
     
    282245  MoleculeSet molecules;
    283246  moleculeId_t currMoleculeId;
     247
     248
     249  /***** singleton Stuff *****/
     250public:
     251
     252  /**
     253   * get the currently active instance of the World.
     254   */
     255  static World* get();
     256
     257  /**
     258   * destroy the currently active instance of the World.
     259   */
     260  static void destroy();
     261
     262  /**
     263   * destroy the currently active instance of the World and immidiately
     264   * create a new one. Use this to reset while somebody is still Observing
     265   * the world and should reset the observed instance. All observers will be
     266   * sent the subjectKille() message from the old world.
     267   */
     268  static World* reset();
     269
    284270private:
    285271  /**
     
    294280   */
    295281  virtual ~World();
     282
     283  static World *theWorld;
     284  // this mutex only saves the singleton pattern...
     285  // use other mutexes to protect internal data as well
     286  // this mutex handles access to the pointer, not to the object!!!
     287  static boost::mutex worldLock;
    296288
    297289  /*****
Note: See TracChangeset for help on using the changeset viewer.