19#include <boost/program_options/variables_map.hpp> 
   31template <VariantType T>
 
   32inline Variant fromString(std::string 
const& 
str)
 
   36  return VariantJSONHelpers::read<T>(ss);
 
   40                                           boost::property_tree::ptree& pt,
 
   41                                           boost::property_tree::ptree& provenance)
 
   44  O2_SIGNPOST_START(configuration, cid, 
"populateDefaults", 
"Filling with defaults");
 
   45  for (
auto const& spec : schema) {
 
   46    std::string 
key = spec.name.substr(0, spec.name.find(
','));
 
   53          pt.put(
key, spec.defaultValue.get<
int>());
 
   56          pt.put(
key, spec.defaultValue.get<int8_t>());
 
   59          pt.put(
key, spec.defaultValue.get<int16_t>());
 
   62          pt.put(
key, spec.defaultValue.get<uint8_t>());
 
   65          pt.put(
key, spec.defaultValue.get<uint16_t>());
 
   68          pt.put(
key, spec.defaultValue.get<uint32_t>());
 
   71          pt.put(
key, spec.defaultValue.get<uint64_t>());
 
   74          pt.put(
key, spec.defaultValue.get<int64_t>());
 
   77          pt.put(
key, spec.defaultValue.get<
float>());
 
   80          pt.put(
key, spec.defaultValue.get<
double>());
 
   83          pt.put(
key, spec.defaultValue.get<std::string>());
 
   86          bool value = spec.defaultValue.get<
bool>();
 
   92          pt.put_child(
key, boost::property_tree::ptree{});
 
   95          pt.put_child(
key, 
vectorToBranch(spec.defaultValue.get<
int*>(), spec.defaultValue.size()));
 
   98          pt.put_child(
key, 
vectorToBranch(spec.defaultValue.get<
float*>(), spec.defaultValue.size()));
 
  101          pt.put_child(
key, 
vectorToBranch(spec.defaultValue.get<
double*>(), spec.defaultValue.size()));
 
  104          pt.put_child(
key, 
vectorToBranch(spec.defaultValue.get<
bool*>(), spec.defaultValue.size()));
 
  107          pt.put_child(
key, 
vectorToBranch(spec.defaultValue.get<std::string*>(), spec.defaultValue.size()));
 
  135      provenance.put(
key, 
"default");
 
  136    } 
catch (std::runtime_error& re) {
 
  137      O2_SIGNPOST_END_WITH_ERROR(configuration, cid, 
"populateDefaults", 
"Aborting because of runtime_error %{public}s", re.what());
 
  139    } 
catch (std::exception& e) {
 
  141      throw std::invalid_argument(std::string(
"missing option: ") + 
key + 
" (" + e.what() + 
")");
 
  144      throw std::invalid_argument(std::string(
"missing option: ") + 
key);
 
 
  151                                   boost::property_tree::ptree& pt,
 
  152                                   boost::program_options::variables_map 
const& vmap,
 
  153                                   boost::property_tree::ptree& provenance)
 
  156  O2_SIGNPOST_START(configuration, cid, 
"populate", 
"Filling parameters from variables_map");
 
  157  for (
auto const& spec : schema) {
 
  159    std::string 
key = spec.name.substr(0, spec.name.find(
','));
 
  160    if (vmap.count(
key) == 0) {
 
  166          pt.put(
key, vmap[
key].as<int>());
 
  169          pt.put(
key, vmap[
key].as<int8_t>());
 
  172          pt.put(
key, vmap[
key].as<int16_t>());
 
  175          pt.put(
key, vmap[
key].as<uint8_t>());
 
  178          pt.put(
key, vmap[
key].as<uint16_t>());
 
  181          pt.put(
key, vmap[
key].as<uint32_t>());
 
  184          pt.put(
key, vmap[
key].as<uint64_t>());
 
  187          pt.put(
key, vmap[
key].as<int64_t>());
 
  190          pt.put(
key, vmap[
key].as<float>());
 
  193          pt.put(
key, vmap[
key].as<double>());
 
  196          if (
auto const* 
v = boost::any_cast<std::string>(&vmap[
key].
value())) {
 
  201          auto v = vmap[
key].as<
bool>();
 
  206          auto v = fromString<VariantType::ArrayInt>(vmap[
key].as<std::string>());
 
  207          pt.put_child(
key, vectorToBranch<int>(
v.get<
int*>(), 
v.size()));
 
  210          auto v = fromString<VariantType::ArrayFloat>(vmap[
key].as<std::string>());
 
  211          pt.put_child(
key, vectorToBranch<float>(
v.get<
float*>(), 
v.size()));
 
  214          auto v = fromString<VariantType::ArrayDouble>(vmap[
key].as<std::string>());
 
  215          pt.put_child(
key, vectorToBranch<double>(
v.get<
double*>(), 
v.size()));
 
  221          auto v = fromString<VariantType::ArrayString>(vmap[
key].as<std::string>());
 
  222          pt.put_child(
key, vectorToBranch<std::string>(
v.get<std::string*>(), 
v.size()));
 
  225          auto v = fromString<VariantType::Array2DInt>(vmap[
key].as<std::string>());
 
  229          auto v = fromString<VariantType::Array2DFloat>(vmap[
key].as<std::string>());
 
  233          auto v = fromString<VariantType::Array2DDouble>(vmap[
key].as<std::string>());
 
  237          auto v = fromString<VariantType::LabeledArrayInt>(vmap[
key].as<std::string>());
 
  241          auto v = fromString<VariantType::LabeledArrayFloat>(vmap[
key].as<std::string>());
 
  245          auto v = fromString<VariantType::LabeledArrayDouble>(vmap[
key].as<std::string>());
 
  249          auto v = fromString<VariantType::LabeledArrayString>(vmap[
key].as<std::string>());
 
  253          pt.put_child(
key, vmap[
key].as<boost::property_tree::ptree>());
 
  260      provenance.put(
key, 
"fairmq");
 
  261    } 
catch (std::runtime_error& re) {
 
  264    } 
catch (std::exception& e) {
 
  266      throw std::invalid_argument(std::string(
"missing option: ") + 
key + 
" (" + e.what() + 
")");
 
  269      throw std::invalid_argument(std::string(
"missing option: ") + 
key);
 
 
  281  if (spec.getLabelsCols().empty() == 
false) {
 
  284  if (spec.getLabelsRows().empty() == 
false) {
 
 
  291                                   boost::property_tree::ptree& pt,
 
  292                                   boost::property_tree::ptree 
const& in,
 
  293                                   boost::property_tree::ptree& provenance,
 
  294                                   std::string 
const& provenanceLabel)
 
  297  O2_SIGNPOST_START(configuration, cid, 
"populate", 
"Filling parameters from ptree");
 
  298  for (
auto const& spec : schema) {
 
  300    std::string 
key = spec.name.substr(0, spec.name.find(
','));
 
  301    auto it = in.get_child_optional(
key);
 
  303      it = in.get_child_optional(boost::property_tree::path(
key, 
'/'));
 
  311          pt.put(
key, (*it).get_value<
int>());
 
  314          pt.put(
key, (*it).get_value<int8_t>());
 
  317          pt.put(
key, (*it).get_value<int16_t>());
 
  320          pt.put(
key, (*it).get_value<uint8_t>());
 
  323          pt.put(
key, (*it).get_value<uint16_t>());
 
  326          pt.put(
key, (*it).get_value<uint32_t>());
 
  329          pt.put(
key, (*it).get_value<uint64_t>());
 
  332          pt.put(
key, (*it).get_value<int64_t>());
 
  335          pt.put(
key, (*it).get_value<
float>());
 
  338          pt.put(
key, (*it).get_value<
double>());
 
  341          pt.put(
key, (*it).get_value<std::string>());
 
  344          auto v = (*it).get_value<
bool>();
 
  346          pt.put(
key, (*it).get_value<
bool>());
 
  357          pt.put_child(
key, *it);
 
  360          auto v = labeledArrayFromBranch<int>(it.value());
 
  362            pt.put_child(
key, *it);
 
  368          auto v = labeledArrayFromBranch<float>(it.value());
 
  370            pt.put_child(
key, *it);
 
  376          auto v = labeledArrayFromBranch<double>(it.value());
 
  378            pt.put_child(
key, *it);
 
  386            pt.put_child(
key, *it);
 
  394          throw std::runtime_error(
"Unknown variant type");
 
  396      provenance.put(
key, provenanceLabel);
 
  397    } 
catch (std::runtime_error& re) {
 
  398      O2_SIGNPOST_END_WITH_ERROR(configuration, cid, 
"populate", 
"Aborting during processing of %{public}s because of runtime_error %{public}s",
 
  399                                 key.c_str(), re.what());
 
  401    } 
catch (std::exception& e) {
 
  403      throw std::invalid_argument(std::string(
"missing option: ") + 
key + 
" (" + e.what() + 
")");
 
  406      throw std::invalid_argument(std::string(
"missing option: ") + 
key);
 
 
  414void traverseRecursive(
const boost::property_tree::ptree& parent,
 
  415                       const boost::property_tree::ptree::path_type& childPath,
 
  416                       const boost::property_tree::ptree& child,
 
  419  using boost::property_tree::ptree;
 
  421  method(parent, childPath, child);
 
  422  for (ptree::const_iterator it = child.begin(); it != child.end(); ++it) {
 
  423    ptree::path_type curPath = childPath / ptree::path_type(it->first);
 
  424    traverseRecursive(parent, curPath, it->second, method);
 
  432  traverseRecursive(parent, 
"", parent, method);
 
 
#define O2_DECLARE_DYNAMIC_LOG(name)
#define O2_SIGNPOST_END(log, id, name, format,...)
#define O2_SIGNPOST_ID_GENERATE(name, log)
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format,...)
#define O2_SIGNPOST_END_WITH_ERROR(log, id, name, format,...)
#define O2_SIGNPOST_START(log, id, name, format,...)
template o2::framework::LabeledArray< std::string > o2::framework::labeledArrayFromBranch< std::string >(boost::property_tree::ptree const &tree)
void replaceLabelsRows(std::vector< std::string > const &labels)
void replaceLabelsCols(std::vector< std::string > const &labels)
GLsizei const GLfloat * value
Defining PrimaryVertex explicitly as messageable.
RuntimeErrorRef runtime_error(const char *)
boost::property_tree::ptree labeledArrayToBranch(LabeledArray< T > &&array)
auto replaceLabels(LabeledArray< T > &input, LabeledArray< T > &&spec)
boost::property_tree::ptree vectorToBranch(T *values, size_t size)
boost::property_tree::ptree array2DToBranch(Array2D< T > &&array)
RuntimeErrorRef runtime_error_f(const char *,...)
auto getLabelsRows() const
auto getLabelsCols() const
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)
std::function< void(boost::property_tree::ptree const  &, typename T::path_type, boost::property_tree::ptree const  &)> WalkerFunction
static void populateDefaults(std::vector< ConfigParamSpec > const &schema, boost::property_tree::ptree &tree, boost::property_tree::ptree &provenance)