mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
encapsulate and use fairmq default xml and json parser if command line mq-config file.extension is called. The .xml and .json files are recognized internally. Remove explicit json parsing in runSimpleMQStateMAchine.h. Propagate the new commandline mq-config where the runstatemachine function is used
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "FairMQProgOptions.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "FairMQParser.h"
|
||||
using namespace std;
|
||||
|
||||
FairMQProgOptions::FairMQProgOptions()
|
||||
@@ -24,6 +24,8 @@ FairMQProgOptions::FairMQProgOptions()
|
||||
, fMQOptionsInCmd("MQ-Device options")
|
||||
, fMQtree()
|
||||
, fFairMQMap()
|
||||
, fHelpTitle("***** FAIRMQ Program Options ***** ")
|
||||
, fVersion("Beta version 0.1")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -104,6 +106,32 @@ int FairMQProgOptions::ParseAll(const int argc, char** argv, bool allowUnregiste
|
||||
LOG(WARN) << "No channels will be created (You can create them manually).";
|
||||
// return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fVarMap.count("mq-config"))
|
||||
{
|
||||
LOG(DEBUG)<<"mq-config command line called : default xml/json parser will be used";
|
||||
std::string file = fVarMap["mq-config"].as<std::string>();
|
||||
std::string id = fVarMap["id"].as<std::string>();
|
||||
|
||||
std::string file_extension = boost::filesystem::extension(file);
|
||||
|
||||
std::transform(file_extension.begin(), file_extension.end(), file_extension.begin(), ::tolower);
|
||||
|
||||
if(file_extension==".json")
|
||||
UserParser<FairMQParser::JSON>(file, id);
|
||||
else
|
||||
if(file_extension==".xml")
|
||||
UserParser<FairMQParser::XML>(file, id);
|
||||
else
|
||||
{
|
||||
LOG(ERROR) <<"mq-config command line called but file extension '"
|
||||
<<file_extension
|
||||
<< "' not recognized. Program will now exit";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -112,13 +140,13 @@ int FairMQProgOptions::NotifySwitchOption()
|
||||
{
|
||||
if (fVarMap.count("help"))
|
||||
{
|
||||
LOG(INFO) << "***** FAIRMQ Program Options ***** \n" << fVisibleOptions;
|
||||
LOG(INFO) << fHelpTitle << "\n" << fVisibleOptions;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fVarMap.count("version"))
|
||||
{
|
||||
LOG(INFO) << "Beta version 0.1\n";
|
||||
LOG(INFO) << fVersion << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -152,7 +180,9 @@ void FairMQProgOptions::InitOptionDescription()
|
||||
("config-xml-string", po::value<vector<string>>()->multitoken(), "XML input as command line string.")
|
||||
("config-xml-file", po::value<string>(), "XML input as file.")
|
||||
("config-json-string", po::value<vector<string>>()->multitoken(), "JSON input as command line string.")
|
||||
("config-json-file", po::value<string>(), "JSON input as file.");
|
||||
("config-json-file", po::value<string>(), "JSON input as file.")
|
||||
("mq-config", po::value<string>(), "JSON/XML input as file. The configuration object will check xml or json file extention and will call the json or xml parser accordingly")
|
||||
;
|
||||
|
||||
AddToCmdLineOptions(fGenericDesc);
|
||||
AddToCmdLineOptions(fMQOptionsInCmd);
|
||||
|
Reference in New Issue
Block a user