开源服务器框架NoahFrame分享 第二章:插件与模块
2017-10-31
NFCPluginManager::GetSingletonPtr()->CheckConfig();
NFCPluginManager::GetSingletonPtr()->ReadyExecute();
while (true)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
NFCPluginManager::GetSingletonPtr()->Execute();
}
NFCPluginManager::GetSingletonPtr()->BeforeShut();
NFCPluginManager::GetSingletonPtr()->Shut();
NFCPluginManager::GetSingletonPtr()->ReleaseInstance();
return 0;
}
因为任何一个插件(Plugin)必须继承自NFIPlugin类,它拥有NFIModule类所有的统一调用接口(任何模块,必须继承自NFIModule并拥有以下接口Awake, Init, AfterInit, Execute, BeforeShut, Shut, Finalize等统一接口):
class NFIModule
{
public:
virtual bool Awake()
{
return true;
}
virtual bool Init()
{
return true;
}
virtual bool AfterInit()
{
return true;
}
virtual bool CheckConfig()
{
return true;
}
virtual bool BeforeShut()
{
return true;
}
virtual bool Shut()
{
网友评论