Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IdDictField.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #include "IdDict/IdDictField.h"
6 #include "IdDict/IdDictLabel.h"
7 #include <stdexcept>
8 #include <format>
9 #include <iostream>
10 
11 
13 }
14 
16  const std::string& /*tag*/) {
17 }
18 
20 }
21 
22 bool IdDictField::verify() const {
23  return(true);
24 }
25 
26 IdDictLabel* IdDictField::find_label(const std::string& name) const {
27  for (size_t i = 0; i < m_labels.size(); ++i) {
29  if ((label != 0) && (label->m_name == name)) return(label);
30  }
31 
32  return(0);
33 }
34 
35 void
37  m_labels.push_back(label);
38 }
39 
40 size_t
42  return m_labels.size();
43 }
44 
45 const std::string
47  std::string result;
48  try{
49  result = m_labels.at(index)->m_name;
50  } catch (std::out_of_range& e) {
51  throw std::out_of_range(std::format("IdDictField::get_label : Attempt to access index {} in vector of size {}",
52  index, m_labels.size()));
53  }
54  return result;
55 }
56 
58 IdDictField::get_label_value(const std::string& name) const {
60  if (std::ranges::find_if(name,[](const char c){ return !std::isdigit(c); }) != name.end()) {
61  for (const auto* label: m_labels) {
62  if (label == nullptr) continue;
63  if (label->m_valued) value = label->m_value;
64  if (label->m_name == name) {
65  return(value);
66  }
67  value++;
68  }
69  }
70  try{
71  value = std::stoi(name);
72  return value;
73  } catch (const std::invalid_argument& e) {
74  std::cerr << "Warning : label " << name << " not found: "<<e.what() << std::endl;
75  }
76 
77  return(0);
78 }
79 
81  for (size_t i = 0; i < m_labels.size(); ++i) {
83  delete label;
84  }
85  m_labels.clear();
86 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
get_generator_info.result
result
Definition: get_generator_info.py:21
IdDictLabel.h
vtune_athena.format
format
Definition: vtune_athena.py:14
IdDictField::add_label
void add_label(IdDictLabel *label)
Definition: IdDictField.cxx:36
index
Definition: index.py:1
IdDictField::clear
void clear()
Definition: IdDictField.cxx:80
IdDictField::find_label
IdDictLabel * find_label(const std::string &name) const
Definition: IdDictField.cxx:26
IdDictField::generate_implementation
void generate_implementation(const IdDictMgr &idd, const std::string &tag="")
Definition: IdDictField.cxx:15
athena.value
value
Definition: athena.py:124
IdDictMgr
Definition: IdDictMgr.h:14
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictField::get_label_number
size_t get_label_number() const
Definition: IdDictField.cxx:41
IdDictField::verify
bool verify() const
Definition: IdDictField.cxx:22
add-xsec-uncert-quadrature-N.label
label
Definition: add-xsec-uncert-quadrature-N.py:104
IdDictLabel
Definition: IdDictLabel.h:10
IdDictField::get_label_value
ExpandedIdentifier::element_type get_label_value(const std::string &name) const
Definition: IdDictField.cxx:58
IdDictField::m_labels
std::vector< IdDictLabel * > m_labels
Definition: IdDictField.h:29
IdDictField::get_label
const std::string get_label(size_t index) const
Definition: IdDictField.cxx:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
IdDictField.h
IdDictField::reset_implementation
void reset_implementation()
Definition: IdDictField.cxx:19
ExpandedIdentifier::element_type
int element_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:106
python.compressB64.c
def c
Definition: compressB64.py:93
IdDictField::resolve_references
void resolve_references(const IdDictMgr &idd)
Definition: IdDictField.cxx:12