本文整理汇总了C++中DynamicLibrary::setFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicLibrary::setFileName方法的具体用法?C++ DynamicLibrary::setFileName怎么用?C++ DynamicLibrary::setFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicLibrary
的用法示例。
在下文中一共展示了DynamicLibrary::setFileName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadPlugin
// --- Plugin Loading ------------------------------------------------------ //
/// Loads a plugin from \p fileName. Returns \c false if an error
/// occurs.
bool PluginManager::loadPlugin(const std::string &fileName)
{
DynamicLibrary *library = new DynamicLibrary;
library->setFileName(fileName);
bool ok = library->open();
if(!ok){
std::cerr << "PluginManager: Error: Failed to load plugin: (" << fileName << "):"
<< library->errorString() << std::endl;
return false;
}
typedef Plugin* (*InitFunction)();
InitFunction initFunction = reinterpret_cast<InitFunction>(library->resolveFunction("chemkit_plugin_init"));
if(!initFunction){
std::cerr << "PluginManager: Error: Failed to load plugin: (" << fileName << "):"
<< "Plugin contains no init() function." << std::endl;
return false;
}
Plugin *plugin = initFunction();
if(!plugin){
std::cerr << "PluginManager: Error: Failed to load plugin: (" << fileName << "):"
<< "Calling the plugin's init() function failed." << std::endl;
return false;
}
plugin->setLibrary(library);
d->plugins.push_back(plugin);
return true;
}