Changeset e73a8a2


Ignore:
Timestamp:
Mar 11, 2010, 2:08:44 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:
aee1a3
Parents:
7ca806
Message:

Changed ActionRegistry to use the new Singleton Mechanism

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.cpp

    r7ca806 re73a8a2  
    1717{
    1818  if(_doRegister){
    19     ActionRegistry::getRegistry()->registerAction(this);
     19    ActionRegistry::getInstance().registerAction(this);
    2020  }
    2121}
  • src/Actions/ActionRegistry.cpp

    r7ca806 re73a8a2  
    99#include "Actions/Action.hpp"
    1010
     11#include "Patterns/Singleton_impl.hpp"
     12
    1113#include <string>
    1214#include <cassert>
     
    1416
    1517using namespace std;
    16 
    17 ActionRegistry *ActionRegistry::theInstance=0;
    1818
    1919ActionRegistry::ActionRegistry()
     
    4343}
    4444
    45 // singleton stuff
    46 ActionRegistry* ActionRegistry::getRegistry(){
    47   if(!theInstance){
    48     theInstance = new ActionRegistry();
    49   }
    50   return theInstance;
    51 }
    52 
    53 void ActionRegistry::purgeRegistry(){
    54   if(theInstance){
    55     delete theInstance;
    56     theInstance = 0;
    57   }
    58 }
     45CONSTRUCT_SINGLETON(ActionRegistry)
  • src/Actions/ActionRegistry.hpp

    r7ca806 re73a8a2  
    1212#include <map>
    1313
     14#include "Patterns/Singleton.hpp"
     15
    1416class Action;
    1517
    16 class ActionRegistry
     18class ActionRegistry : public Singleton<ActionRegistry>
    1719{
     20  friend class Singleton<ActionRegistry>;
    1821public:
    1922  Action* getActionByName(const std::string);
     
    2326  std::map<const std::string,Action*> actionMap;
    2427
    25 // singleton stuff
    26 public:
    27   static ActionRegistry* getRegistry();
    28   static void purgeRegistry();
    2928private:
    3029  ActionRegistry();
    3130  virtual ~ActionRegistry();
    32   static ActionRegistry *theInstance;
    3331};
    3432
  • src/builder.cpp

    r7ca806 re73a8a2  
    21772177  logger::purgeInstance();
    21782178  errorLogger::purgeInstance();
    2179   ActionRegistry::purgeRegistry();
     2179  ActionRegistry::purgeInstance();
    21802180}
    21812181
  • src/unittests/SingletonTest.cpp

    r7ca806 re73a8a2  
    8787  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count1);
    8888  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count1);
     89  // no calls to the destructor should have occured so far
     90  CPPUNIT_ASSERT_EQUAL(0,SingletonStub1::count2);
     91  CPPUNIT_ASSERT_EQUAL(0,SingletonStub2::count2);
    8992
    9093  SingletonStub1::purgeInstance();
  • src/unittests/atomsCalculationTest.cpp

    r7ca806 re73a8a2  
    6363void atomsCalculationTest::tearDown(){
    6464  World::purgeInstance();
    65   ActionRegistry::purgeRegistry();
     65  ActionRegistry::purgeInstance();
    6666}
    6767
  • src/unittests/manipulateAtomsTest.cpp

    r7ca806 re73a8a2  
    7878void manipulateAtomsTest::tearDown(){
    7979  World::purgeInstance();
    80   ActionRegistry::purgeRegistry();
     80  ActionRegistry::purgeInstance();
    8181}
    8282
Note: See TracChangeset for help on using the changeset viewer.