CMakeLists.txt
,main.cpp
和PureMVC sources
从execute()Startup SimpleCommand显示“ Hello Startup”的最简单示例是什么?
PureMVC源是here
理想情况下,解决方案可以是指向github项目的链接。
最佳答案
您应该编译相应的dll和lib(调试或发布[static | shared]),包括PureMVC文件。也许您可以从PureMVC :: Patterns :: Facade派生外观,覆盖基本的虚函数。因为C ++和类似Java的编程语言之间存在差异,所以将不会在基类的构造函数中调用重写的initializeController()!
这是一个派生示例:
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中,可以通过以下方式启动程序:
ApplicationFacade& facade = ApplicationFacade::getInstance();
facade.sendNotification(ApplicationFacade::STARTUP);
然后退出:
facade.sendNotification(ApplicationFacade::EXIT);
关于c++ - 你好StartupCommand PureMVC cpp with CMake,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24381250/