首页 > 代码库 > Facade
Facade
#include <iostream>using namespace std;class GtkSystem{public: void Init(int argc, char** argv); int EventLoop() { cout<<"GtkSystem::EventLoop"<<endl; return 0; }};class QtSystem{public: void Init(int argc, char** argv); int EventLoop() { cout<<"QtSystem::EventLoop"<<endl; return 1; }};class LogSystem{public: static void Logger(const char* text) { cout<<"LogSystem::Logger["<<text<<"]"<<endl; }}; class GuiFacade{public: GuiFacade(); ~GuiFacade(); int MainLoop(); void Logger(const char* text);private:#ifdef GUI_WITH_GTK GtkSystem* m_pGuiSystem;#else QtSystem* m_pGuiSystem;#endif LogSystem* m_pLogSystem;};GuiFacade::GuiFacade(){#ifdef GUI_WITH_GTK m_pGuiSystem = new GtkSystem;#else m_pGuiSystem = new QtSystem;#endif}GuiFacade::~GuiFacade(){ delete m_pGuiSystem; m_pGuiSystem = NULL;}int GuiFacade::MainLoop(){ return m_pGuiSystem->EventLoop();}void GuiFacade::Logger(const char* text){ LogSystem::Logger(text);}int main(int argc, char *argv[]){ GuiFacade facade; facade.Logger("GuiSystem Startup"); facade.MainLoop(); return 0;}
Facade
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。