Skip to content

Commit 497aa36

Browse files
matthiasrichterktf
authored andcommitted
Implementing options '--poll-period' and 'dry-run' and short keys
The options were available in the old argument parsing.
1 parent d5d22a9 commit 497aa36

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

Utilities/aliceHLTwrapper/include/aliceHLTwrapper/WrapperDevice.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ class WrapperDevice : public FairMQDevice {
4848
/// get description of options
4949
static bpo::options_description GetOptionsDescription();
5050

51+
enum /*class*/ OptionKeyIds /*: int*/ {
52+
OptionKeyPollPeriod = 0,
53+
OptionKeyDryRun,
54+
OptionKeyLast
55+
};
56+
57+
constexpr static const char* OptionKeys[] = {
58+
"poll-period",
59+
"dry-run",
60+
nullptr
61+
};
62+
5163
/////////////////////////////////////////////////////////////////
5264
// the FairMQDevice interface
5365

Utilities/aliceHLTwrapper/src/WrapperDevice.cxx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,19 @@ WrapperDevice::WrapperDevice(int verbosity)
5757
WrapperDevice::~WrapperDevice()
5858
= default;
5959

60+
constexpr const char* WrapperDevice::OptionKeys[];
61+
6062
bpo::options_description WrapperDevice::GetOptionsDescription()
6163
{
6264
// assemble the options for the device class and component
6365
bpo::options_description od("WrapperDevice options");
66+
od.add_options()
67+
(OptionKeys[OptionKeyPollPeriod],
68+
bpo::value<int>()->default_value(10),
69+
"polling period")
70+
((std::string(OptionKeys[OptionKeyDryRun]) + ",n").c_str(),
71+
bpo::value<bool>()->zero_tokens()->default_value(false),
72+
"skip component processing");
6473
od.add(Component::GetOptionsDescription());
6574
return od;
6675
}
@@ -84,13 +93,13 @@ void WrapperDevice::InitTask()
8493
// option_description entires, but options_description does not
8594
// provide such a functionality
8695
vector<std::string> argstrings;
87-
bpo::options_description descriptions = GetOptionsDescription();
96+
bpo::options_description componentOptionDescriptions = Component::GetOptionsDescription();
8897
const auto * config = GetConfig();
8998
if (config) {
9099
const auto varmap = config->GetVarMap();
91100
for (const auto varit : varmap) {
92101
// check if this key belongs to the options of the device
93-
const auto * description = descriptions.find_nothrow(varit.first, false);
102+
const auto * description = componentOptionDescriptions.find_nothrow(varit.first, false);
94103
if (description && varmap.count(varit.first) && !varit.second.defaulted()) {
95104
argstrings.push_back("--");
96105
argstrings.back() += varit.first;
@@ -109,6 +118,8 @@ void WrapperDevice::InitTask()
109118
}
110119
}
111120
}
121+
mPollingPeriod = config->GetValue<int>(OptionKeys[OptionKeyPollPeriod]);
122+
mSkipProcessing = config->GetValue<bool>(OptionKeys[OptionKeyDryRun]);
112123
}
113124

114125
// TODO: probably one can get rid of this option, the instance/device

0 commit comments

Comments
 (0)