mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Remove unused methods from FairMQProgOptions
This commit is contained in:
parent
3538d9f410
commit
f46803a8b6
|
@ -432,6 +432,13 @@ try {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate channel name
|
||||||
|
if (fName.find(".") != string::npos) {
|
||||||
|
ss << "INVALID";
|
||||||
|
LOG(error) << "channel name must not contain '.'";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// validate socket type
|
// validate socket type
|
||||||
const set<string> socketTypes{ "sub", "pub", "pull", "push", "req", "rep", "xsub", "xpub", "dealer", "router", "pair" };
|
const set<string> socketTypes{ "sub", "pub", "pull", "push", "req", "rep", "xsub", "xpub", "dealer", "router", "pair" };
|
||||||
if (socketTypes.find(fType) == socketTypes.end()) {
|
if (socketTypes.find(fType) == socketTypes.end()) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ FairMQProgOptions::FairMQProgOptions()
|
||||||
, fGeneralOptions("General options")
|
, fGeneralOptions("General options")
|
||||||
, fMQOptions("FairMQ device options")
|
, fMQOptions("FairMQ device options")
|
||||||
, fParserOptions("FairMQ channel config parser options")
|
, fParserOptions("FairMQ channel config parser options")
|
||||||
, fConfigMutex()
|
, fMtx()
|
||||||
, fChannelInfo()
|
, fChannelInfo()
|
||||||
, fChannelKeyMap()
|
, fChannelKeyMap()
|
||||||
, fUnregisteredOptions()
|
, fUnregisteredOptions()
|
||||||
|
@ -89,8 +89,7 @@ int FairMQProgOptions::ParseAll(const vector<string>& cmdLineArgs, bool allowUnr
|
||||||
{
|
{
|
||||||
vector<const char*> argv(cmdLineArgs.size());
|
vector<const char*> argv(cmdLineArgs.size());
|
||||||
|
|
||||||
transform(cmdLineArgs.begin(), cmdLineArgs.end(), argv.begin(), [](const string& str)
|
transform(cmdLineArgs.begin(), cmdLineArgs.end(), argv.begin(), [](const string& str) {
|
||||||
{
|
|
||||||
return str.c_str();
|
return str.c_str();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -102,20 +101,17 @@ int FairMQProgOptions::ParseAll(const int argc, char const* const* argv, bool al
|
||||||
ParseCmdLine(argc, argv, allowUnregistered);
|
ParseCmdLine(argc, argv, allowUnregistered);
|
||||||
|
|
||||||
// if this option is provided, handle them and return stop value
|
// if this option is provided, handle them and return stop value
|
||||||
if (fVarMap.count("help"))
|
if (fVarMap.count("help")) {
|
||||||
{
|
|
||||||
cout << fAllOptions << endl;
|
cout << fAllOptions << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// if this option is provided, handle them and return stop value
|
// if this option is provided, handle them and return stop value
|
||||||
if (fVarMap.count("print-options"))
|
if (fVarMap.count("print-options")) {
|
||||||
{
|
|
||||||
PrintOptionsRaw();
|
PrintOptionsRaw();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// if these options are provided, do no further checks and let the device handle them
|
// if these options are provided, do no further checks and let the device handle them
|
||||||
if (fVarMap.count("print-channels") || fVarMap.count("version"))
|
if (fVarMap.count("print-channels") || fVarMap.count("version")) {
|
||||||
{
|
|
||||||
fair::Logger::SetConsoleSeverity("nolog");
|
fair::Logger::SetConsoleSeverity("nolog");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -127,13 +123,10 @@ int FairMQProgOptions::ParseAll(const int argc, char const* const* argv, bool al
|
||||||
string verbosity = GetValue<string>("verbosity");
|
string verbosity = GetValue<string>("verbosity");
|
||||||
fair::Logger::SetVerbosity(verbosity);
|
fair::Logger::SetVerbosity(verbosity);
|
||||||
|
|
||||||
if (logFile != "")
|
if (logFile != "") {
|
||||||
{
|
|
||||||
fair::Logger::InitFileSink(severity, logFile);
|
fair::Logger::InitFileSink(severity, logFile);
|
||||||
fair::Logger::SetConsoleSeverity("nolog");
|
fair::Logger::SetConsoleSeverity("nolog");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
fair::Logger::SetConsoleColor(color);
|
fair::Logger::SetConsoleColor(color);
|
||||||
fair::Logger::SetConsoleSeverity(severity);
|
fair::Logger::SetConsoleSeverity(severity);
|
||||||
}
|
}
|
||||||
|
@ -141,39 +134,27 @@ int FairMQProgOptions::ParseAll(const int argc, char const* const* argv, bool al
|
||||||
string idForParser;
|
string idForParser;
|
||||||
|
|
||||||
// check if config-key for config parser is provided
|
// check if config-key for config parser is provided
|
||||||
if (fVarMap.count("config-key"))
|
if (fVarMap.count("config-key")) {
|
||||||
{
|
|
||||||
idForParser = fVarMap["config-key"].as<string>();
|
idForParser = fVarMap["config-key"].as<string>();
|
||||||
}
|
} else if (fVarMap.count("id")) {
|
||||||
else if (fVarMap.count("id"))
|
|
||||||
{
|
|
||||||
idForParser = fVarMap["id"].as<string>();
|
idForParser = fVarMap["id"].as<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if any config parser is selected
|
// check if any config parser is selected
|
||||||
try
|
try {
|
||||||
{
|
if (fVarMap.count("mq-config")) {
|
||||||
if (fVarMap.count("mq-config"))
|
|
||||||
{
|
|
||||||
LOG(debug) << "mq-config: Using default JSON parser";
|
LOG(debug) << "mq-config: Using default JSON parser";
|
||||||
UpdateChannelMap(parser::JSON().UserParser(fVarMap.at("mq-config").as<string>(), idForParser));
|
UpdateChannelMap(parser::JSON().UserParser(fVarMap.at("mq-config").as<string>(), idForParser));
|
||||||
}
|
} else if (fVarMap.count("channel-config")) {
|
||||||
else if (fVarMap.count("channel-config"))
|
|
||||||
{
|
|
||||||
LOG(debug) << "channel-config: Parsing channel configuration";
|
LOG(debug) << "channel-config: Parsing channel configuration";
|
||||||
ParseChannelsFromCmdLine();
|
ParseChannelsFromCmdLine();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(warn) << "FairMQProgOptions: no channels configuration provided via neither of:";
|
LOG(warn) << "FairMQProgOptions: no channels configuration provided via neither of:";
|
||||||
for (const auto& p : fParserOptions.options())
|
for (const auto& p : fParserOptions.options()) {
|
||||||
{
|
|
||||||
LOG(warn) << "--" << p->canonical_display_name();
|
LOG(warn) << "--" << p->canonical_display_name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (exception& e) {
|
||||||
catch (exception& e)
|
|
||||||
{
|
|
||||||
LOG(error) << e.what();
|
LOG(error) << e.what();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -188,12 +169,9 @@ void FairMQProgOptions::ParseChannelsFromCmdLine()
|
||||||
string idForParser;
|
string idForParser;
|
||||||
|
|
||||||
// check if config-key for config parser is provided
|
// check if config-key for config parser is provided
|
||||||
if (fVarMap.count("config-key"))
|
if (fVarMap.count("config-key")) {
|
||||||
{
|
|
||||||
idForParser = fVarMap["config-key"].as<string>();
|
idForParser = fVarMap["config-key"].as<string>();
|
||||||
}
|
} else if (fVarMap.count("id")) {
|
||||||
else if (fVarMap.count("id"))
|
|
||||||
{
|
|
||||||
idForParser = fVarMap["id"].as<string>();
|
idForParser = fVarMap["id"].as<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,17 +184,14 @@ void FairMQProgOptions::ParseCmdLine(const int argc, char const* const* argv, bo
|
||||||
|
|
||||||
// get options from cmd line and store in variable map
|
// get options from cmd line and store in variable map
|
||||||
// here we use command_line_parser instead of parse_command_line, to allow unregistered and positional options
|
// here we use command_line_parser instead of parse_command_line, to allow unregistered and positional options
|
||||||
if (allowUnregistered)
|
if (allowUnregistered) {
|
||||||
{
|
|
||||||
po::command_line_parser parser{argc, argv};
|
po::command_line_parser parser{argc, argv};
|
||||||
parser.options(fAllOptions).allow_unregistered();
|
parser.options(fAllOptions).allow_unregistered();
|
||||||
po::parsed_options parsed = parser.run();
|
po::parsed_options parsed = parser.run();
|
||||||
fUnregisteredOptions = po::collect_unrecognized(parsed.options, po::include_positional);
|
fUnregisteredOptions = po::collect_unrecognized(parsed.options, po::include_positional);
|
||||||
|
|
||||||
po::store(parsed, fVarMap);
|
po::store(parsed, fVarMap);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
po::store(po::parse_command_line(argc, argv, fAllOptions), fVarMap);
|
po::store(po::parse_command_line(argc, argv, fAllOptions), fVarMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,8 +204,7 @@ void FairMQProgOptions::ParseDefaults()
|
||||||
|
|
||||||
vector<const char*> argv(emptyArgs.size());
|
vector<const char*> argv(emptyArgs.size());
|
||||||
|
|
||||||
transform(emptyArgs.begin(), emptyArgs.end(), argv.begin(), [](const string& str)
|
transform(emptyArgs.begin(), emptyArgs.end(), argv.begin(), [](const string& str) {
|
||||||
{
|
|
||||||
return str.c_str();
|
return str.c_str();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -259,8 +233,7 @@ int FairMQProgOptions::UpdateChannelMap(const unordered_map<string, vector<FairM
|
||||||
void FairMQProgOptions::UpdateChannelInfo()
|
void FairMQProgOptions::UpdateChannelInfo()
|
||||||
{
|
{
|
||||||
fChannelInfo.clear();
|
fChannelInfo.clear();
|
||||||
for (const auto& c : fFairMQChannelMap)
|
for (const auto& c : fFairMQChannelMap) {
|
||||||
{
|
|
||||||
fChannelInfo.insert(make_pair(c.first, c.second.size()));
|
fChannelInfo.insert(make_pair(c.first, c.second.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,12 +352,11 @@ int FairMQProgOptions::UpdateChannelValue(const string& channelName, int index,
|
||||||
|
|
||||||
vector<string> FairMQProgOptions::GetPropertyKeys() const
|
vector<string> FairMQProgOptions::GetPropertyKeys() const
|
||||||
{
|
{
|
||||||
lock_guard<mutex> lock{fConfigMutex};
|
lock_guard<mutex> lock(fMtx);
|
||||||
|
|
||||||
vector<string> result;
|
vector<string> result;
|
||||||
|
|
||||||
for (const auto& it : fVarMap)
|
for (const auto& it : fVarMap) {
|
||||||
{
|
|
||||||
result.push_back(it.first.c_str());
|
result.push_back(it.first.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,8 +390,7 @@ int FairMQProgOptions::PrintOptions()
|
||||||
int maxLenType = 0;
|
int maxLenType = 0;
|
||||||
int maxLenDefault = 0;
|
int maxLenDefault = 0;
|
||||||
|
|
||||||
for (const auto& m : fVarMap)
|
for (const auto& m : fVarMap) {
|
||||||
{
|
|
||||||
maxLenKey = max(maxLenKey, static_cast<int>(m.first.length()));
|
maxLenKey = max(maxLenKey, static_cast<int>(m.first.length()));
|
||||||
|
|
||||||
VarValInfo valinfo = ConvertVariableValue<options::ToVarValInfo>()((m.second));
|
VarValInfo valinfo = ConvertVariableValue<options::ToVarValInfo>()((m.second));
|
||||||
|
@ -431,21 +402,18 @@ int FairMQProgOptions::PrintOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : limit the value len field in a better way
|
// TODO : limit the value len field in a better way
|
||||||
if (maxLenValue > 100)
|
if (maxLenValue > 100) {
|
||||||
{
|
|
||||||
maxLenValue = 100;
|
maxLenValue = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& o : fUnregisteredOptions)
|
for (const auto& o : fUnregisteredOptions) {
|
||||||
{
|
|
||||||
LOG(debug) << "detected unregistered option: " << o;
|
LOG(debug) << "detected unregistered option: " << o;
|
||||||
}
|
}
|
||||||
|
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << "Configuration: \n";
|
ss << "Configuration: \n";
|
||||||
|
|
||||||
for (const auto& p : mapinfo)
|
for (const auto& p : mapinfo) {
|
||||||
{
|
|
||||||
ss << setfill(' ') << left
|
ss << setfill(' ') << left
|
||||||
<< setw(maxLenKey) << p.first << " = "
|
<< setw(maxLenKey) << p.first << " = "
|
||||||
<< setw(maxLenValue) << p.second.value << " "
|
<< setw(maxLenValue) << p.second.value << " "
|
||||||
|
@ -463,11 +431,9 @@ int FairMQProgOptions::PrintOptionsRaw()
|
||||||
{
|
{
|
||||||
const vector<boost::shared_ptr<po::option_description>>& options = fAllOptions.options();
|
const vector<boost::shared_ptr<po::option_description>>& options = fAllOptions.options();
|
||||||
|
|
||||||
for (const auto& o : options)
|
for (const auto& o : options) {
|
||||||
{
|
|
||||||
VarValInfo value;
|
VarValInfo value;
|
||||||
if (fVarMap.count(o->canonical_display_name()))
|
if (fVarMap.count(o->canonical_display_name())) {
|
||||||
{
|
|
||||||
value = ConvertVariableValue<options::ToVarValInfo>()((fVarMap[o->canonical_display_name()]));
|
value = ConvertVariableValue<options::ToVarValInfo>()((fVarMap[o->canonical_display_name()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,18 +449,14 @@ int FairMQProgOptions::PrintOptionsRaw()
|
||||||
|
|
||||||
string FairMQProgOptions::GetStringValue(const string& key)
|
string FairMQProgOptions::GetStringValue(const string& key)
|
||||||
{
|
{
|
||||||
unique_lock<mutex> lock(fConfigMutex);
|
lock_guard<mutex> lock(fMtx);
|
||||||
|
|
||||||
string valueStr;
|
string valueStr;
|
||||||
try
|
try {
|
||||||
{
|
if (fVarMap.count(key)) {
|
||||||
if (fVarMap.count(key))
|
|
||||||
{
|
|
||||||
valueStr = ConvertVariableValue<options::ToString>()(fVarMap.at(key));
|
valueStr = ConvertVariableValue<options::ToString>()(fVarMap.at(key));
|
||||||
}
|
}
|
||||||
}
|
} catch (exception& e) {
|
||||||
catch (exception& e)
|
|
||||||
{
|
|
||||||
LOG(error) << "Exception thrown for the key '" << key << "'";
|
LOG(error) << "Exception thrown for the key '" << key << "'";
|
||||||
LOG(error) << e.what();
|
LOG(error) << e.what();
|
||||||
}
|
}
|
||||||
|
@ -504,7 +466,7 @@ string FairMQProgOptions::GetStringValue(const string& key)
|
||||||
|
|
||||||
int FairMQProgOptions::Count(const string& key) const
|
int FairMQProgOptions::Count(const string& key) const
|
||||||
{
|
{
|
||||||
unique_lock<mutex> lock(fConfigMutex);
|
lock_guard<mutex> lock(fMtx);
|
||||||
|
|
||||||
return fVarMap.count(key);
|
return fVarMap.count(key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,17 +54,14 @@ class FairMQProgOptions
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int SetValue(const std::string& key, T val)
|
int SetValue(const std::string& key, T val)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(fConfigMutex);
|
std::unique_lock<std::mutex> lock(fMtx);
|
||||||
|
|
||||||
// update variable map
|
// update variable map
|
||||||
UpdateVarMap<typename std::decay<T>::type>(key, val);
|
UpdateVarMap<typename std::decay<T>::type>(key, val);
|
||||||
|
|
||||||
if (key == "channel-config")
|
if (key == "channel-config") {
|
||||||
{
|
|
||||||
ParseChannelsFromCmdLine();
|
ParseChannelsFromCmdLine();
|
||||||
}
|
} else if (fChannelKeyMap.count(key)) {
|
||||||
else if (fChannelKeyMap.count(key))
|
|
||||||
{
|
|
||||||
UpdateChannelValue(fChannelKeyMap.at(key).channel, fChannelKeyMap.at(key).index, fChannelKeyMap.at(key).member, val);
|
UpdateChannelValue(fChannelKeyMap.at(key).channel, fChannelKeyMap.at(key).index, fChannelKeyMap.at(key).member, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +77,7 @@ class FairMQProgOptions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Subscribe(const std::string& subscriber, std::function<void(typename fair::mq::PropertyChange::KeyType, T)> func)
|
void Subscribe(const std::string& subscriber, std::function<void(typename fair::mq::PropertyChange::KeyType, T)> func)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(fConfigMutex);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
|
|
||||||
static_assert(!std::is_same<T,const char*>::value || !std::is_same<T, char*>::value,
|
static_assert(!std::is_same<T,const char*>::value || !std::is_same<T, char*>::value,
|
||||||
"In template member FairMQProgOptions::Subscribe<T>(key,Lambda) the types const char* or char* for the calback signatures are not supported.");
|
"In template member FairMQProgOptions::Subscribe<T>(key,Lambda) the types const char* or char* for the calback signatures are not supported.");
|
||||||
|
@ -91,21 +88,21 @@ class FairMQProgOptions
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Unsubscribe(const std::string& subscriber)
|
void Unsubscribe(const std::string& subscriber)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(fConfigMutex);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
|
|
||||||
fEvents.Unsubscribe<fair::mq::PropertyChange, T>(subscriber);
|
fEvents.Unsubscribe<fair::mq::PropertyChange, T>(subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubscribeAsString(const std::string& subscriber, std::function<void(typename fair::mq::PropertyChange::KeyType, std::string)> func)
|
void SubscribeAsString(const std::string& subscriber, std::function<void(typename fair::mq::PropertyChange::KeyType, std::string)> func)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(fConfigMutex);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
|
|
||||||
fEvents.Subscribe<fair::mq::PropertyChangeAsString, std::string>(subscriber, func);
|
fEvents.Subscribe<fair::mq::PropertyChangeAsString, std::string>(subscriber, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnsubscribeAsString(const std::string& subscriber)
|
void UnsubscribeAsString(const std::string& subscriber)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(fConfigMutex);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
|
|
||||||
fEvents.Unsubscribe<fair::mq::PropertyChangeAsString, std::string>(subscriber);
|
fEvents.Unsubscribe<fair::mq::PropertyChangeAsString, std::string>(subscriber);
|
||||||
}
|
}
|
||||||
|
@ -116,16 +113,13 @@ class FairMQProgOptions
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T GetValue(const std::string& key) const
|
T GetValue(const std::string& key) const
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(fConfigMutex);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
|
|
||||||
T val = T();
|
T val = T();
|
||||||
|
|
||||||
if (fVarMap.count(key))
|
if (fVarMap.count(key)) {
|
||||||
{
|
|
||||||
val = fVarMap[key].as<T>();
|
val = fVarMap[key].as<T>();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(warn) << "Config has no key: " << key << ". Returning default constructed object.";
|
LOG(warn) << "Config has no key: " << key << ". Returning default constructed object.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,28 +131,10 @@ class FairMQProgOptions
|
||||||
|
|
||||||
int Count(const std::string& key) const;
|
int Count(const std::string& key) const;
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T ConvertTo(const std::string& strValue)
|
|
||||||
{
|
|
||||||
if (std::is_arithmetic<T>::value)
|
|
||||||
{
|
|
||||||
std::istringstream iss(strValue);
|
|
||||||
T val;
|
|
||||||
iss >> val;
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG(error) << "the provided string " << strValue << " cannot be converted to the requested type. The target type must be arithmetic type.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add options_description
|
// add options_description
|
||||||
int AddToCmdLineOptions(const boost::program_options::options_description optDesc, bool visible = true);
|
int AddToCmdLineOptions(const boost::program_options::options_description optDesc, bool visible = true);
|
||||||
boost::program_options::options_description& GetCmdLineOptions();
|
boost::program_options::options_description& GetCmdLineOptions();
|
||||||
|
|
||||||
const boost::program_options::variables_map& GetVarMap() const { return fVarMap; }
|
|
||||||
|
|
||||||
int PrintOptions();
|
int PrintOptions();
|
||||||
int PrintOptionsRaw();
|
int PrintOptionsRaw();
|
||||||
|
|
||||||
|
@ -183,7 +159,7 @@ class FairMQProgOptions
|
||||||
boost::program_options::options_description fMQOptions; ///< MQ options descriptions
|
boost::program_options::options_description fMQOptions; ///< MQ options descriptions
|
||||||
boost::program_options::options_description fParserOptions; ///< MQ Parser options descriptions
|
boost::program_options::options_description fParserOptions; ///< MQ Parser options descriptions
|
||||||
|
|
||||||
mutable std::mutex fConfigMutex;
|
mutable std::mutex fMtx;
|
||||||
|
|
||||||
std::unordered_map<std::string, int> fChannelInfo; ///< channel name - number of subchannels
|
std::unordered_map<std::string, int> fChannelInfo; ///< channel name - number of subchannels
|
||||||
std::unordered_map<std::string, ChannelKey> fChannelKeyMap;// key=full path - val=key info
|
std::unordered_map<std::string, ChannelKey> fChannelKeyMap;// key=full path - val=key info
|
||||||
|
@ -199,16 +175,6 @@ class FairMQProgOptions
|
||||||
void UpdateMQValues();
|
void UpdateMQValues();
|
||||||
int Store(const FairMQChannelMap& channels);
|
int Store(const FairMQChannelMap& channels);
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void EmitUpdate(const std::string& key, T val)
|
|
||||||
{
|
|
||||||
// compile time check whether T is const char* or char*, and in that case a compile time error is thrown.
|
|
||||||
static_assert(!std::is_same<T,const char*>::value || !std::is_same<T, char*>::value,
|
|
||||||
"In template member FairMQProgOptions::EmitUpdate<T>(key,val) the types const char* or char* for the calback signatures are not supported.");
|
|
||||||
fEvents.Emit<fair::mq::PropertyChange, T>(key, val);
|
|
||||||
fEvents.Emit<fair::mq::PropertyChangeAsString, std::string>(key, GetStringValue(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
int UpdateChannelMap(const FairMQChannelMap& map);
|
int UpdateChannelMap(const FairMQChannelMap& map);
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int UpdateChannelValue(const std::string&, int, const std::string&, T)
|
int UpdateChannelValue(const std::string&, int, const std::string&, T)
|
||||||
|
|
|
@ -34,8 +34,7 @@ namespace mq
|
||||||
template<class T>
|
template<class T>
|
||||||
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
|
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
|
||||||
{
|
{
|
||||||
for (const auto& i : v)
|
for (const auto& i : v) {
|
||||||
{
|
|
||||||
os << i << " ";
|
os << i << " ";
|
||||||
}
|
}
|
||||||
return os;
|
return os;
|
||||||
|
@ -105,12 +104,9 @@ struct ConvertVariableValue : T
|
||||||
{
|
{
|
||||||
std::string defaulted;
|
std::string defaulted;
|
||||||
|
|
||||||
if (varVal.defaulted())
|
if (varVal.defaulted()) {
|
||||||
{
|
|
||||||
defaulted = " [default]";
|
defaulted = " [default]";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
defaulted = " [provided]";
|
defaulted = " [provided]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,12 +88,6 @@ int main(int argc, char** argv)
|
||||||
MyDevice device;
|
MyDevice device;
|
||||||
device.SetConfig(config);
|
device.SetConfig(config);
|
||||||
|
|
||||||
// getting as string and conversion helpers
|
|
||||||
|
|
||||||
// string dataRateStr = config.GetStringValue("data-rate");
|
|
||||||
// double dataRate = config.ConvertTo<double>(dataRateStr);
|
|
||||||
// LOG(info) << "dataRate: " << dataRate;
|
|
||||||
|
|
||||||
LOG(info) << "Subscribing: <string>(chans.data.0.address)";
|
LOG(info) << "Subscribing: <string>(chans.data.0.address)";
|
||||||
config.Subscribe<string>("test", [&device](const string& key, string value)
|
config.Subscribe<string>("test", [&device](const string& key, string value)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user