本文整理汇总了C++中CExtension::IsLoaded方法的典型用法代码示例。如果您正苦于以下问题:C++ CExtension::IsLoaded方法的具体用法?C++ CExtension::IsLoaded怎么用?C++ CExtension::IsLoaded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CExtension
的用法示例。
在下文中一共展示了CExtension::IsLoaded方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadExtension
IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength)
{
/* Remove platform extension if it's there. Compat hack. */
const char *ext = libsys->GetFileExtension(file);
if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
{
char path2[PLATFORM_MAX_PATH];
smcore.Format(path2, sizeof(path2), "%s", file);
path2[strlen(file) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
return LoadExtension(path2, error, maxlength);
}
IExtension *pAlready;
if ((pAlready=FindExtensionByFile(file)) != NULL)
{
return pAlready;
}
CExtension *pExt = new CLocalExtension(file);
if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
{
pExt->Unload();
delete pExt;
return NULL;
}
/* :TODO: do QueryRunning check if the map is loaded */
m_Libs.push_back(pExt);
return pExt;
}
示例2:
IExtension *CExtensionManager::FindExtensionByName(const char *ext)
{
List<CExtension *>::iterator iter;
CExtension *pExt;
IExtensionInterface *pAPI;
const char *name;
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
{
pExt = (*iter);
if (!pExt->IsLoaded())
{
continue;
}
if ((pAPI = pExt->GetAPI()) == NULL)
{
continue;
}
name = pAPI->GetExtensionName();
if (!name)
{
continue;
}
if (strcmp(name, ext) == 0)
{
return pExt;
}
}
return NULL;
}
示例3: LoadAutoExtension
IExtension *CExtensionManager::LoadAutoExtension(const char *path)
{
/* Remove platform extension if it's there. Compat hack. */
const char *ext = libsys->GetFileExtension(path);
if (strcmp(ext, PLATFORM_LIB_EXT) == 0)
{
char path2[PLATFORM_MAX_PATH];
smcore.Format(path2, sizeof(path2), "%s", path);
path2[strlen(path) - strlen(PLATFORM_LIB_EXT) - 1] = '\0';
return LoadAutoExtension(path2);
}
IExtension *pAlready;
if ((pAlready=FindExtensionByFile(path)) != NULL)
{
return pAlready;
}
char error[256];
CExtension *p = new CLocalExtension(path);
/* We put us in the list beforehand so extensions that check for each other
* won't recursively load each other.
*/
m_Libs.push_back(p);
if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
{
smcore.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
p->SetError(error);
}
return p;
}
示例4: CRemoteExtension
IExtension *CExtensionManager::LoadExternal(IExtensionInterface *pInterface,
const char *filepath,
const char *filename,
char *error,
size_t maxlength)
{
IExtension *pAlready;
if ((pAlready=FindExtensionByFile(filename)) != NULL)
{
return pAlready;
}
CExtension *pExt = new CRemoteExtension(pInterface, filename, filepath);
if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
{
pExt->Unload();
delete pExt;
return NULL;
}
m_Libs.push_back(pExt);
return pExt;
}
示例5: LoadAutoExtension
IExtension *CExtensionManager::LoadAutoExtension(const char *path)
{
if (!strstr(path, "." PLATFORM_LIB_EXT))
{
char newpath[PLATFORM_MAX_PATH];
g_LibSys.PathFormat(newpath, sizeof(newpath), "%s.%s", path, PLATFORM_LIB_EXT);
return LoadAutoExtension(newpath);
}
IExtension *pAlready;
if ((pAlready=FindExtensionByFile(path)) != NULL)
{
return pAlready;
}
char error[256];
CExtension *p = new CLocalExtension(path);
/* We put us in the list beforehand so extensions that check for each other
* won't recursively load each other.
*/
m_Libs.push_back(p);
if (!p->Load(error, sizeof(error)) || !p->IsLoaded())
{
g_Logger.LogError("[SM] Unable to load extension \"%s\": %s", path, error);
p->SetError(error);
}
return p;
}
示例6: MarkAllLoaded
void CExtensionManager::MarkAllLoaded()
{
List<CExtension *>::iterator iter;
CExtension *pExt;
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++)
{
pExt = (*iter);
if (!pExt->IsLoaded())
{
continue;
}
if (pExt->m_bFullyLoaded)
{
continue;
}
pExt->MarkAllLoaded();
}
}
示例7: CLocalExtension
IExtension *CExtensionManager::LoadExtension(const char *file, char *error, size_t maxlength)
{
IExtension *pAlready;
if ((pAlready=FindExtensionByFile(file)) != NULL)
{
return pAlready;
}
CExtension *pExt = new CLocalExtension(file);
if (!pExt->Load(error, maxlength) || !pExt->IsLoaded())
{
pExt->Unload();
delete pExt;
return NULL;
}
/* :TODO: do QueryRunning check if the map is loaded */
m_Libs.push_back(pExt);
return pExt;
}
示例8: OnRootConsoleCommand
void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
{
int argcount = smcore.Argc(command);
if (argcount >= 3)
{
const char *cmd = smcore.Arg(command, 2);
if (strcmp(cmd, "list") == 0)
{
List<CExtension *>::iterator iter;
CExtension *pExt;
unsigned int num = 1;
switch (m_Libs.size())
{
case 1:
{
rootmenu->ConsolePrint("[SM] Displaying 1 extension:");
break;
}
case 0:
{
rootmenu->ConsolePrint("[SM] No extensions are loaded.");
break;
}
default:
{
rootmenu->ConsolePrint("[SM] Displaying %d extensions:", m_Libs.size());
break;
}
}
for (iter=m_Libs.begin(); iter!=m_Libs.end(); iter++,num++)
{
pExt = (*iter);
if (pExt->IsLoaded())
{
char error[255];
if (!pExt->IsRunning(error, sizeof(error)))
{
rootmenu->ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), error);
}
else
{
IExtensionInterface *pAPI = pExt->GetAPI();
const char *name = pAPI->GetExtensionName();
const char *version = pAPI->GetExtensionVerString();
const char *descr = pAPI->GetExtensionDescription();
rootmenu->ConsolePrint("[%02d] %s (%s): %s", num, name, version, descr);
}
} else {
rootmenu->ConsolePrint("[%02d] <FAILED> file \"%s\": %s", num, pExt->GetFilename(), pExt->m_Error.c_str());
}
}
return;
}
else if (strcmp(cmd, "load") == 0)
{
if (argcount < 4)
{
rootmenu->ConsolePrint("[SM] Usage: sm exts load <file>");
return;
}
const char *filename = smcore.Arg(command, 3);
char path[PLATFORM_MAX_PATH];
char error[256];
smcore.Format(path, sizeof(path), "%s%s%s", filename, !strstr(filename, ".ext") ? ".ext" : "",
!strstr(filename, "." PLATFORM_LIB_EXT) ? "." PLATFORM_LIB_EXT : "");
if (FindExtensionByFile(path) != NULL)
{
rootmenu->ConsolePrint("[SM] Extension %s is already loaded.", path);
return;
}
if (LoadExtension(path, error, sizeof(error)))
{
rootmenu->ConsolePrint("[SM] Loaded extension %s successfully.", path);
} else
{
rootmenu->ConsolePrint("[SM] Extension %s failed to load: %s", path, error);
}
return;
}
else if (strcmp(cmd, "info") == 0)
{
if (argcount < 4)
{
rootmenu->ConsolePrint("[SM] Usage: sm exts info <#>");
return;
}
const char *sId = smcore.Arg(command, 3);
unsigned int id = atoi(sId);
if (id <= 0)
{
rootmenu->ConsolePrint("[SM] Usage: sm exts info <#>");
return;
}
//.........这里部分代码省略.........
示例9: UnloadExtension
bool CExtensionManager::UnloadExtension(IExtension *_pExt)
{
if (!_pExt)
{
return false;
}
CExtension *pExt = (CExtension *)_pExt;
if (m_Libs.find(pExt) == m_Libs.end())
{
return false;
}
/* Tell it to unload */
if (pExt->IsLoaded())
{
IExtensionInterface *pAPI = pExt->GetAPI();
pAPI->OnExtensionUnload();
}
/* First remove us from internal lists */
g_ShareSys.RemoveInterfaces(_pExt);
m_Libs.remove(pExt);
List<CExtension *> UnloadQueue;
/* Handle dependencies */
if (pExt->IsLoaded())
{
/* Unload any dependent plugins */
List<CPlugin *>::iterator p_iter = pExt->m_Dependents.begin();
while (p_iter != pExt->m_Dependents.end())
{
/* We have to manually unlink ourselves here, since we're no longer being managed */
scripts->UnloadPlugin((*p_iter));
p_iter = pExt->m_Dependents.erase(p_iter);
}
List<String>::iterator s_iter;
for (s_iter = pExt->m_Libraries.begin();
s_iter != pExt->m_Libraries.end();
s_iter++)
{
scripts->OnLibraryAction((*s_iter).c_str(), LibraryAction_Removed);
}
/* Notify and/or unload all dependencies */
List<CExtension *>::iterator c_iter;
CExtension *pDep;
IExtensionInterface *pAPI;
for (c_iter = m_Libs.begin(); c_iter != m_Libs.end(); c_iter++)
{
pDep = (*c_iter);
if ((pAPI=pDep->GetAPI()) == NULL)
{
continue;
}
if (pDep == pExt)
{
continue;
}
/* Now, get its dependency list */
bool dropped = false;
List<IfaceInfo>::iterator i_iter = pDep->m_Deps.begin();
while (i_iter != pDep->m_Deps.end())
{
if ((*i_iter).owner == _pExt)
{
if (!pAPI->QueryInterfaceDrop((*i_iter).iface))
{
if (!dropped)
{
dropped = true;
UnloadQueue.push_back(pDep);
}
}
pAPI->NotifyInterfaceDrop((*i_iter).iface);
i_iter = pDep->m_Deps.erase(i_iter);
}
else
{
i_iter++;
}
}
/* Flush out any back references to this plugin */
i_iter = pDep->m_ChildDeps.begin();
while (i_iter != pDep->m_ChildDeps.end())
{
if ((*i_iter).owner == pExt)
{
i_iter = pDep->m_ChildDeps.erase(i_iter);
}
else
{
i_iter++;
}
}
}
//.........这里部分代码省略.........