首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >您好,StartupCommand PureMVC cpp与CMake

您好,StartupCommand PureMVC cpp与CMake
EN

Stack Overflow用户
提问于 2014-06-24 15:54:42
回答 1查看 487关注 0票数 0

在execute() Startup SimpleCommand中显示"Hello Startup“的最简单的CMakeLists.txtmain.cppPureMVC sources示例是什么?

PureMVC源码是here

理想的解决方案可以是github项目的链接。

EN

回答 1

Stack Overflow用户

发布于 2014-07-28 17:16:30

您应该编译相应的dll和lib (调试或发布静态|共享),包括PureMVC文件。也许你可以从PureMVC::Patterns::Facade派生一个外观,覆盖必要的虚函数。因为在C++和类Java编程语言之间是不同的,所以被覆盖的initializeController()不会在基类的构造函数中被调用!下面是一个派生示例:

代码语言:javascript
复制
class ApplicationFacade
    : public virtual IFacade
    , public Facade
{
    friend class Facade;
public:
    static const string STARTUP;
    static const string EXIT;
protected:
    ApplicationFacade(void)
        : Facade(this, "ApplicationFacade")
    {
        initializeController();
    }

public:
    static ApplicationFacade& getInstance(void)
    {
        if (Facade::hasCore("ApplicationFacade"))
            return *(dynamic_cast<ApplicationFacade*>(&Facade::getInstance("ApplicationFacade")));
        return *(new ApplicationFacade());
    }

protected:
    virtual void initializeNotifier(string const& key)
    {
        Facade::initializeNotifier(key);
    }
    virtual void initializeFacade()
    {
        Facade::initializeFacade();
    }

    virtual void initializeController(void)
    {
        Facade::initializeController();
        StartupCommand* startupCommand = new StartupCommand();
        registerCommand(STARTUP, startupCommand);
        ExitCommand* exitCommand = new ExitCommand();
        registerCommand(EXIT, exitCommand);
    }

    ~ApplicationFacade()
    {
    }
};
const string ApplicationFacade::STARTUP = "startup";
const string ApplicationFacade::EXIT = "exit";

StartupCommand和ExitCommand派生自PureMVC::Patterns::SimpleCommand,然后在main.cpp中,您可以通过以下方式启动程序:

代码语言:javascript
复制
ApplicationFacade& facade = ApplicationFacade::getInstance();
facade.sendNotification(ApplicationFacade::STARTUP);

并退出:

代码语言:javascript
复制
facade.sendNotification(ApplicationFacade::EXIT);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24381250

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档