本文整理汇总了C++中DynamicLibrary类的典型用法代码示例。如果您正苦于以下问题:C++ DynamicLibrary类的具体用法?C++ DynamicLibrary怎么用?C++ DynamicLibrary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DynamicLibrary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DynamicLibrary
Plugin* Plugin::LoadPlugin(const char* pluginFile)
{
DynamicLibrary* lib = new DynamicLibrary();
if( !lib->Load(pluginFile) )
{
delete lib;
return 0;
}
PluginAccessor accessor = (PluginAccessor)lib->FindFunction("GetPlugin");
if( !accessor )
{
delete lib;
return 0;
}
Plugin* plugin = accessor(Memory::sInstance, Assert::sInstance);
if( !plugin )
{
delete lib;
return 0;
}
plugin->SetLibrary(lib);
return plugin;
}
示例2: plugins_file
void Application::RegisterAllPlugins()
{
std::ifstream plugins_file(cpw::ApplicationConfiguration::GetInstance()->GetPluginsFile().c_str());
if (plugins_file.is_open())
{
while (!plugins_file.eof())
{
std::string plugin;
plugins_file >> plugin;
DynamicLibrary *library = new DynamicLibrary();
if (plugin=="")
continue;
library->Load(plugin);
if (library->GetH() != NULL)
{
std::string str1;
library->RegisterPluginMenu(str1);
int id = main_frame->AddPluginMenu(str1);
plugin_map[id] = library;
}
else
if (library)
{
delete library;
library = NULL;
}
}
plugins_file.close();
}
}
示例3: LOG_DEBUG
void PluginManager::loadDynamicPlugins(std::string& plugins_path)
{
LOG_DEBUG("Loading dynamic plugins");
Poco::Path plugin_directory = Poco::Path::forDirectory(plugins_path);
plugin_directory.popDirectory();
plugin_directory.pushDirectory("plugins");
LOG_DEBUG("Plugin directory: " << plugin_directory.toString());
std::set<std::string> dll_files;
Poco::Glob::glob(plugin_directory.append(DynamicLibrary::DL_PREFIX+
"*."+
DynamicLibrary::DL_SUFFIX),
dll_files);
for (std::set<std::string>::iterator it = dll_files.begin();
it!=dll_files.end();
++it)
{
std::string plugin_file = *it;
LOG_DEBUG("Loading library " << plugin_file);
DynamicLibrary* dl = DynamicLibrary::load(plugin_file);
registerPluginFunction registerPlugin =
(registerPluginFunction)dl->getSymbol("registerPlugin");
if (registerPlugin)
{
LOG_DEBUG("Initialize Plugin " << *it);
registerPlugin(this);
} else
{
LOG_WARN("Couldn't find registerPlugin for " << *it);
}
}
}
示例4: 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;
}
示例5: DynamicLibrary
bool Core::LoadModule(const string& cModule)
{
_lDynamicLibrary::iterator it_DynamicLibrary = m_lDynamicLibrary.find(cModule);
if (it_DynamicLibrary == m_lDynamicLibrary.end())
{
DynamicLibrary* pModule = new DynamicLibrary(cModule, mLogger);
if (pModule->CheckWork())
{
START_DLL_MODULE pFunc = (START_DLL_MODULE)pModule->GetAddress("Start_DexDynamicLibrary");
pFunc(this);
m_lDynamicLibrary[cModule] = pModule;
return true;
}
else
{
DrawLine("LoadModule: Ìîäóëü " + cModule + " íå ðàáîòàåò!", MessageTypes::MT_ERROR);
}
}
else
{
DrawLine("LoadModule: Ìîäóëü " + cModule + " óæå çàãðóæåí", MT_WARNING);
}
return false;
}
示例6: TEST
TEST(DynamicLibrary, Unsupported) {
std::string Err;
DynamicLibrary DL =
DynamicLibrary::getPermanentLibrary(LibPath().c_str(), &Err);
EXPECT_FALSE(DL.isValid());
EXPECT_EQ(Err, "dlopen() not supported on this platform");
}
示例7: registerBuiltinCheckers
ClangCheckerRegistry::ClangCheckerRegistry(ArrayRef<std::string> plugins,
DiagnosticsEngine *diags) {
registerBuiltinCheckers(*this);
for (ArrayRef<std::string>::iterator i = plugins.begin(), e = plugins.end();
i != e; ++i) {
// Get access to the plugin.
DynamicLibrary lib = DynamicLibrary::getPermanentLibrary(i->c_str());
// See if it's compatible with this build of clang.
const char *pluginAPIVersion =
(const char *) lib.getAddressOfSymbol("clang_analyzerAPIVersionString");
if (!isCompatibleAPIVersion(pluginAPIVersion)) {
warnIncompatible(diags, *i, pluginAPIVersion);
continue;
}
// Register its checkers.
RegisterCheckersFn registerPluginCheckers =
(RegisterCheckersFn) (intptr_t) lib.getAddressOfSymbol(
"clang_registerCheckers");
if (registerPluginCheckers)
registerPluginCheckers(*this);
}
}
示例8: AProNew
ResourcePtr DynamicLibraryLoader::loadResource(const String& filename)
{
DynamicLibrary* dynlib = AProNew(DynamicLibrary, filename);
if(dynlib->isLoaded())
return ResourcePtr(dynlib);
else
return ResourcePtr();
}
示例9: LLVMRustLoadDynamicLibrary
extern "C" LLVMBool LLVMRustLoadDynamicLibrary(const char *path)
{
std::string err;
DynamicLibrary lib = DynamicLibrary::getPermanentLibrary(path, &err);
if (!lib.isValid())
LLVMRustSetLastError(err.c_str());
return lib.isValid();
}
示例10: loadCrate
bool RustMCJITMemoryManager::loadCrate(const char* file, std::string* err) {
DynamicLibrary crate = DynamicLibrary::getPermanentLibrary(file,
err);
if(crate.isValid()) {
crates.insert(&crate);
return true;
}
return false;
}
示例11: test_desobj
void test_desobj()
{
ErrorOr<ObjectFile *> objfile = ObjectFile::createObjectFile("/usr/lib/libQtCore.so");
ObjectFile *pobj = objfile.get();
qDebug()<<"heheho"<<pobj->getFileFormatName().data();
int i = 0;
DynamicLibrary dlib = DynamicLibrary::getPermanentLibrary("/usr/lib/libQt5Core.so");
qDebug()<<dlib.isValid();
void *addr = dlib.SearchForAddressOfSymbol("_ZN7QString4chopEi");
qDebug()<<"addr:"<<addr;
}
示例12: TEST_BEGIN
} TEST_END
TEST_BEGIN(base, dynamic_library) {
DynamicLibrary dync;
rc_t rc = dync.open(_STR("base_unittest.dll"));
ASSERT_EQ(RC_S_OK, rc);
typedef void (*PFN_TEST_CALL)();
PFN_TEST_CALL pfn_call = dync.LocateSymbol<PFN_TEST_CALL>(_STR("base_dynamic_library_test"));
ASSERT_NE(NULL, pfn_call);
(pfn_call)();
ASSERT_EQ(TRUE, gbCall);
} TEST_END
示例13: showServerControls
void FaceTrackNoIR::showServerControls() {
if (pProtocolDialog) {
delete pProtocolDialog;
pProtocolDialog = NULL;
}
DynamicLibrary* lib = dlopen_protocols.value(ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL);
if (lib && lib->Dialog) {
pProtocolDialog = (IProtocolDialog*) lib->Dialog();
if (pProtocolDialog) {
auto foo = dynamic_cast<QWidget*>(pProtocolDialog);
foo->setFixedSize(foo->size());
dynamic_cast<QWidget*>(pProtocolDialog)->show();
}
}
}
示例14: showFilterControls
void FaceTrackNoIR::showFilterControls() {
if (pFilterDialog) {
delete pFilterDialog;
pFilterDialog = NULL;
}
DynamicLibrary* lib = dlopen_filters.value(ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL);
if (lib && lib->Dialog) {
pFilterDialog = (IFilterDialog*) lib->Dialog();
if (pFilterDialog) {
auto foo = dynamic_cast<QWidget*>(pFilterDialog);
foo->setFixedSize(foo->size());
if (Libraries && Libraries->pFilter)
pFilterDialog->registerFilter(Libraries->pFilter);
dynamic_cast<QWidget*>(pFilterDialog)->show();
}
}
}
示例15: showSecondTrackerSettings
void FaceTrackNoIR::showSecondTrackerSettings() {
if (pSecondTrackerDialog) {
delete pSecondTrackerDialog;
pSecondTrackerDialog = NULL;
}
DynamicLibrary* lib = dlopen_trackers.value(ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL);
if (lib) {
pSecondTrackerDialog = (ITrackerDialog*) lib->Dialog();
if (pSecondTrackerDialog) {
auto foo = dynamic_cast<QWidget*>(pSecondTrackerDialog);
foo->setFixedSize(foo->size());
if (Libraries && Libraries->pSecondTracker)
pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker);
dynamic_cast<QWidget*>(pSecondTrackerDialog)->show();
}
}
}