Project
Loading...
Searching...
No Matches
BoostOptionsRetriever.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#include "PropertyTreeHelpers.h"
16
17#include <boost/program_options.hpp>
18#include <boost/program_options/options_description.hpp>
19
20#include <string>
21#include <vector>
22#include <cstdlib>
23#include <cstring>
24
25using namespace o2::framework;
26namespace bpo = boost::program_options;
27
28namespace o2::framework
29{
30
32 int argc, char** argv)
33 : mDescription{std::make_unique<boost::program_options::options_description>("ALICE O2 Framework - Available options")},
34 mArgc{argc},
35 mArgv{argv},
36 mIgnoreUnknown{ignoreUnknown}
37{
38}
39
40void BoostOptionsRetriever::update(std::vector<ConfigParamSpec> const& specs,
41 boost::property_tree::ptree& store,
42 boost::property_tree::ptree& provenance)
43{
44 auto options = mDescription->add_options();
45 for (const auto& spec : specs) {
46 const char* name = spec.name.c_str();
47 const char* help = spec.help.c_str();
48 // FIXME: propagate default value?
49 switch (spec.type) {
51 options = options(name, bpo::value<int>()->default_value(spec.defaultValue.get<int>()), help);
52 break;
54 options = options(name, bpo::value<int8_t>()->default_value(spec.defaultValue.get<int8_t>()), help);
55 break;
57 options = options(name, bpo::value<int16_t>()->default_value(spec.defaultValue.get<int16_t>()), help);
58 break;
60 options = options(name, bpo::value<uint8_t>()->default_value(spec.defaultValue.get<uint8_t>()), help);
61 break;
63 options = options(name, bpo::value<uint16_t>()->default_value(spec.defaultValue.get<uint16_t>()), help);
64 break;
66 options = options(name, bpo::value<uint32_t>()->default_value(spec.defaultValue.get<uint32_t>()), help);
67 break;
69 options = options(name, bpo::value<uint64_t>()->default_value(spec.defaultValue.get<uint64_t>()), help);
70 break;
72 options = options(name, bpo::value<int64_t>()->default_value(spec.defaultValue.get<int64_t>()), help);
73 break;
75 options = options(name, bpo::value<float>()->default_value(spec.defaultValue.get<float>()), help);
76 break;
78 options = options(name, bpo::value<double>()->default_value(spec.defaultValue.get<double>()), help);
79 break;
81 options = options(name, bpo::value<std::string>()->default_value(spec.defaultValue.get<const char*>()), help);
82 break;
84 options = options(name, bpo::value<bool>()->zero_tokens()->default_value(spec.defaultValue.get<bool>()), help);
85 break;
98 options = options(name, bpo::value<std::string>()->default_value(spec.defaultValue.asString()), help);
99 break;
103 break;
104 };
105 }
106
107 using namespace bpo::command_line_style;
108 auto style = (allow_short | short_allow_adjacent | short_allow_next | allow_long | long_allow_adjacent | long_allow_next | allow_sticky | allow_dash_for_short);
109
110 auto parsed = mIgnoreUnknown ? bpo::command_line_parser(mArgc, mArgv).options(*mDescription).style(style).allow_unregistered().run()
111 : bpo::parse_command_line(mArgc, mArgv, *mDescription, style);
112 bpo::variables_map vmap;
113 bpo::store(parsed, vmap);
114 PropertyTreeHelpers::populate(specs, store, vmap, provenance);
115}
116
117} // namespace o2::framework
unsigned char uint8_t
unsigned short int uint16_t
unsigned int uint32_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
void update(std::vector< ConfigParamSpec > const &specs, boost::property_tree::ptree &store, boost::property_tree::ptree &provenance) override
BoostOptionsRetriever(bool ignoreUnknown, int argc, char **argv)
GLuint const GLchar * name
Definition glcorearb.h:781
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
boost::program_options::options_description options_description
static void populate(std::vector< ConfigParamSpec > const &schema, boost::property_tree::ptree &tree, boost::program_options::variables_map const &vmap, boost::property_tree::ptree &provenance)