mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
- Remove singular key names from JSON schema. - Align the property tree created by `FairMQSuboptParser` with the format required by the main parser (plural names). - Fix `--print-options` to print all options (not only those that have their value set). - remove XML parser (outdated and unused). - various code cleanup.
70 lines
2.3 KiB
C++
70 lines
2.3 KiB
C++
/// std
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
/// boost
|
|
#include "boost/program_options.hpp"
|
|
|
|
/// FairRoot/FairMQ
|
|
#include "FairMQLogger.h"
|
|
#include "FairMQParser.h"
|
|
#include "FairMQProgOptions.h"
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
/// main
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
try
|
|
{
|
|
FairMQProgOptions config;
|
|
|
|
po::options_description format_desc("XML input");
|
|
format_desc.add_options()
|
|
("xml.config.node.root", po::value<std::string>()->default_value("fairMQOptions"), "xml root node ")
|
|
;
|
|
|
|
po::options_description io_file_opt_desc("I/O file Options");
|
|
io_file_opt_desc.add_options()
|
|
("input.file.name", po::value<std::string>(), "input file name")
|
|
("input.file.tree", po::value<std::string>(), "input tree name")
|
|
("input.file.branch", po::value<std::string>(), "input branch name")
|
|
("output.file.name", po::value<std::string>(), "output file name")
|
|
("output.file.tree", po::value<std::string>(), "output tree name")
|
|
("output.file.branch", po::value<std::string>(), "output branch name")
|
|
;
|
|
|
|
config.AddToCmdLineOptions(format_desc);
|
|
config.AddToCmdLineOptions(io_file_opt_desc);
|
|
|
|
config.EnableCfgFile();// UseConfigFile (by default config file is not defined)
|
|
config.AddToCfgFileOptions(format_desc,false);//false because already added to visible
|
|
config.AddToCfgFileOptions(io_file_opt_desc,false);
|
|
|
|
// Parse command line and config file
|
|
if(config.ParseAll(argc,argv))
|
|
return 0;
|
|
|
|
// Set severity level (Default is 0=DEBUG)
|
|
int severity = config.GetValue<int>("severity");
|
|
FairMQLogger::Level lvl = static_cast<FairMQLogger::Level>(severity);
|
|
SET_LOGGER_LEVEL(lvl);
|
|
|
|
// parse XML file
|
|
std::string filename;
|
|
std::string XMLrootNode;
|
|
|
|
filename=config.GetValue<std::string>("config-xml-file");
|
|
XMLrootNode=config.GetValue<std::string>("xml.config.node.root");
|
|
std::string id=config.GetValue<std::string>("id");
|
|
config.UserParser<FairMQParser::XML>(filename,id,XMLrootNode);
|
|
}
|
|
catch (std::exception& e)
|
|
{
|
|
LOG(error) << e.what();
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|