Ignore:
Timestamp:
Mar 11, 2010, 2:08:44 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
c3f8c4
Parents:
abab7e
Message:

Changed ActionRegistry to use the new Singleton Mechanism

Location:
molecuilder/src/Actions
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/Actions/Action.cpp

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

    rabab7e r8a4f12  
    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)
  • molecuilder/src/Actions/ActionRegistry.hpp

    rabab7e r8a4f12  
    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
Note: See TracChangeset for help on using the changeset viewer.