Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/UIFactory.cpp

    rd7940e rcc04b7  
    88
    99#include <cassert>
    10 #include "Patterns/Singleton_impl.hpp"
    1110#include "UIElements/UIFactory.hpp"
    1211
    1312// all factories that can be used:
    1413#include "UIElements/TextUIFactory.hpp"
     14
     15UIFactory *UIFactory::theFactory = 0;
    1516
    1617UIFactory::UIFactory()
     
    2627
    2728void UIFactory::makeUserInterface(InterfaceTypes type) {
     29  assert(theFactory == 0 && "makeUserInterface should only be called once");
    2830  switch(type) {
    2931    case Text :
    30       setInstance(new TextUIFactory());
     32      theFactory = new TextUIFactory();
    3133      break;
    3234
     
    3739}
    3840
    39 CONSTRUCT_SINGLETON(UIFactory)
     41UIFactory* UIFactory::get(){
     42  assert(theFactory != 0 && "No UserInterface created prior to factory access");
     43  return theFactory;
     44}
     45
     46
     47void UIFactory::purgeInstance(){
     48  if(theFactory) {
     49    delete theFactory;
     50    theFactory = 0;
     51  }
     52}
Note: See TracChangeset for help on using the changeset viewer.