本文整理汇总了C++中Plugin::createUtility方法的典型用法代码示例。如果您正苦于以下问题:C++ Plugin::createUtility方法的具体用法?C++ Plugin::createUtility怎么用?C++ Plugin::createUtility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::createUtility方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mtsutil
//.........这里部分代码省略.........
if (testCaseMode) {
std::vector<fs::path> dirPaths = fileResolver->resolveAll("plugins");
std::set<std::string> seen;
int executed = 0, succeeded = 0;
for (size_t i=0; i<dirPaths.size(); ++i) {
fs::path dirPath = fs::complete(dirPaths[i]);
if (!fs::exists(dirPath) || !fs::is_directory(dirPath))
break;
fs::directory_iterator end, it(dirPath);
for (; it != end; ++it) {
if (!fs::is_regular_file(it->status()))
continue;
std::string extension(boost::to_lower_copy(it->path().extension()));
#if defined(WIN32)
if (extension != ".dll")
continue;
#elif defined(__OSX__)
if (extension != ".dylib")
continue;
#elif defined(__LINUX__)
if (extension != ".so")
continue;
#else
#error Unknown operating system!
#endif
std::string shortName = it->path().stem();
if (seen.find(shortName) != seen.end() || !boost::starts_with(shortName, "test_"))
continue;
seen.insert(shortName);
Plugin plugin(shortName, it->path());
if (!plugin.isUtility())
continue;
ref<Utility> utility = plugin.createUtility();
TestCase *testCase = static_cast<TestCase *>(utility.get());
if (!utility->getClass()->derivesFrom(MTS_CLASS(TestCase)))
SLog(EError, "This is not a test case!");
if (testCase->run(argc-optind, argv+optind) != 0)
SLog(EError, "Testcase unexpectedly returned with a nonzero value.");
executed += testCase->getExecuted();
succeeded += testCase->getSucceeded();
}
}
SLog(EInfo, "Ran %i tests, %i succeeded, %i failed.", executed, succeeded, executed-succeeded);
} else {
if (argc <= optind) {
std::cerr << "A utility name must be supplied!" << endl;
return -1;
}
fs::path pluginName(argv[optind]);
/* Build the full plugin file name */
#if defined(WIN32)
pluginName.replace_extension(".dll");
#elif defined(__OSX__)
pluginName.replace_extension(".dylib");
#elif defined(__LINUX__)
pluginName.replace_extension(".so");
#else
#error Unknown operating system!
#endif
fs::path fullName = fileResolver->resolve(fs::path("plugins") / pluginName);
if (!fs::exists(fullName)) {
/* Plugin not found! */
SLog(EError, "Utility \"%s\" not found (run \"mtsutil\" without arguments to "
"see a list of available utilities)", fullName.file_string().c_str());
}
SLog(EInfo, "Loading utility \"%s\" ..", argv[optind]);
Plugin *plugin = new Plugin(argv[optind], fullName);
if (!plugin->isUtility())
SLog(EError, "This plugin does not implement the 'Utility' interface!");
Statistics::getInstance()->logPlugin(argv[optind], plugin->getDescription());
ref<Utility> utility = plugin->createUtility();
int retval = utility->run(argc-optind, argv+optind);
scheduler->pause();
utility = NULL;
delete plugin;
return retval;
}
} catch (const std::exception &e) {
std::cerr << "Caught a critical exeption: " << e.what() << std::endl;
} catch (...) {
std::cerr << "Caught a critical exeption of unknown type!" << endl;
}
return 0;
}