|
Last change
on this file since 78b9d9 was 3e8325, checked in by Tillmann Crueger <crueger@…>, 16 years ago |
|
Added a central registry that allows access to actions by name.
|
-
Property mode
set to
100644
|
|
File size:
930 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * UIFactory.cpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: Jan 5, 2010
|
|---|
| 5 | * Author: crueger
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 | #include <cassert>
|
|---|
| 10 | #include "UIElements/UIFactory.hpp"
|
|---|
| 11 |
|
|---|
| 12 | // all factories that can be used:
|
|---|
| 13 | #include "UIElements/TextUIFactory.hpp"
|
|---|
| 14 |
|
|---|
| 15 | UIFactory *UIFactory::theFactory = 0;
|
|---|
| 16 |
|
|---|
| 17 | UIFactory::UIFactory()
|
|---|
| 18 | {
|
|---|
| 19 | // TODO Auto-generated constructor stub
|
|---|
| 20 |
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | UIFactory::~UIFactory()
|
|---|
| 24 | {
|
|---|
| 25 | // TODO Auto-generated destructor stub
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | void UIFactory::makeUserInterface(InterfaceTypes type) {
|
|---|
| 29 | assert(theFactory == 0 && "makeUserInterface should only be called once");
|
|---|
| 30 | switch(type) {
|
|---|
| 31 | case Text :
|
|---|
| 32 | theFactory = new TextUIFactory();
|
|---|
| 33 | break;
|
|---|
| 34 |
|
|---|
| 35 | default:
|
|---|
| 36 | assert(0 && "No such Factory in stock");
|
|---|
| 37 | break;
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | UIFactory* UIFactory::get(){
|
|---|
| 42 | assert(theFactory != 0 && "No UserInterface created prior to factory access");
|
|---|
| 43 | return theFactory;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | void UIFactory::purgeInstance(){
|
|---|
| 48 | if(theFactory) {
|
|---|
| 49 | delete theFactory;
|
|---|
| 50 | theFactory = 0;
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.