本文整理汇总了C++中CModInfo::GetGlobalLoader方法的典型用法代码示例。如果您正苦于以下问题:C++ CModInfo::GetGlobalLoader方法的具体用法?C++ CModInfo::GetGlobalLoader怎么用?C++ CModInfo::GetGlobalLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModInfo
的用法示例。
在下文中一共展示了CModInfo::GetGlobalLoader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadModule
bool CModules::LoadModule(const CString& sModule, const CString& sArgs, CUser* pUser, CString& sRetMsg) {
sRetMsg = "";
if (FindModule(sModule) != NULL) {
sRetMsg = "Module [" + sModule + "] already loaded.";
return false;
}
bool bSuccess;
GLOBALMODULECALL(OnModuleLoading(sModule, sArgs, bSuccess, sRetMsg), pUser, NULL, return bSuccess);
CString sModPath, sDataPath;
bool bVersionMismatch;
CModInfo Info;
if (!FindModPath(sModule, sModPath, sDataPath)) {
sRetMsg = "Unable to find module [" + sModule + "]";
return false;
}
ModHandle p = OpenModule(sModule, sModPath, bVersionMismatch, Info, sRetMsg);
if (!p)
return false;
if (bVersionMismatch) {
dlclose(p);
sRetMsg = "Version mismatch, recompile this module.";
return false;
}
if ((pUser == NULL) != Info.IsGlobal()) {
dlclose(p);
sRetMsg = "Module [" + sModule + "] is ";
sRetMsg += Info.IsGlobal() ? "" : "not ";
sRetMsg += "a global module.";
return false;
}
CModule* pModule = NULL;
if (pUser) {
pModule = Info.GetLoader()(p, pUser, sModule, sDataPath);
} else {
pModule = Info.GetGlobalLoader()(p, sModule, sDataPath);
}
pModule->SetDescription(Info.GetDescription());
pModule->SetGlobal(Info.IsGlobal());
pModule->SetArgs(sArgs);
pModule->SetModPath(CDir::ChangeDir(CZNC::Get().GetCurPath(), sModPath));
push_back(pModule);
bool bLoaded;
try {
bLoaded = pModule->OnLoad(sArgs, sRetMsg);
} catch (CModule::EModException) {
bLoaded = false;
sRetMsg = "Caught an exception";
}
if (!bLoaded) {
UnloadModule(sModule, sModPath);
if (!sRetMsg.empty())
sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg;
else
sRetMsg = "Module [" + sModule + "] aborted.";
return false;
}
if (!sRetMsg.empty()) {
sRetMsg += "[" + sRetMsg + "] ";
}
sRetMsg += "[" + sModPath + "]";
return true;
}