本文整理汇总了C++中Plugin::create方法的典型用法代码示例。如果您正苦于以下问题:C++ Plugin::create方法的具体用法?C++ Plugin::create怎么用?C++ Plugin::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_base
int init_base(int &argc, char *argv[], Context *context = 0) {
if (argc < 4) { // invalid number of arguments
return EXIT_FAILURE;
}
// obtain real argc for this plugin and pargv, pargc for _base plugin
int i = 0;
for (; i < argc and strcmp(argv[i], "--") != 0; i++);
char **pargv = argv + i + 1;
int pargc = argc - i - 1;
argc = i;
string plugin_fn = pargv[0];
string plugin_fn_name = pargv[1];
ostringstream plugin_args;
copy(pargv + 2, pargv + pargc, ostream_iterator<char *>(plugin_args, " "));
// for (int i = 0; i < pargc; i++) plugin_args;
_plugin = new Plugin<IInteractiveMtFactory>(plugin_fn, plugin_args.str(), plugin_fn_name);
if (_plugin == 0) {
cerr << "Could not create base plugin '" << plugin_fn << "'\n";
return EXIT_FAILURE;
}
_base = _plugin->create(context);
if (_base == 0) {
cerr << "Could not create base factory for '" << plugin_fn << "'\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
示例2:
TEST(PluginFactory, loadPlugins)
{
PluginFactory* factory = PluginFactory::getInstance();
EXPECT_NO_THROW(factory->loadPluginsFromFile("./libsampleplugin.so"));
std::vector<std::string> loadedModules=factory->getRegisteredPluginNames();
EXPECT_EQ(loadedModules.size(),(unsigned int)2);
EXPECT_EQ(factory->hasPlugin("TestModule"),true);
EXPECT_EQ(factory->hasPlugin("TestAlgorithm"),true);
EXPECT_THROW(factory->getPlugin<Algorithm>("TestModule"),std::string);
Plugin<Module>* modulePlugin = factory->getPlugin<Module>("TestModule");
Module* testModule = modulePlugin->create(Configuration::createEmptyDict());
EXPECT_EQ(testModule->getOutputSize(),(unsigned int)1);
EXPECT_EQ(testModule->getOutput(0)->getName(),"out");
Plugin<Algorithm>* algorithmPlugin = factory->getPlugin<Algorithm>("TestAlgorithm");
Algorithm* testAlgorithm = algorithmPlugin->create(Configuration::createEmptyDict());
Graph g;
testAlgorithm->setGraph(g);
testAlgorithm->execute();
}