Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.cpp

    ra77c96 r23b547  
    1616#include "Descriptors/MoleculeDescriptor_impl.hpp"
    1717#include "Actions/ManipulateAtomsProcess.hpp"
     18
     19#include "Patterns/Singleton_impl.hpp"
    1820
    1921using namespace std;
     
    229231/******************************* Singleton Stuff **************************/
    230232
    231 // TODO: Hide boost-thread using Autotools stuff when no threads are used
    232 World* World::theWorld = 0;
    233 boost::mutex World::worldLock;
    234 
    235233World::World() :
    236234    periode(new periodentafel),
     
    261259}
    262260
    263 World* World::get(){
    264   // boost supports RAII-Style locking, so we don't need to unlock
    265   boost::mutex::scoped_lock guard(worldLock);
    266   if(!theWorld) {
    267     theWorld = new World();
    268   }
    269   return theWorld;
    270 }
    271 
    272 void World::destroy(){
    273   // boost supports RAII-Style locking, so we don't need to unlock
    274   boost::mutex::scoped_lock guard(worldLock);
    275   delete theWorld;
    276   theWorld = 0;
    277 }
    278 
    279 World* World::reset(){
    280   World* oldWorld = 0;
    281   {
    282     // boost supports RAII-Style locking, so we don't need to unlock
    283     boost::mutex::scoped_lock guard(worldLock);
    284 
    285     oldWorld = theWorld;
    286     theWorld = new World();
    287     // oldworld does not need protection any more,
    288     // since we should have the only reference
    289 
    290     // worldLock handles access to the pointer,
    291     // not to the object
    292   } // scope-end releases the lock
    293 
    294   // we have to let all the observers know that the
    295   // oldWorld was destroyed. oldWorld calls subjectKilled
    296   // upon destruction. Every Observer getting that signal
    297   // should see that it gets the updated new world
    298   delete oldWorld;
    299   return theWorld;
    300 }
     261// Explicit instantiation of the singleton mechanism at this point
     262
     263CONSTRUCT_SINGLETON(World)
    301264
    302265/******************************* deprecated Legacy Stuff ***********************/
Note: See TracChangeset for help on using the changeset viewer.