码迷,mamicode.com
首页 > 其他好文 > 详细

Facade

时间:2014-12-10 10:32:19      阅读:153      评论:0      收藏:0      [点我收藏+]

标签: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;
}

 

Facade

标签:style   blog   io   ar   color   os   sp   on   div   

原文地址:http://www.cnblogs.com/stanley198610281217/p/4154701.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!