Changeset 23b547 for src


Ignore:
Timestamp:
Mar 10, 2010, 5:51:48 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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, 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:
d7940e
Parents:
31af19
Message:

Added generic singleton Pattern that can be inherited to any class making that class a singleton.

Location:
src
Files:
2 added
29 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AtomsCalculation_impl.hpp

    r31af19 r23b547  
    2929template<typename T>
    3030std::vector<T>* AtomsCalculation<T>::doCalc(){
    31   World* world = World::get();
     31  World* world = World::getPointer();
    3232  int steps = world->numAtoms();
    33   int count = 0;
    3433  std::vector<T> *res = new std::vector<T>();
    3534  res->reserve(steps);
  • src/Actions/ManipulateAtomsProcess.cpp

    r31af19 r23b547  
    2323
    2424void ManipulateAtomsProcess::call(){
    25   World::get()->doManipulate(this);
     25  World::getInstance().doManipulate(this);
    2626}
    2727
  • src/Descriptors/AtomDescriptor.cpp

    r31af19 r23b547  
    6868
    6969World::AtomSet& AtomDescriptor_impl::getAtoms(){
    70   return World::get()->atoms;
     70  return World::getInstance().atoms;
    7171}
    7272
  • src/Descriptors/AtomTypeDescriptor.cpp

    r31af19 r23b547  
    2929
    3030AtomDescriptor AtomByType(int Z){
    31   element * elem = World::get()->getPeriode()->FindElement(Z);
     31  element * elem = World::getInstance().getPeriode()->FindElement(Z);
    3232  return AtomByType(elem);
    3333}
  • src/Descriptors/MoleculeDescriptor.cpp

    r31af19 r23b547  
    6868
    6969World::MoleculeSet& MoleculeDescriptor_impl::getMolecules(){
    70   return World::get()->molecules;
     70  return World::getInstance().molecules;
    7171}
    7272
  • src/Legacy/oldmenu.cpp

    r31af19 r23b547  
    7878      case 'a': // absolute coordinates of atom
    7979        Log() << Verbose(0) << "Enter absolute coordinates." << endl;
    80         first = World::get()->createAtom();
     80        first = World::getInstance().createAtom();
    8181        first->x.AskPosition(mol->cell_size, false);
    8282        first->type = periode->AskElement();  // give type
     
    8585
    8686      case 'b': // relative coordinates of atom wrt to reference point
    87         first = World::get()->createAtom();
     87        first = World::getInstance().createAtom();
    8888        valid = true;
    8989        do {
     
    101101
    102102      case 'c': // relative coordinates of atom wrt to already placed atom
    103         first = World::get()->createAtom();
     103        first = World::getInstance().createAtom();
    104104        valid = true;
    105105        do {
     
    117117
    118118    case 'd': // two atoms, two angles and a distance
    119         first = World::get()->createAtom();
     119        first = World::getInstance().createAtom();
    120120        valid = true;
    121121        do {
     
    217217
    218218      case 'e': // least square distance position to a set of atoms
    219         first = World::get()->createAtom();
     219        first = World::getInstance().createAtom();
    220220        atoms = new (Vector*[128]);
    221221        valid = true;
     
    239239          mol->AddAtom(first);  // add to molecule
    240240        } else {
    241           World::get()->destroyAtom(first);
     241          World::getInstance().destroyAtom(first);
    242242          Log() << Verbose(0) << "Please enter at least two vectors!\n";
    243243        }
     
    782782        x.AddVector(&y); // per factor one cell width further
    783783        for (int k=count;k--;) { // go through every atom of the original cell
    784           first = World::get()->createAtom(); // create a new body
     784          first = World::getInstance().createAtom(); // create a new body
    785785          first->x.CopyVector(vectors[k]);  // use coordinate of original atom
    786786          first->x.AddVector(&x);     // translate the coordinates
     
    10891089    A++;
    10901090  }
    1091   World::get()->destroyMolecule(mol);
     1091  World::getInstance().destroyMolecule(mol);
    10921092};
    10931093
  • src/World.cpp

    r31af19 r23b547  
    1616#include "Descriptors/MoleculeDescriptor_impl.hpp"
    1717#include "Actions/ManipulateAtomsProcess.hpp"
     18
     19#include "Patterns/Singleton_impl.hpp"
    1820
    1921using namespace std;
     
    170172    atomId_t id = *(atomIdPool.begin());
    171173    atomIdPool.erase(id);
     174    return id;
    172175  }
    173176}
     
    227230
    228231/******************************* Singleton Stuff **************************/
    229 
    230 // TODO: Hide boost-thread using Autotools stuff when no threads are used
    231 World* World::theWorld = 0;
    232 boost::mutex World::worldLock;
    233232
    234233World::World() :
     
    260259}
    261260
    262 World* World::get(){
    263   // boost supports RAII-Style locking, so we don't need to unlock
    264   boost::mutex::scoped_lock guard(worldLock);
    265   if(!theWorld) {
    266     theWorld = new World();
    267   }
    268   return theWorld;
    269 }
    270 
    271 void World::destroy(){
    272   // boost supports RAII-Style locking, so we don't need to unlock
    273   boost::mutex::scoped_lock guard(worldLock);
    274   delete theWorld;
    275   theWorld = 0;
    276 }
    277 
    278 World* World::reset(){
    279   World* oldWorld = 0;
    280   {
    281     // boost supports RAII-Style locking, so we don't need to unlock
    282     boost::mutex::scoped_lock guard(worldLock);
    283 
    284     oldWorld = theWorld;
    285     theWorld = new World();
    286     // oldworld does not need protection any more,
    287     // since we should have the only reference
    288 
    289     // worldLock handles access to the pointer,
    290     // not to the object
    291   } // scope-end releases the lock
    292 
    293   // we have to let all the observers know that the
    294   // oldWorld was destroyed. oldWorld calls subjectKilled
    295   // upon destruction. Every Observer getting that signal
    296   // should see that it gets the updated new world
    297   delete oldWorld;
    298   return theWorld;
    299 }
     261// Explicit instantiation of the singleton mechanism at this point
     262
     263CONSTRUCT_SINGLETON(World)
    300264
    301265/******************************* deprecated Legacy Stuff ***********************/
  • src/World.hpp

    r31af19 r23b547  
    1919#include "Patterns/Observer.hpp"
    2020#include "Patterns/Cacheable.hpp"
     21#include "Patterns/Singleton.hpp"
     22
    2123
    2224// forward declarations
     
    3335class AtomsCalculation;
    3436
    35 class World : public Observable
     37
     38
     39class World : public Singleton<World>, public Observable
    3640{
     41
     42// Make access to constructor and destructor possible from inside the singleton
     43friend class Singleton<World>;
     44
    3745// necessary for coupling with descriptors
    3846friend class AtomDescriptor_impl;
     
    4553template<typename> friend class AtomsCalculation;
    4654public:
     55
     56  // Types for Atom and Molecule structures
    4757  typedef std::map<atomId_t,atom*> AtomSet;
    4858  typedef std::map<moleculeId_t,molecule*> MoleculeSet;
     
    272282  MoleculeSet molecules;
    273283  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 
    297284private:
    298285  /**
     
    307294   */
    308295  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;
    315296
    316297  /*****
  • src/WorldIterators.cpp

    r31af19 r23b547  
    1717
    1818World::AtomIterator::AtomIterator(){
    19   state = World::get()->atomEnd();
     19  state = World::getInstance().atomEnd();
    2020}
    2121
     
    9595
    9696World::MoleculeIterator::MoleculeIterator(){
    97   state = World::get()->moleculeEnd();
     97  state = World::getInstance().moleculeEnd();
    9898}
    9999
  • src/atom.cpp

    r31af19 r23b547  
    5050  res->FixedIon = FixedIon;
    5151  res->node = &x;
    52   World::get()->registerAtom(res);
     52  World::getInstance().registerAtom(res);
    5353  return res;
    5454}
  • src/atom_atominfo.cpp

    r31af19 r23b547  
    2929
    3030void AtomInfo::setType(int Z) {
    31   element *elem = World::get()->getPeriode()->FindElement(Z);
     31  element *elem = World::getInstance().getPeriode()->FindElement(Z);
    3232  setType(elem);
    3333}
  • src/boundary.cpp

    r31af19 r23b547  
    801801{
    802802        Info FunctionInfo(__func__);
    803   molecule *Filling = World::get()->createMolecule();
     803  molecule *Filling = World::getInstance().createMolecule();
    804804  Vector CurrentPosition;
    805805  int N[NDIM];
  • src/builder.cpp

    r31af19 r23b547  
    14321432     }
    14331433     if (mol == NULL) {
    1434        mol = World::get()->createMolecule();
     1434       mol = World::getInstance().createMolecule();
    14351435       mol->ActiveFlag = true;
    14361436       if (ConfigFileName != NULL)
     
    14811481                SaveFlag = true;
    14821482                Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
    1483                 first = World::get()->createAtom();
     1483                first = World::getInstance().createAtom();
    14841484                first->type = periode->FindElement(atoi(argv[argptr]));
    14851485                if (first->type != NULL)
     
    16341634                Log() << Verbose(1) << "Filling Box with water molecules." << endl;
    16351635                // construct water molecule
    1636                 molecule *filler = World::get()->createMolecule();
     1636                molecule *filler = World::getInstance().createMolecule();
    16371637                molecule *Filling = NULL;
    16381638                atom *second = NULL, *third = NULL;
     
    16411641//                first->x.Zero();
    16421642//                filler->AddAtom(first);
    1643                 first = World::get()->createAtom();
     1643                first = World::getInstance().createAtom();
    16441644                first->type = periode->FindElement(1);
    16451645                first->x.Init(0.441, -0.143, 0.);
    16461646                filler->AddAtom(first);
    1647                 second = World::get()->createAtom();
     1647                second = World::getInstance().createAtom();
    16481648                second->type = periode->FindElement(1);
    16491649                second->x.Init(-0.464, 1.137, 0.0);
    16501650                filler->AddAtom(second);
    1651                 third = World::get()->createAtom();
     1651                third = World::getInstance().createAtom();
    16521652                third->type = periode->FindElement(8);
    16531653                third->x.Init(-0.464, 0.177, 0.);
     
    16641664                  molecules->insert(Filling);
    16651665                }
    1666                 World::get()->destroyMolecule(filler);
     1666                World::getInstance().destroyMolecule(filler);
    16671667                argptr+=6;
    16681668              }
     
    20972097                      x.AddVector(&y); // per factor one cell width further
    20982098                      for (int k=count;k--;) { // go through every atom of the original cell
    2099                         first = World::get()->createAtom(); // create a new body
     2099                        first = World::getInstance().createAtom(); // create a new body
    21002100                        first->x.CopyVector(vectors[k]);  // use coordinate of original atom
    21012101                        first->x.AddVector(&x);      // translate the coordinates
     
    21682168void cleanUp(config *configuration){
    21692169  UIFactory::purgeInstance();
    2170   World::destroy();
     2170  World::purgeInstance();
    21712171  delete(configuration);
    21722172  Log() << Verbose(0) <<  "Maximum of allocated memory: "
     
    21922192    setVerbosity(0);
    21932193    /* structure of ParseCommandLineOptions will be refactored later */
    2194     j = ParseCommandLineOptions(argc, argv,  World::get()->getMolecules(), World::get()->getPeriode(), *configuration, ConfigFileName);
     2194    j = ParseCommandLineOptions(argc, argv,  World::getInstance().getMolecules(), World::getInstance().getPeriode(), *configuration, ConfigFileName);
    21952195    switch (j){
    21962196        case 255:
     
    22022202            break;
    22032203    }
    2204     if(World::get()->numMolecules() == 0){
    2205         mol = World::get()->createMolecule();
    2206         World::get()->getMolecules()->insert(mol);
     2204    if(World::getInstance().numMolecules() == 0){
     2205        mol = World::getInstance().createMolecule();
     2206        World::getInstance().getMolecules()->insert(mol);
    22072207        cout << "Molecule created" << endl;
    22082208        if(mol->cell_size[0] == 0.){
     
    22252225
    22262226      UIFactory::makeUserInterface(UIFactory::Text);
    2227       MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,World::get()->getMolecules(), configuration, World::get()->getPeriode(), ConfigFileName);
     2227      MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,World::getInstance().getMolecules(), configuration, World::getInstance().getPeriode(), ConfigFileName);
    22282228      mainWindow->display();
    22292229      delete mainWindow;
    22302230    }
    22312231
    2232     if(World::get()->getPeriode()->StorePeriodentafel(configuration->databasepath))
     2232    if(World::getInstance().getPeriode()->StorePeriodentafel(configuration->databasepath))
    22332233        Log() << Verbose(0) << "Saving of elements.db successful." << endl;
    22342234
  • src/config.cpp

    r31af19 r23b547  
    733733            sprintf(keyword,"%s_%i",name, j+1);
    734734            if (repetition == 0) {
    735               neues = World::get()->createAtom();
     735              neues = World::getInstance().createAtom();
    736736              AtomList[i][j] = neues;
    737737              LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;
     
    812812          sprintf(keyword,"%s_%i",name, j+1);
    813813          if (repetition == 0) {
    814             neues = World::get()->createAtom();
     814            neues = World::getInstance().createAtom();
    815815            AtomList[i][j] = neues;
    816816            LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;
     
    851851void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
    852852{
    853   molecule *mol = World::get()->createMolecule();
     853  molecule *mol = World::getInstance().createMolecule();
    854854  ifstream *file = new ifstream(filename);
    855855  if (file == NULL) {
     
    10891089void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
    10901090{
    1091   molecule *mol = World::get()->createMolecule();
     1091  molecule *mol = World::getInstance().createMolecule();
    10921092  ifstream *file = new ifstream(filename);
    10931093  if (file == NULL) {
     
    12881288        }
    12891289        istringstream input2(zeile);
    1290         atom *neues = World::get()->createAtom();
     1290        atom *neues = World::getInstance().createAtom();
    12911291        input2 >> neues->x.x[0]; // x
    12921292        input2 >> neues->x.x[1]; // y
     
    17881788  char filename[MAXSTRINGSIZE];
    17891789  ofstream output;
    1790   molecule *mol = World::get()->createMolecule();
     1790  molecule *mol = World::getInstance().createMolecule();
    17911791  mol->SetNameFromFilename(ConfigFileName);
    17921792
     
    18991899  }
    19001900
    1901   World::get()->destroyMolecule(mol);
     1901  World::getInstance().destroyMolecule(mol);
    19021902};
    19031903
  • src/defs.hpp

    r31af19 r23b547  
    8585#define STD_SEPERATOR_SPACER '-'
    8686
     87// some types used to set template parameters
     88struct true_type{
     89  enum{value=1};
     90};
     91struct false_type{
     92  enum{value = 0};
     93};
     94
    8795#endif /*DEFS_HPP_*/
  • src/molecule.cpp

    r31af19 r23b547  
    3131 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
    3232 */
    33 molecule::molecule(const periodentafel * const teil) : elemente(teil), start(World::get()->createAtom()), end(World::get()->createAtom()),
     33molecule::molecule(const periodentafel * const teil) : elemente(teil), start(World::getInstance().createAtom()), end(World::getInstance().createAtom()),
    3434  first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),
    3535  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),
     
    5656
    5757molecule *NewMolecule(){
    58   return new molecule(World::get()->getPeriode());
     58  return new molecule(World::getInstance().getPeriode());
    5959}
    6060
     
    261261  switch(TopBond->BondDegree) {
    262262    case 1:
    263       FirstOtherAtom = World::get()->createAtom();    // new atom
     263      FirstOtherAtom = World::getInstance().createAtom();    // new atom
    264264      FirstOtherAtom->type = elemente->FindElement(1);  // element is Hydrogen
    265265      FirstOtherAtom->v.CopyVector(&TopReplacement->v); // copy velocity
     
    318318
    319319      // create the two Hydrogens ...
    320       FirstOtherAtom = World::get()->createAtom();
    321       SecondOtherAtom = World::get()->createAtom();
     320      FirstOtherAtom = World::getInstance().createAtom();
     321      SecondOtherAtom = World::getInstance().createAtom();
    322322      FirstOtherAtom->type = elemente->FindElement(1);
    323323      SecondOtherAtom->type = elemente->FindElement(1);
     
    373373    case 3:
    374374      // take the "usual" tetraoidal angle and add the three Hydrogen in direction of the bond (height of the tetraoid)
    375       FirstOtherAtom = World::get()->createAtom();
    376       SecondOtherAtom = World::get()->createAtom();
    377       ThirdOtherAtom = World::get()->createAtom();
     375      FirstOtherAtom = World::getInstance().createAtom();
     376      SecondOtherAtom = World::getInstance().createAtom();
     377      ThirdOtherAtom = World::getInstance().createAtom();
    378378      FirstOtherAtom->type = elemente->FindElement(1);
    379379      SecondOtherAtom->type = elemente->FindElement(1);
     
    494494    MDSteps++;
    495495  for(i=0;i<NumberOfAtoms;i++){
    496     Walker = World::get()->createAtom();
     496    Walker = World::getInstance().createAtom();
    497497    getline(xyzfile,line,'\n');
    498498    istringstream *item = new istringstream(line);
  • src/molecule_dynamics.cpp

    r31af19 r23b547  
    486486  bool status = true;
    487487  int MaxSteps = configuration.MaxOuterStep;
    488   MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::get());
     488  MoleculeListClass *MoleculePerStep = new MoleculeListClass(World::getPointer());
    489489  // Get the Permutation Map by MinimiseConstrainedPotential
    490490  atom **PermutationMap = NULL;
     
    506506  Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl;
    507507  for (int step = 0; step <= MaxSteps; step++) {
    508     mol = World::get()->createMolecule();
     508    mol = World::getInstance().createMolecule();
    509509    MoleculePerStep->insert(mol);
    510510    Walker = start;
  • src/molecule_fragmentation.cpp

    r31af19 r23b547  
    676676  //if (FragmentationToDo) {    // we should always store the fragments again as coordination might have changed slightly without changing bond structure
    677677  // allocate memory for the pointer array and transmorph graphs into full molecular fragments
    678   BondFragments = new MoleculeListClass(World::get());
     678  BondFragments = new MoleculeListClass(World::getPointer());
    679679  int k=0;
    680680  for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {
     
    927927{
    928928  atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");
    929   molecule *Leaf = World::get()->createMolecule();
     929  molecule *Leaf = World::getInstance().createMolecule();
    930930
    931931//  Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl;
  • src/moleculelist.cpp

    r31af19 r23b547  
    215215  // remove src
    216216  ListOfMolecules.remove(srcmol);
    217   World::get()->destroyMolecule(srcmol);
     217  World::getInstance().destroyMolecule(srcmol);
    218218  return true;
    219219};
     
    750750void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
    751751{
    752   molecule *mol = World::get()->createMolecule();
     752  molecule *mol = World::getInstance().createMolecule();
    753753  atom *Walker = NULL;
    754754  atom *Advancer = NULL;
     
    775775    }
    776776    // remove the molecule
    777     World::get()->destroyMolecule(*MolRunner);
     777    World::getInstance().destroyMolecule(*MolRunner);
    778778    ListOfMolecules.erase(MolRunner);
    779779  }
     
    797797  molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
    798798  for (int i=0;i<MolCount;i++) {
    799     molecules[i] = World::get()->createMolecule();
     799    molecules[i] = World::getInstance().createMolecule();
    800800    molecules[i]->ActiveFlag = true;
    801801    strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE);
     
    895895  OBSERVE;
    896896  molecule *mol = NULL;
    897   mol = World::get()->createMolecule();
     897  mol = World::getInstance().createMolecule();
    898898  insert(mol);
    899899};
     
    904904  char filename[MAXSTRINGSIZE];
    905905  Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
    906   mol = World::get()->createMolecule();
     906  mol = World::getInstance().createMolecule();
    907907  do {
    908908    Log() << Verbose(0) << "Enter file name: ";
     
    962962      mol = *ListRunner;
    963963      ListOfMolecules.erase(ListRunner);
    964       World::get()->destroyMolecule(mol);
     964      World::getInstance().destroyMolecule(mol);
    965965      break;
    966966    }
     
    10091009  // remove the leaf itself
    10101010  if (Leaf != NULL) {
    1011     World::get()->destroyMolecule(Leaf);
     1011    World::getInstance().destroyMolecule(Leaf);
    10121012    Leaf = NULL;
    10131013  }
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r31af19 r23b547  
    5757
    5858  // construct periodentafel
    59   tafel = World::get()->getPeriode();
     59  tafel = World::getInstance().getPeriode();
    6060  tafel->AddElement(hydrogen);
    6161
    6262  // construct molecule (tetraeder of hydrogens)
    63   TestMolecule = World::get()->createMolecule();
    64   Walker = World::get()->createAtom();
     63  TestMolecule = World::getInstance().createMolecule();
     64  Walker = World::getInstance().createAtom();
    6565  Walker->type = hydrogen;
    6666  Walker->node->Init(1., 0., 1. );
    6767  TestMolecule->AddAtom(Walker);
    68   Walker = World::get()->createAtom();
     68  Walker = World::getInstance().createAtom();
    6969  Walker->type = hydrogen;
    7070  Walker->node->Init(0., 1., 1. );
    7171  TestMolecule->AddAtom(Walker);
    72   Walker = World::get()->createAtom();
     72  Walker = World::getInstance().createAtom();
    7373  Walker->type = hydrogen;
    7474  Walker->node->Init(1., 1., 0. );
    7575  TestMolecule->AddAtom(Walker);
    76   Walker = World::get()->createAtom();
     76  Walker = World::getInstance().createAtom();
    7777  Walker->type = hydrogen;
    7878  Walker->node->Init(0., 0., 0. );
     
    8282  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    8383
    84   TestList = World::get()->getMolecules();
     84  TestList = World::getInstance().getMolecules();
    8585  TestMolecule->ActiveFlag = true;
    8686  TestList->insert(TestMolecule);
     
    104104
    105105  delete(point);
    106   World::destroy();
     106  World::purgeInstance();
    107107  MemoryUsageObserver::purgeInstance();
    108108  logger::purgeInstance();
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r31af19 r23b547  
    6161
    6262  // construct periodentafel
    63   tafel = World::get()->getPeriode();
     63  tafel = World::getInstance().getPeriode();
    6464  tafel->AddElement(hydrogen);
    6565  tafel->AddElement(carbon);
    6666
    6767  // construct molecule (tetraeder of hydrogens) base
    68   TestMolecule = World::get()->createMolecule();
    69   Walker = World::get()->createAtom();
     68  TestMolecule = World::getInstance().createMolecule();
     69  Walker = World::getInstance().createAtom();
    7070  Walker->type = hydrogen;
    7171  Walker->node->Init(1., 0., 1. );
    7272  TestMolecule->AddAtom(Walker);
    73   Walker = World::get()->createAtom();
     73  Walker = World::getInstance().createAtom();
    7474  Walker->type = hydrogen;
    7575  Walker->node->Init(0., 1., 1. );
    7676  TestMolecule->AddAtom(Walker);
    77   Walker = World::get()->createAtom();
     77  Walker = World::getInstance().createAtom();
    7878  Walker->type = hydrogen;
    7979  Walker->node->Init(1., 1., 0. );
    8080  TestMolecule->AddAtom(Walker);
    81   Walker = World::get()->createAtom();
     81  Walker = World::getInstance().createAtom();
    8282  Walker->type = hydrogen;
    8383  Walker->node->Init(0., 0., 0. );
     
    8787  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    8888
    89   TestList = World::get()->getMolecules();
     89  TestList = World::getInstance().getMolecules();
    9090  TestMolecule->ActiveFlag = true;
    9191  TestList->insert(TestMolecule);
     
    100100
    101101  // add outer atoms
    102   Walker = World::get()->createAtom();
     102  Walker = World::getInstance().createAtom();
    103103  Walker->type = carbon;
    104104  Walker->node->Init(4., 0., 4. );
    105105  TestMolecule->AddAtom(Walker);
    106   Walker = World::get()->createAtom();
     106  Walker = World::getInstance().createAtom();
    107107  Walker->type = carbon;
    108108  Walker->node->Init(0., 4., 4. );
    109109  TestMolecule->AddAtom(Walker);
    110   Walker = World::get()->createAtom();
     110  Walker = World::getInstance().createAtom();
    111111  Walker->type = carbon;
    112112  Walker->node->Init(4., 4., 0. );
    113113  TestMolecule->AddAtom(Walker);
    114114  // add inner atoms
    115   Walker = World::get()->createAtom();
     115  Walker = World::getInstance().createAtom();
    116116  Walker->type = carbon;
    117117  Walker->node->Init(0.5, 0.5, 0.5 );
     
    135135  // note that all the atoms are cleaned by TestMolecule
    136136  delete(LC);
    137   World::destroy();
     137  World::purgeInstance();
    138138  MemoryUsageObserver::purgeInstance();
    139139  logger::purgeInstance();
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r31af19 r23b547  
    5656
    5757  // construct periodentafel
    58   tafel = World::get()->getPeriode();
     58  tafel = World::getInstance().getPeriode();
    5959  tafel->AddElement(hydrogen);
    6060
    6161  // construct molecule (tetraeder of hydrogens)
    62   TestMolecule = World::get()->createMolecule();
    63   Walker = World::get()->createAtom();
     62  TestMolecule = World::getInstance().createMolecule();
     63  Walker = World::getInstance().createAtom();
    6464  Walker->type = hydrogen;
    6565  Walker->node->Init(1., 0., 1. );
    6666  TestMolecule->AddAtom(Walker);
    67   Walker = World::get()->createAtom();
     67  Walker = World::getInstance().createAtom();
    6868  Walker->type = hydrogen;
    6969  Walker->node->Init(0., 1., 1. );
    7070  TestMolecule->AddAtom(Walker);
    71   Walker = World::get()->createAtom();
     71  Walker = World::getInstance().createAtom();
    7272  Walker->type = hydrogen;
    7373  Walker->node->Init(1., 1., 0. );
    7474  TestMolecule->AddAtom(Walker);
    75   Walker = World::get()->createAtom();
     75  Walker = World::getInstance().createAtom();
    7676  Walker->type = hydrogen;
    7777  Walker->node->Init(0., 0., 0. );
     
    8181  CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    8282
    83   TestList = World::get()->getMolecules();
     83  TestList = World::getInstance().getMolecules();
    8484  TestMolecule->ActiveFlag = true;
    8585  TestList->insert(TestMolecule);
     
    100100
    101101  // note that all the atoms are cleaned by TestMolecule
    102   World::destroy();
     102  World::purgeInstance();
    103103  MemoryUsageObserver::purgeInstance();
    104104  logger::purgeInstance();
  • src/unittests/AtomDescriptorTest.cpp

    r31af19 r23b547  
    2929// set up and tear down
    3030void AtomDescriptorTest::setUp(){
    31   World::get();
     31  World::getInstance();
    3232  for(int i=0;i<ATOM_COUNT;++i){
    33     atoms[i]= World::get()->createAtom();
     33    atoms[i]= World::getInstance().createAtom();
    3434    atomIds[i]= atoms[i]->getId();
    3535  }
     
    3737
    3838void AtomDescriptorTest::tearDown(){
    39   World::destroy();
     39  World::purgeInstance();
    4040}
    4141
     
    7373
    7474void AtomDescriptorTest::AtomBaseSetsTest(){
    75   std::vector<atom*> allAtoms = World::get()->getAllAtoms(AllAtoms());
     75  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
    7676  CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds));
    7777  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(allAtoms));
    7878
    79   std::vector<atom*> noAtoms = World::get()->getAllAtoms(NoAtoms());
     79  std::vector<atom*> noAtoms = World::getInstance().getAllAtoms(NoAtoms());
    8080  CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty());
    8181}
     
    8383  // test Atoms from boundaries and middle of the set
    8484  atom* testAtom;
    85   testAtom = World::get()->getAtom(AtomById(atomIds[0]));
     85  testAtom = World::getInstance().getAtom(AtomById(atomIds[0]));
    8686  CPPUNIT_ASSERT(testAtom);
    8787  CPPUNIT_ASSERT_EQUAL( atomIds[0], testAtom->getId());
    88   testAtom = World::get()->getAtom(AtomById(atomIds[ATOM_COUNT/2]));
     88  testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT/2]));
    8989  CPPUNIT_ASSERT(testAtom);
    9090  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtom->getId());
    91   testAtom = World::get()->getAtom(AtomById(atomIds[ATOM_COUNT-1]));
     91  testAtom = World::getInstance().getAtom(AtomById(atomIds[ATOM_COUNT-1]));
    9292  CPPUNIT_ASSERT(testAtom);
    9393  CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT-1], testAtom->getId());
     
    103103  }
    104104  // test from outside of set
    105   testAtom = World::get()->getAtom(AtomById(outsideId));
     105  testAtom = World::getInstance().getAtom(AtomById(outsideId));
    106106  CPPUNIT_ASSERT(!testAtom);
    107107}
     
    109109  // test some elementary set operations
    110110  {
    111     std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()||NoAtoms());
     111    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()||NoAtoms());
    112112    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
    113113    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
     
    115115
    116116  {
    117     std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||AllAtoms());
     117    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||AllAtoms());
    118118    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
    119119    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
     
    121121
    122122  {
    123     std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()&&AllAtoms());
     123    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()&&AllAtoms());
    124124    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
    125125  }
    126126
    127127  {
    128     std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()&&NoAtoms());
     128    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&NoAtoms());
    129129    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
    130130  }
    131131
    132132  {
    133     std::vector<atom*> testAtoms = World::get()->getAllAtoms(!AllAtoms());
     133    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!AllAtoms());
    134134    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
    135135  }
    136136
    137137  {
    138     std::vector<atom*> testAtoms = World::get()->getAllAtoms(!NoAtoms());
     138    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(!NoAtoms());
    139139    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
    140140    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
     
    143143  // exclude and include some atoms
    144144  {
    145     std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2])));
     145    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2])));
    146146    std::set<atomId_t> excluded;
    147147    excluded.insert(atomIds[ATOM_COUNT/2]);
     
    152152
    153153  {
    154     std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2])));
     154    std::vector<atom*> testAtoms = World::getInstance().getAllAtoms(NoAtoms()||(AtomById(atomIds[ATOM_COUNT/2])));
    155155    CPPUNIT_ASSERT_EQUAL( (size_t)1, testAtoms.size());
    156156    CPPUNIT_ASSERT_EQUAL( atomIds[ATOM_COUNT/2], testAtoms[0]->getId());
  • src/unittests/MoleculeDescriptorTest.cpp

    r31af19 r23b547  
    2929// set up and tear down
    3030void MoleculeDescriptorTest::setUp(){
    31   World::get();
     31  World::getInstance();
    3232  for(int i=0;i<MOLECULE_COUNT;++i){
    33     molecules[i]= World::get()->createMolecule();
     33    molecules[i]= World::getInstance().createMolecule();
    3434    moleculeIds[i]= molecules[i]->getId();
    3535  }
     
    3737
    3838void MoleculeDescriptorTest::tearDown(){
    39   World::destroy();
     39  World::purgeInstance();
    4040}
    4141
     
    7373
    7474void MoleculeDescriptorTest::MoleculeBaseSetsTest(){
    75   std::vector<molecule*> allMolecules = World::get()->getAllMolecules(AllMolecules());
     75  std::vector<molecule*> allMolecules = World::getInstance().getAllMolecules(AllMolecules());
    7676  CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(allMolecules,moleculeIds));
    7777  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(allMolecules));
    7878
    79   std::vector<molecule*> noMolecules = World::get()->getAllMolecules(NoMolecules());
     79  std::vector<molecule*> noMolecules = World::getInstance().getAllMolecules(NoMolecules());
    8080  CPPUNIT_ASSERT_EQUAL( true , noMolecules.empty());
    8181}
     
    8383  // test Molecules from boundaries and middle of the set
    8484  molecule* testMolecule;
    85   testMolecule = World::get()->getMolecule(MoleculeById(moleculeIds[0]));
     85  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[0]));
    8686  CPPUNIT_ASSERT(testMolecule);
    8787  CPPUNIT_ASSERT_EQUAL( moleculeIds[0], testMolecule->getId());
    88   testMolecule = World::get()->getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT/2]));
     88  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT/2]));
    8989  CPPUNIT_ASSERT(testMolecule);
    9090  CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecule->getId());
    91   testMolecule = World::get()->getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT-1]));
     91  testMolecule = World::getInstance().getMolecule(MoleculeById(moleculeIds[MOLECULE_COUNT-1]));
    9292  CPPUNIT_ASSERT(testMolecule);
    9393  CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT-1], testMolecule->getId());
     
    103103  }
    104104  // test from outside of set
    105   testMolecule = World::get()->getMolecule(MoleculeById(outsideId));
     105  testMolecule = World::getInstance().getMolecule(MoleculeById(outsideId));
    106106  CPPUNIT_ASSERT(!testMolecule);
    107107}
     
    109109  // test some elementary set operations
    110110  {
    111     std::vector<molecule*> testMolecules = World::get()->getAllMolecules(AllMolecules()||NoMolecules());
     111    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()||NoMolecules());
    112112    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
    113113    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
     
    115115
    116116  {
    117     std::vector<molecule*> testMolecules = World::get()->getAllMolecules(NoMolecules()||AllMolecules());
     117    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||AllMolecules());
    118118    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
    119119    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
     
    121121
    122122  {
    123     std::vector<molecule*> testMolecules = World::get()->getAllMolecules(NoMolecules()&&AllMolecules());
     123    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()&&AllMolecules());
    124124    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
    125125  }
    126126
    127127  {
    128     std::vector<molecule*> testMolecules = World::get()->getAllMolecules(AllMolecules()&&NoMolecules());
     128    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&NoMolecules());
    129129    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
    130130  }
    131131
    132132  {
    133     std::vector<molecule*> testMolecules = World::get()->getAllMolecules(!AllMolecules());
     133    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!AllMolecules());
    134134    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
    135135  }
    136136
    137137  {
    138     std::vector<molecule*> testMolecules = World::get()->getAllMolecules(!NoMolecules());
     138    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!NoMolecules());
    139139    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
    140140    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
     
    143143  // exclude and include some molecules
    144144  {
    145     std::vector<molecule*> testMolecules = World::get()->getAllMolecules(AllMolecules()&&(!MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
     145    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&(!MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
    146146    std::set<moleculeId_t> excluded;
    147147    excluded.insert(moleculeIds[MOLECULE_COUNT/2]);
     
    152152
    153153  {
    154     std::vector<molecule*> testMolecules = World::get()->getAllMolecules(NoMolecules()||(MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
     154    std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||(MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
    155155    CPPUNIT_ASSERT_EQUAL( (size_t)1, testMolecules.size());
    156156    CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecules[0]->getId());
  • src/unittests/analysisbondsunittest.cpp

    r31af19 r23b547  
    6161
    6262  // construct periodentafel
    63   tafel = World::get()->getPeriode();
     63  tafel = World::getInstance().getPeriode();
    6464  tafel->AddElement(hydrogen);
    6565  tafel->AddElement(carbon);
    6666
    6767  // construct molecule (tetraeder of hydrogens)
    68   TestMolecule = World::get()->createMolecule();
    69   Walker = World::get()->createAtom();
     68  TestMolecule = World::getInstance().createMolecule();
     69  Walker = World::getInstance().createAtom();
    7070  Walker->type = hydrogen;
    7171  Walker->node->Init(1.5, 0., 1.5 );
    7272  TestMolecule->AddAtom(Walker);
    73   Walker = World::get()->createAtom();
     73  Walker = World::getInstance().createAtom();
    7474  Walker->type = hydrogen;
    7575  Walker->node->Init(0., 1.5, 1.5 );
    7676  TestMolecule->AddAtom(Walker);
    77   Walker = World::get()->createAtom();
     77  Walker = World::getInstance().createAtom();
    7878  Walker->type = hydrogen;
    7979  Walker->node->Init(1.5, 1.5, 0. );
    8080  TestMolecule->AddAtom(Walker);
    81   Walker = World::get()->createAtom();
     81  Walker = World::getInstance().createAtom();
    8282  Walker->type = hydrogen;
    8383  Walker->node->Init(0., 0., 0. );
    8484  TestMolecule->AddAtom(Walker);
    85   Walker = World::get()->createAtom();
     85  Walker = World::getInstance().createAtom();
    8686  Walker->type = carbon;
    8787  Walker->node->Init(0.5, 0.5, 0.5 );
     
    117117
    118118  // remove molecule
    119   World::get()->destroyMolecule(TestMolecule);
     119  World::getInstance().destroyMolecule(TestMolecule);
    120120  // note that all the atoms are cleaned by TestMolecule
    121   World::destroy();
     121  World::purgeInstance();
    122122};
    123123
  • src/unittests/atomsCalculationTest.cpp

    r31af19 r23b547  
    5151// set up and tear down
    5252void atomsCalculationTest::setUp(){
    53   World::get();
     53  World::getInstance();
    5454  for(int i=0;i<ATOM_COUNT;++i){
    5555    atoms[i]= new AtomStub(i);
    56     World::get()->registerAtom(atoms[i]);
     56    World::getInstance().registerAtom(atoms[i]);
    5757  }
    5858}
    5959void atomsCalculationTest::tearDown(){
    60   World::destroy();
     60  World::purgeInstance();
    6161  ActionRegistry::purgeRegistry();
    6262}
     
    9292}
    9393
    94 static void operation(atom* _atom){
    95   AtomStub *atom = dynamic_cast<AtomStub*>(_atom);
    96   assert(atom);
    97   atom->doSomething();
    98 }
    99 
    100 
    10194void atomsCalculationTest::testCalculateSimple(){
    102   AtomsCalculation<int> *calc = World::get()->calcOnAtoms<int>(boost::bind(&atom::getId,_1),"FOO",AllAtoms());
     95  AtomsCalculation<int> *calc = World::getInstance().calcOnAtoms<int>(boost::bind(&atom::getId,_1),"FOO",AllAtoms());
    10396  std::vector<int> allIds = (*calc)();
    10497  CPPUNIT_ASSERT(hasAll(allIds,0,ATOM_COUNT));
     
    108101void atomsCalculationTest::testCalculateExcluded(){
    109102  int excluded = ATOM_COUNT/2;
    110   AtomsCalculation<int> *calc = World::get()->calcOnAtoms<int>(boost::bind(&atom::getId,_1),"FOO",AllAtoms() && !AtomById(excluded));
     103  AtomsCalculation<int> *calc = World::getInstance().calcOnAtoms<int>(boost::bind(&atom::getId,_1),"FOO",AllAtoms() && !AtomById(excluded));
    111104  std::vector<int> allIds = (*calc)();
    112105  std::set<int> excluded_set;
  • src/unittests/bondgraphunittest.cpp

    r31af19 r23b547  
    5757
    5858  // construct periodentafel
    59   tafel = World::get()->getPeriode();
     59  tafel = World::getInstance().getPeriode();
    6060  tafel->AddElement(hydrogen);
    6161  tafel->AddElement(carbon);
    6262
    6363  // construct molecule (tetraeder of hydrogens)
    64   TestMolecule = World::get()->createMolecule();
    65   Walker = World::get()->createAtom();
     64  TestMolecule = World::getInstance().createMolecule();
     65  Walker = World::getInstance().createAtom();
    6666  Walker->type = hydrogen;
    6767  Walker->node->Init(1., 0., 1. );
    6868  TestMolecule->AddAtom(Walker);
    69   Walker = World::get()->createAtom();
     69  Walker = World::getInstance().createAtom();
    7070  Walker->type = hydrogen;
    7171  Walker->node->Init(0., 1., 1. );
    7272  TestMolecule->AddAtom(Walker);
    73   Walker = World::get()->createAtom();
     73  Walker = World::getInstance().createAtom();
    7474  Walker->type = hydrogen;
    7575  Walker->node->Init(1., 1., 0. );
    7676  TestMolecule->AddAtom(Walker);
    77   Walker = World::get()->createAtom();
     77  Walker = World::getInstance().createAtom();
    7878  Walker->type = hydrogen;
    7979  Walker->node->Init(0., 0., 0. );
     
    102102
    103103  // remove molecule
    104   World::get()->destroyMolecule(TestMolecule);
     104  World::getInstance().destroyMolecule(TestMolecule);
    105105  // note that all the atoms, molecules, the tafel and the elements
    106106  // are all cleaned when the world is destroyed
    107   World::destroy();
     107  World::purgeInstance();
    108108  MemoryUsageObserver::purgeInstance();
    109109  logger::purgeInstance();
  • src/unittests/listofbondsunittest.cpp

    r31af19 r23b547  
    5151
    5252  // construct periodentafel
    53   tafel = World::get()->getPeriode();
     53  tafel = World::getInstance().getPeriode();
    5454  tafel->AddElement(hydrogen);
    5555
    5656  // construct molecule (tetraeder of hydrogens)
    57   TestMolecule = World::get()->createMolecule();
    58   Walker = World::get()->createAtom();
     57  TestMolecule = World::getInstance().createMolecule();
     58  Walker = World::getInstance().createAtom();
    5959  Walker->type = hydrogen;
    6060  Walker->node->Init(1., 0., 1. );
    6161  TestMolecule->AddAtom(Walker);
    62   Walker = World::get()->createAtom();
     62  Walker = World::getInstance().createAtom();
    6363  Walker->type = hydrogen;
    6464  Walker->node->Init(0., 1., 1. );
    6565  TestMolecule->AddAtom(Walker);
    66   Walker = World::get()->createAtom();
     66  Walker = World::getInstance().createAtom();
    6767  Walker->type = hydrogen;
    6868  Walker->node->Init(1., 1., 0. );
    6969  TestMolecule->AddAtom(Walker);
    70   Walker = World::get()->createAtom();
     70  Walker = World::getInstance().createAtom();
    7171  Walker->type = hydrogen;
    7272  Walker->node->Init(0., 0., 0. );
     
    8282{
    8383  // remove
    84   World::get()->destroyMolecule(TestMolecule);
     84  World::getInstance().destroyMolecule(TestMolecule);
    8585  // note that all the atoms, molecules, the tafel and the elements
    8686  // are all cleaned when the world is destroyed
    87   World::destroy();
     87  World::purgeInstance();
    8888  MemoryUsageObserver::purgeInstance();
    8989  logger::purgeInstance();
     
    250250
    251251  // remove atom2
    252   World::get()->destroyAtom(atom2);
     252  World::getInstance().destroyAtom(atom2);
    253253
    254254  // check bond if removed from other atom
  • src/unittests/manipulateAtomsTest.cpp

    r31af19 r23b547  
    3030  AtomStub(int _id) :
    3131  atom(),
    32   id(_id),
    33   manipulated(false)
     32  manipulated(false),
     33  id(_id)
    3434  {}
    3535
     
    6666// set up and tear down
    6767void manipulateAtomsTest::setUp(){
    68   World::get();
     68  World::getInstance();
    6969  for(int i=0;i<ATOM_COUNT;++i){
    7070    atoms[i]= new AtomStub(i);
    71     World::get()->registerAtom(atoms[i]);
     71    World::getInstance().registerAtom(atoms[i]);
    7272  }
    7373}
    7474void manipulateAtomsTest::tearDown(){
    75   World::destroy();
     75  World::purgeInstance();
    7676  ActionRegistry::purgeRegistry();
    77 }
    78 
    79 // some helper functions
    80 static bool hasAll(std::vector<atom*> atoms,int min, int max, std::set<int> excluded = std::set<int>()){
    81   for(int i=min;i<max;++i){
    82     if(!excluded.count(i)){
    83       std::vector<atom*>::iterator iter;
    84       bool res=false;
    85       for(iter=atoms.begin();iter!=atoms.end();++iter){
    86         res |= (*iter)->getId() == i;
    87       }
    88       if(!res) {
    89         cout << "Atom " << i << " missing in returned list" << endl;
    90         return false;
    91       }
    92     }
    93   }
    94   return true;
    95 }
    96 
    97 static bool hasNoDuplicates(std::vector<atom*> atoms){
    98   std::set<int> found;
    99   std::vector<atom*>::iterator iter;
    100   for(iter=atoms.begin();iter!=atoms.end();++iter){
    101     int id = (*iter)->getId();
    102     if(found.count(id))
    103       return false;
    104     found.insert(id);
    105   }
    106   return true;
    10777}
    10878
     
    11585
    11686void manipulateAtomsTest::testManipulateSimple(){
    117   ManipulateAtomsProcess *proc = World::get()->manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms());
     87  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms());
    11888  proc->call();
    119   std::vector<atom*> allAtoms = World::get()->getAllAtoms(AllAtoms());
     89  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
    12090  std::vector<atom*>::iterator iter;
    12191  for(iter=allAtoms.begin();iter!=allAtoms.end();++iter){
     
    12898
    12999void manipulateAtomsTest::testManipulateExcluded(){
    130   ManipulateAtomsProcess *proc = World::get()->manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms() && !AtomById(ATOM_COUNT/2));
     100  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms() && !AtomById(ATOM_COUNT/2));
    131101  proc->call();
    132   std::vector<atom*> allAtoms = World::get()->getAllAtoms(AllAtoms());
     102  std::vector<atom*> allAtoms = World::getInstance().getAllAtoms(AllAtoms());
    133103  std::vector<atom*>::iterator iter;
    134104  for(iter=allAtoms.begin();iter!=allAtoms.end();++iter){
     
    145115void manipulateAtomsTest::testObserver(){
    146116  countObserver *obs = new countObserver();
    147   World::get()->signOn(obs);
    148   ManipulateAtomsProcess *proc = World::get()->manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms() && !AtomById(ATOM_COUNT/2));
     117  World::getInstance().signOn(obs);
     118  ManipulateAtomsProcess *proc = World::getInstance().manipulateAtoms(boost::bind(operation,_1),"FOO",AllAtoms() && !AtomById(ATOM_COUNT/2));
    149119  proc->call();
    150120
    151121  CPPUNIT_ASSERT_EQUAL(1,obs->count);
    152   World::get()->signOff(obs);
     122  World::getInstance().signOff(obs);
    153123  delete obs;
    154124}
Note: See TracChangeset for help on using the changeset viewer.