ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
IdDictField Class Reference

#include <IdDictField.h>

Collaboration diagram for IdDictField:

Public Member Functions

 IdDictField (const std::string &name)
 
const std::string & name () const
 
size_t index () const
 
size_t get_label_number () const
 
IdDictLabelfind_label (const std::string &name) const
 
const IdDictLabellabel (size_t index) const
 
const std::string & get_label (size_t index) const
 
ExpandedIdentifier::element_type get_label_value (const std::string &name) const
 
void add_label (IdDictLabel *label)
 
void set_index (size_t index)
 
bool verify () const
 
void clear ()
 

Private Attributes

std::string m_name
 
std::vector< IdDictLabel * > m_labels
 
size_t m_index {}
 

Detailed Description

Definition at line 15 of file IdDictField.h.

Constructor & Destructor Documentation

◆ IdDictField()

IdDictField::IdDictField ( const std::string &  name)

Definition at line 12 of file IdDictField.cxx.

13  : m_name(name)
14 {
15 }

Member Function Documentation

◆ add_label()

void IdDictField::add_label ( IdDictLabel label)

Definition at line 33 of file IdDictField.cxx.

33  {
34  m_labels.push_back(label);
35 }

◆ clear()

void IdDictField::clear ( )

Definition at line 80 of file IdDictField.cxx.

80  {
81  for (size_t i = 0; i < m_labels.size(); ++i) {
83  delete label;
84  }
85  m_labels.clear();
86 }

◆ find_label()

IdDictLabel * IdDictField::find_label ( const std::string &  name) const

Definition at line 23 of file IdDictField.cxx.

23  {
24  for (size_t i = 0; i < m_labels.size(); ++i) {
26  if ((label != 0) && (label->name() == name)) return(label);
27  }
28 
29  return(0);
30 }

◆ get_label()

const std::string & IdDictField::get_label ( size_t  index) const

Definition at line 48 of file IdDictField.cxx.

48  {
49  try{
50  return m_labels.at(index)->name();
51  } catch (std::out_of_range& e) {
52  throw std::out_of_range(std::format("IdDictField::get_label : Attempt to access index {} in vector of size {}",
53  index, m_labels.size()));
54  }
55 }

◆ get_label_number()

size_t IdDictField::get_label_number ( ) const

Definition at line 43 of file IdDictField.cxx.

43  {
44  return m_labels.size();
45 }

◆ get_label_value()

ExpandedIdentifier::element_type IdDictField::get_label_value ( const std::string &  name) const

Definition at line 58 of file IdDictField.cxx.

58  {
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->valued()) value = label->value();
64  if (label->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 }

◆ index()

size_t IdDictField::index ( ) const
inline

Definition at line 67 of file IdDictField.h.

68 {
69  return m_index;
70 }

◆ label()

const IdDictLabel & IdDictField::label ( size_t  index) const
inline

Definition at line 74 of file IdDictField.h.

75 {
76  return *m_labels.at(index);
77 }

◆ name()

const std::string & IdDictField::name ( ) const
inline

Definition at line 60 of file IdDictField.h.

61 {
62  return m_name;
63 }

◆ set_index()

void IdDictField::set_index ( size_t  index)

Definition at line 38 of file IdDictField.cxx.

38  {
39  m_index = index;
40 }

◆ verify()

bool IdDictField::verify ( ) const

Definition at line 19 of file IdDictField.cxx.

19  {
20  return(true);
21 }

Member Data Documentation

◆ m_index

size_t IdDictField::m_index {}
private

Definition at line 55 of file IdDictField.h.

◆ m_labels

std::vector<IdDictLabel*> IdDictField::m_labels
private

Definition at line 54 of file IdDictField.h.

◆ m_name

std::string IdDictField::m_name
private

Definition at line 53 of file IdDictField.h.


The documentation for this class was generated from the following files:
IdDictLabel::value
int value() const
Definition: IdDictLabel.h:51
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
IdDictField::m_index
size_t m_index
Definition: IdDictField.h:55
vtune_athena.format
format
Definition: vtune_athena.py:14
index
Definition: index.py:1
athena.value
value
Definition: athena.py:124
IdDictLabel::valued
bool valued() const
Definition: IdDictLabel.h:58
IdDictField::index
size_t index() const
Definition: IdDictField.h:67
IdDictField::label
const IdDictLabel & label(size_t index) const
Definition: IdDictField.h:74
IdDictLabel
Definition: IdDictLabel.h:10
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictField::m_name
std::string m_name
Definition: IdDictField.h:53
IdDictLabel::name
const std::string & name() const
Definition: IdDictLabel.h:44
IdDictField::name
const std::string & name() const
Definition: IdDictField.h:60
IdDictField::m_labels
std::vector< IdDictLabel * > m_labels
Definition: IdDictField.h:54
ExpandedIdentifier::element_type
int element_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:106
python.compressB64.c
def c
Definition: compressB64.py:93