mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
Add orthogonal OK/ERROR states.
Replace state check mutex with atomic. Update DDS example documentation.
This commit is contained in:
committed by
Mohammad Al-Turany
parent
a7ab33a10e
commit
fbf7dbf2ba
@@ -5,7 +5,6 @@
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
/*
|
||||
* File: FairMQProgOptions.cxx
|
||||
* Author: winckler
|
||||
@@ -16,26 +15,28 @@
|
||||
#include "FairMQProgOptions.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQProgOptions::FairMQProgOptions()
|
||||
: FairProgOptions()
|
||||
, fMQParserOptions("MQ-Device parser options")
|
||||
, fMQOptionsInCmd("MQ-Device options")
|
||||
, fMQOptionsInCfg("MQ-Device options")
|
||||
, fMQtree()
|
||||
, fFairMQmap()
|
||||
, fFairMQMap()
|
||||
{
|
||||
}
|
||||
|
||||
FairMQProgOptions::~FairMQProgOptions()
|
||||
FairMQProgOptions::~FairMQProgOptions()
|
||||
{
|
||||
}
|
||||
|
||||
int FairMQProgOptions::ParseAll(const int argc, char** argv, bool AllowUnregistered)
|
||||
{
|
||||
int FairMQProgOptions::ParseAll(const int argc, char** argv, bool allowUnregistered)
|
||||
{
|
||||
// init description
|
||||
InitOptionDescription();
|
||||
// parse command line options
|
||||
if (ParseCmdLine(argc,argv,fCmdline_options,fvarmap,AllowUnregistered))
|
||||
if (ParseCmdLine(argc, argv, fCmdLineOptions, fVarMap, allowUnregistered))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -46,20 +47,22 @@ int FairMQProgOptions::ParseAll(const int argc, char** argv, bool AllowUnregiste
|
||||
// check if file exist
|
||||
if (fs::exists(fConfigFile))
|
||||
{
|
||||
if (ParseCfgFile(fConfigFile.string(), fConfig_file_options, fvarmap, AllowUnregistered))
|
||||
if (ParseCfgFile(fConfigFile.string(), fConfigFileOptions, fVarMap, allowUnregistered))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(ERROR)<<"config file '"<< fConfigFile <<"' not found";
|
||||
LOG(ERROR) << "config file '" << fConfigFile << "' not found";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// set log level before printing (default is 0 = DEBUG level)
|
||||
std::string verbose=GetValue<std::string>("verbose");
|
||||
//SET_LOG_LEVEL(DEBUG);
|
||||
if(fSeverity_map.count(verbose))
|
||||
if (fSeverity_map.count(verbose))
|
||||
{
|
||||
set_global_log_level(log_op::operation::GREATER_EQ_THAN,fSeverity_map.at(verbose));
|
||||
}
|
||||
@@ -70,44 +73,44 @@ int FairMQProgOptions::ParseAll(const int argc, char** argv, bool AllowUnregiste
|
||||
}
|
||||
|
||||
PrintOptions();
|
||||
|
||||
|
||||
// check if one of required MQ config option is there
|
||||
auto parserOption_shptr = fMQParserOptions.options();
|
||||
bool option_exists=false;
|
||||
std::vector<std::string> MQParserKeys;
|
||||
for(const auto& p : parserOption_shptr)
|
||||
bool optionExists = false;
|
||||
vector<string> MQParserKeys;
|
||||
for (const auto& p : parserOption_shptr)
|
||||
{
|
||||
MQParserKeys.push_back( p->canonical_display_name() );
|
||||
if( fvarmap.count( p->canonical_display_name() ) )
|
||||
MQParserKeys.push_back(p->canonical_display_name());
|
||||
if (fVarMap.count(p->canonical_display_name()))
|
||||
{
|
||||
option_exists=true;
|
||||
optionExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!option_exists)
|
||||
|
||||
if (!optionExists)
|
||||
{
|
||||
LOG(ERROR)<<"Required option to configure the MQ device is not there.";
|
||||
LOG(ERROR)<<"Please provide the value of one of the following key:";
|
||||
for(const auto& p : MQParserKeys)
|
||||
LOG(ERROR) << "Required option to configure the MQ device is not there.";
|
||||
LOG(ERROR) << "Please provide the value of one of the following key:";
|
||||
for (const auto& p : MQParserKeys)
|
||||
{
|
||||
LOG(ERROR)<<p;
|
||||
LOG(ERROR) << p;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FairMQProgOptions::NotifySwitchOption()
|
||||
{
|
||||
if ( fvarmap.count("help") )
|
||||
if (fVarMap.count("help"))
|
||||
{
|
||||
LOG(INFO) << "***** FAIRMQ Program Options ***** \n" << fVisible_options;
|
||||
LOG(INFO) << "***** FAIRMQ Program Options ***** \n" << fVisibleOptions;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fvarmap.count("version"))
|
||||
if (fVarMap.count("version"))
|
||||
{
|
||||
LOG(INFO) << "Beta version 0.1\n";
|
||||
return 1;
|
||||
@@ -116,42 +119,39 @@ int FairMQProgOptions::NotifySwitchOption()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void FairMQProgOptions::InitOptionDescription()
|
||||
{
|
||||
// Id required in command line if config txt file not enabled
|
||||
if (fUseConfigFile)
|
||||
{
|
||||
fMQOptionsInCmd.add_options()
|
||||
("id", po::value< std::string >(), "Device ID (required argument)")
|
||||
("io-threads", po::value<int>()->default_value(1), "io threads number");
|
||||
|
||||
("id", po::value<string>(), "Device ID (required argument).")
|
||||
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads.");
|
||||
|
||||
fMQOptionsInCfg.add_options()
|
||||
("id", po::value< std::string >()->required(), "Device ID (required argument)")
|
||||
("io-threads", po::value<int>()->default_value(1), "io threads number");
|
||||
("id", po::value<string>()->required(), "Device ID (required argument).")
|
||||
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads.");
|
||||
}
|
||||
else
|
||||
{
|
||||
fMQOptionsInCmd.add_options()
|
||||
("id", po::value< std::string >()->required(), "Device ID (required argument)")
|
||||
("io-threads", po::value<int>()->default_value(1), "io threads number");
|
||||
("id", po::value<string>()->required(), "Device ID (required argument)")
|
||||
("io-threads", po::value<int>()->default_value(1), "Number of I/O threads");
|
||||
}
|
||||
|
||||
|
||||
fMQParserOptions.add_options()
|
||||
("config-xml-string", po::value< std::vector<std::string> >()->multitoken(), "XML input as command line string.")
|
||||
("config-xml-file", po::value< std::string >(), "XML input as file.")
|
||||
("config-json-string", po::value< std::vector<std::string> >()->multitoken(), "JSON input as command line string.")
|
||||
("config-json-file", po::value< std::string >(), "JSON input as file.");
|
||||
|
||||
|
||||
("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.");
|
||||
|
||||
AddToCmdLineOptions(fGenericDesc);
|
||||
AddToCmdLineOptions(fMQOptionsInCmd);
|
||||
AddToCmdLineOptions(fMQParserOptions);
|
||||
|
||||
|
||||
if (fUseConfigFile)
|
||||
{
|
||||
AddToCfgFileOptions(fMQOptionsInCfg,false);
|
||||
AddToCfgFileOptions(fMQParserOptions,false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user