标签:style blog io ar color os sp on div
#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; }
标签:style blog io ar color os sp on div
原文地址:http://www.cnblogs.com/stanley198610281217/p/4154701.html