本文整理汇总了C++中ModuleManager::run方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleManager::run方法的具体用法?C++ ModuleManager::run怎么用?C++ ModuleManager::run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleManager
的用法示例。
在下文中一共展示了ModuleManager::run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// argument is a configFile
int main(int argc, char** argv){
// Declare a group of options that will be allowed only on command line
po::options_description generic("Generic options");
generic.add_options()
("version,v", "print version string")
("help,h", "produce help message")
;
po::options_description config("Program options");
config.add_options()
("configuration,c", po::value< string >(), "defines the path to an already created and stored chain configuration, written in yaml")
("input,i", po::value< vector<string> >()->composing(), "defines an input, can be used multiple times format: inputName:fileName inputName is optional if there is only one input")
("output,o", po::value< vector<string> >()->composing(), "defines an output, can be used multiple times, format: outputName:fileName. outputName is optional, if there is only one input. Output is optional, if there is only one input and one output, the output filename will be chosen from the input name in this case.")
("param,p", po::value< vector<string> >()->composing(), "defines a parameter, format: name:value")
;
// Hidden options, will be allowed command line, but will not be shown to the user.
po::options_description hidden("Hidden options");
hidden.add_options()
("modulename,m", po::value< string>(), "defines the name of the module")
;
// These two lines say that all positional options should be translated into "-modulename" options.
po::positional_options_description p;
p.add("modulename", -1);
// Declare an options description instance which will include all the options
po::options_description allOptions("Allowed options");
allOptions.add(generic).add(config).add(hidden);
// Declare an options description instance which will be shown to the user
po::options_description visibleOptions("Allowed options");
visibleOptions.add(generic).add(config);
// process input parameters and store the result in vm
po::variables_map vm;
store(po::command_line_parser(argc, argv).options(allOptions).positional(p).run(), vm);
po::notify(vm);
if (argc < 2) {
std::cerr << "Usage Error!\n\n";
cout << "Usage:" << endl;
cout << argv[0] << " -c <path to configuration file> run a processing chain from a config file." << endl;
cout << argv[0] << " <moduleName> -i <input> [-p <params> -o <output>] run a single module." << endl;
cout << "\n";
// show help
cout << visibleOptions;
return 1;
}
// used by the module manager to access Qt components, TODO maybe move to module manager?
QApplication app (argc,argv);
ModuleManager mm;
Configuration conf;
if (vm.count("configuration")){
// run a processing chain from a config file.
// ./uipf -c example.yam
// loads the configFile and create a Configuration
string configFileName = argv[2];
conf.load(configFileName);
} else{
// run a single module.
// ./uipf <moduleName> ...options...
if (vm.count("version")) {
cout << "Version: 1.0" << "\n";
return 0;
}
if (vm.count("help")) {
cout << "Usage:" << endl;
cout << argv[0] << " -c <path to configuration file> run a processing chain from a config file." << endl;
cout << argv[0] << " <moduleName> -i <input> [-p <params> -o <output>] run a single module." << endl;
cout << "\n";
cout << visibleOptions;
return 0;
}
if (!vm.count("modulename") || !vm.count("input")){
std::cerr << "Usage Error!\n\n";
cout << "Usage:" << endl;
cout << argv[0] << " -c <path to configuration file> run a processing chain from a config file." << endl;
cout << argv[0] << " <moduleName> -i <input> [-p <params> -o <output>] run a single module." << endl;
cout << "\n";
// show help
cout << visibleOptions;
return 1;
}
string modName = vm["modulename"].as<string>();
if (!mm.hasModule(modName)) {
//.........这里部分代码省略.........