DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
appfwk
src
CommandLineInterpreter.hpp
Go to the documentation of this file.
1
11
12
#ifndef APPFWK_SRC_COMMANDLINEINTERPRETER_HPP_
13
#define APPFWK_SRC_COMMANDLINEINTERPRETER_HPP_
14
15
#include "boost/program_options.hpp"
16
17
#include <iostream>
18
#include <string>
19
#include <vector>
20
21
namespace
bpo = boost::program_options;
22
23
namespace
dunedaq::appfwk
{
31
struct
CommandLineInterpreter
32
{
33
public
:
40
static
CommandLineInterpreter
parse
(
int
argc,
char
** argv)
41
{
42
CommandLineInterpreter
output;
43
44
std::ostringstream descstr;
45
descstr << *argv
46
<<
" known arguments (additional arguments will be stored and "
47
"passed on)"
;
48
bpo::options_description desc(descstr.str());
49
desc.add_options()(
"name,n"
, bpo::value<std::string>()->required(),
"Application name"
)(
50
"sessionName,s"
, bpo::value<std::string>()->required(),
"Session name"
)(
51
"configurationId,k"
, bpo::value<std::string>()->required(),
"Configuration id"
)(
52
"commandFacility,c"
, bpo::value<std::string>()->required(),
"CommandFacility URI"
)(
53
"configurationService,d"
, bpo::value<std::string>()->required(),
"Configuration Service URI"
)(
54
"help,h"
,
"produce help message"
);
55
56
bpo::variables_map vm;
57
auto
parsed = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
58
59
output.
other_options
= bpo::collect_unrecognized(parsed.options, bpo::include_positional);
60
bpo::store(parsed, vm);
61
62
if
(vm.count(
"help"
)) {
63
std::cout << desc << std::endl;
// NOLINT
64
output.
help_requested
=
true
;
65
return
output;
66
}
67
68
bpo::notify(vm);
69
70
output.
app_name
= vm[
"name"
].as<std::string>();
71
output.
session_name
= vm[
"sessionName"
].as<std::string>();
72
output.
configuration_id
= vm[
"configurationId"
].as<std::string>();
73
output.
command_facility_plugin_name
= vm[
"commandFacility"
].as<std::string>();
74
output.
conf_service_plugin_name
= vm[
"configurationService"
].as<std::string>();
75
return
output;
76
}
77
78
bool
help_requested
{
false
};
79
80
std::string
app_name
{
""
};
81
std::string
session_name
{
""
};
82
std::string
configuration_id
{
""
};
83
std::string
command_facility_plugin_name
{
""
};
84
std::string
conf_service_plugin_name
{
""
};
85
86
std::vector<std::string>
other_options
{};
87
};
88
}
// namespace dunedaq::appfwk
89
90
#endif
// APPFWK_SRC_COMMANDLINEINTERPRETER_HPP_
dunedaq::appfwk
Definition
Nljs.hpp:18
dunedaq::appfwk::CommandLineInterpreter
CommandLineInterpreter parses the command-line options given to the application and stores the result...
Definition
CommandLineInterpreter.hpp:32
dunedaq::appfwk::CommandLineInterpreter::conf_service_plugin_name
std::string conf_service_plugin_name
Definition
CommandLineInterpreter.hpp:84
dunedaq::appfwk::CommandLineInterpreter::help_requested
bool help_requested
Definition
CommandLineInterpreter.hpp:78
dunedaq::appfwk::CommandLineInterpreter::other_options
std::vector< std::string > other_options
Any other options which were passed and not recognized.
Definition
CommandLineInterpreter.hpp:86
dunedaq::appfwk::CommandLineInterpreter::command_facility_plugin_name
std::string command_facility_plugin_name
Definition
CommandLineInterpreter.hpp:83
dunedaq::appfwk::CommandLineInterpreter::parse
static CommandLineInterpreter parse(int argc, char **argv)
Parse the command line and return a CommandLineInterpreter struct.
Definition
CommandLineInterpreter.hpp:40
dunedaq::appfwk::CommandLineInterpreter::session_name
std::string session_name
Definition
CommandLineInterpreter.hpp:81
dunedaq::appfwk::CommandLineInterpreter::configuration_id
std::string configuration_id
Definition
CommandLineInterpreter.hpp:82
dunedaq::appfwk::CommandLineInterpreter::app_name
std::string app_name
Definition
CommandLineInterpreter.hpp:80
Generated on
for DUNE-DAQ by
1.17.0