mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
add a signal/slot mechanism. 2 APIs : one generic version, and one string API (commented)
This commit is contained in:
committed by
Mohammad Al-Turany
parent
5e5ddd5b7b
commit
9ceab6099c
@@ -68,6 +68,9 @@ class FairProgOptions
|
||||
int AddToCmdLineOptions(const po::options_description& optDesc, bool visible = true);
|
||||
int AddToCfgFileOptions(const po::options_description& optDesc, bool visible = true);
|
||||
int AddToEnvironmentOptions(const po::options_description& optDesc);
|
||||
po::options_description& GetCmdLineOptions();
|
||||
po::options_description& GetCfgFileOptions();
|
||||
po::options_description& GetEnvironmentOptions();
|
||||
|
||||
void UseConfigFile(const std::string& filename = "");
|
||||
|
||||
@@ -96,6 +99,23 @@ class FairProgOptions
|
||||
// convert value to string that corresponds to the key
|
||||
std::string GetStringValue(const std::string& key);
|
||||
|
||||
//restrict conversion to fundamental types
|
||||
template<typename T>
|
||||
T ConvertTo(const std::string& str_value)
|
||||
{
|
||||
if (std::is_arithmetic<T>::value)
|
||||
{
|
||||
std::istringstream iss( str_value );
|
||||
T val;
|
||||
iss >> val;
|
||||
return val;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(ERROR)<<"the provided string "<<str_value << " cannot be converted in the requested type. The target types must be arithmetic types";
|
||||
}
|
||||
}
|
||||
|
||||
const po::variables_map& GetVarMap() const { return fVarMap; }
|
||||
|
||||
// boost prog options parsers
|
||||
|
Reference in New Issue
Block a user