/* * UIFactory.hpp * * Created on: Jan 5, 2010 * Author: crueger */ #ifndef UIFACTORY_HPP_ #define UIFACTORY_HPP_ class MainWindow; class Dialog; class MoleculeListClass; class config; class periodentafel; struct menuPopulaters; #include "Patterns/Singleton.hpp" #include #include #include /** * Abstract Factory to create any kind of User interface object needed by the programm. * * The factory can be created and has to be set to a certain type upon creation. It will then * only create UIelements of that certain type, so that all UIElements match. This way different * UIs can be handled in a concise abstract way. */ class UIFactory : public Singleton { friend class Singleton; public: /** * Produce some kind of main window, of whichever type was chosen when the factory was created */ virtual MainWindow* makeMainWindow(menuPopulaters,MoleculeListClass *, config *, periodentafel *, char *)=0; /** * Produce a User Interaction Dialog, that can query values from the User. * Again the type is determined upon factory creation. */ virtual Dialog* makeDialog()=0; protected: UIFactory(); virtual ~UIFactory(); public: struct factoryDescription { factoryDescription(std::string _name); virtual ~factoryDescription(); const std::string name; // yes this method really is a factory factory, to allow insertion of // arbitrary factories virtual UIFactory* makeFactory()=0; }; /** * create a Factory of a certain type. From that moment on only those UIElements can be produced by the factory */ static void makeUserInterface(std::string type); static void registerFactory(factoryDescription *factoryDesc); protected: private: static std::map > factories; }; #endif /* UIFACTORY_HPP_ */