Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/UIFactory.cpp

    r9fe36b rd7940e  
    88
    99#include <cassert>
     10#include "Patterns/Singleton_impl.hpp"
    1011#include "UIElements/UIFactory.hpp"
    1112
    1213// all factories that can be used:
    1314#include "UIElements/TextUIFactory.hpp"
    14 #ifdef USE_GUI_QT
    15 #include "UIElements/QT4/QTUIFactory.hpp"
    16 #endif
    17 
    18 UIFactory *UIFactory::theFactory = 0;
    1915
    2016UIFactory::UIFactory()
     
    3026
    3127void UIFactory::makeUserInterface(InterfaceTypes type) {
    32   assert(theFactory == 0 && "makeUserInterface should only be called once");
    3328  switch(type) {
    3429    case Text :
    35       theFactory = new TextUIFactory();
     30      setInstance(new TextUIFactory());
    3631      break;
    37 #ifdef USE_GUI_QT
    38     case QT4 :
    39       theFactory = new QTUIFactory();
    40       break;
    41 #endif
     32
    4233    default:
    4334      assert(0 && "No such Factory in stock");
     
    4637}
    4738
    48 UIFactory* UIFactory::get(){
    49   assert(theFactory != 0 && "No UserInterface created prior to factory access");
    50   return theFactory;
    51 }
    52 
    53 
    54 void UIFactory::purgeInstance(){
    55   if(theFactory) {
    56     delete theFactory;
    57     theFactory = 0;
    58   }
    59 }
     39CONSTRUCT_SINGLETON(UIFactory)
Note: See TracChangeset for help on using the changeset viewer.