mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
add CountProperty() to plugin APIs, throw is GetProperty doesn't find key
This commit is contained in:
committed by
Mohammad Al-Turany
parent
243352d717
commit
95112dac02
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairProgOptionsHelper.h"
|
||||
#include <fairmq/Tools.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -26,6 +27,7 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <exception>
|
||||
|
||||
namespace po = boost::program_options;
|
||||
namespace fs = boost::filesystem;
|
||||
@@ -61,21 +63,14 @@ class FairProgOptions
|
||||
std::unique_lock<std::mutex> lock(fConfigMutex);
|
||||
|
||||
T val = T();
|
||||
try
|
||||
|
||||
if (fVarMap.count(key))
|
||||
{
|
||||
if (fVarMap.count(key))
|
||||
{
|
||||
val = fVarMap[key].as<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(error) << "Config has no key: " << key;
|
||||
}
|
||||
val = fVarMap[key].as<T>();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
else
|
||||
{
|
||||
LOG(error) << "Exception thrown for the key '" << key << "'";
|
||||
LOG(error) << e.what();
|
||||
LOG(warn) << "Config has no key: " << key << ". Returning default constructed object.";
|
||||
}
|
||||
|
||||
return val;
|
||||
|
Reference in New Issue
Block a user