Changes in src/UIElements/UIFactory.cpp [112b09:bcf653]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/UIFactory.cpp
r112b09 rbcf653 1 /* 2 * Project: MoleCuilder 3 * Description: creates and alters molecular systems 4 * Copyright (C) 2010 University of Bonn. All rights reserved. 5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. 6 */ 7 1 8 /* 2 9 * UIFactory.cpp … … 6 13 */ 7 14 15 // include config.h 16 #ifdef HAVE_CONFIG_H 17 #include <config.h> 18 #endif 19 8 20 #include "Helpers/MemDebug.hpp" 9 21 10 #include < cassert>22 #include <utility> 11 23 #include "Patterns/Singleton_impl.hpp" 12 #include "UIFactory.hpp" 24 #include "UIElements/UIFactory.hpp" 25 #include "Helpers/Assert.hpp" 26 #include "Helpers/MemDebug.hpp" 13 27 14 // all factories that can be used: 15 #include "TextUI/TextUIFactory.hpp" 16 #include "CommandLineUI/CommandLineUIFactory.hpp" 28 using namespace std; 29 30 std::map<std::string,boost::shared_ptr<UIFactory::factoryDescription> > UIFactory::factories; 17 31 18 32 UIFactory::UIFactory() 19 { 20 // TODO Auto-generated constructor stub 33 {} 21 34 35 UIFactory::~UIFactory() 36 {} 37 38 void UIFactory::makeUserInterface(std::string type) { 39 ASSERT(factories.count(type),"Selected factory was not registered before creation."); 40 // call the factory factory 41 setInstance(factories[type]->makeFactory()); 22 42 } 23 43 24 UIFactory::~UIFactory() 25 { 26 // TODO Auto-generated destructor stub 27 } 28 29 void UIFactory::makeUserInterface(InterfaceTypes type) { 30 switch(type) { 31 case Text : 32 setInstance(new TextUIFactory()); 33 break; 34 case CommandLine: 35 setInstance(new CommandLineUIFactory()); 36 break; 37 38 default: 39 assert(0 && "No such Factory in stock"); 40 break; 41 } 44 void UIFactory::registerFactory(factoryDescription *factoryDesc) { 45 ASSERT(!factories.count(factoryDesc->name),"Trying to re-register an already registered factory."); 46 factories.insert(make_pair(factoryDesc->name, 47 boost::shared_ptr<factoryDescription>(factoryDesc))); 42 48 } 43 49 44 50 CONSTRUCT_SINGLETON(UIFactory) 51 52 UIFactory::factoryDescription::factoryDescription(string _name) : 53 name(_name) 54 {} 55 56 UIFactory::factoryDescription::~factoryDescription() 57 {}
Note:
See TracChangeset
for help on using the changeset viewer.