ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictField Class Reference

#include <IdDictField.h>

Collaboration diagram for IdDictField:

Public Member Functions

 IdDictField (const std::string &name)
 IdDictField (IdDictField &&)
 ~IdDictField ()
IdDictFieldoperator= (IdDictField &&)
 IdDictField (const IdDictField &)=delete
IdDictFieldoperator= (const IdDictField &)=delete
const std::string & name () const
size_t index () const
size_t get_label_number () const
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 (std::unique_ptr< const IdDictLabel > label)
void set_index (size_t index)
bool verify () const
void clear ()

Private Attributes

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

Detailed Description

Definition at line 16 of file IdDictField.h.

Constructor & Destructor Documentation

◆ IdDictField() [1/3]

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

Definition at line 12 of file IdDictField.cxx.

13 : m_name(name)
14{
15}
std::string m_name
Definition IdDictField.h:60
const std::string & name() const
Definition IdDictField.h:67

◆ IdDictField() [2/3]

IdDictField::IdDictField ( IdDictField && )
default

◆ ~IdDictField()

IdDictField::~IdDictField ( )
default

◆ IdDictField() [3/3]

IdDictField::IdDictField ( const IdDictField & )
delete

Member Function Documentation

◆ add_label()

void IdDictField::add_label ( std::unique_ptr< const IdDictLabel > label)

Definition at line 36 of file IdDictField.cxx.

36 {
37 m_labels.push_back(std::move(label));
38}
const IdDictLabel & label(size_t index) const
Definition IdDictField.h:81
std::vector< std::unique_ptr< const IdDictLabel > > m_labels
Definition IdDictField.h:61

◆ clear()

void IdDictField::clear ( )

Definition at line 83 of file IdDictField.cxx.

83 {
84 m_labels.clear();
85}

◆ find_label()

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

Definition at line 28 of file IdDictField.cxx.

28 {
29 for (const auto& p : m_labels) {
30 if (p && p->name() == name) return p.get();
31 }
32 return nullptr;
33}

◆ get_label()

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

Definition at line 51 of file IdDictField.cxx.

51 {
52 try{
53 return m_labels.at(index)->name();
54 } catch (std::out_of_range& e) {
55 throw std::out_of_range(std::format("IdDictField::get_label : Attempt to access index {} in vector of size {}",
56 index, m_labels.size()));
57 }
58}
size_t index() const
Definition IdDictField.h:74

◆ get_label_number()

size_t IdDictField::get_label_number ( ) const

Definition at line 46 of file IdDictField.cxx.

46 {
47 return m_labels.size();
48}

◆ get_label_value()

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

Definition at line 61 of file IdDictField.cxx.

61 {
63 if (std::ranges::find_if(name,[](const char c){ return !std::isdigit(c); }) != name.end()) {
64 for (const auto& label: m_labels) {
65 if (!label) continue;
66 if (label->valued()) value = label->value();
67 if (label->name() == name) {
68 return(value);
69 }
70 value++;
71 }
72 }
73 try{
74 value = std::stoi(name);
75 return value;
76 } catch (const std::invalid_argument& e) {
77 std::cerr << "Warning : label " << name << " not found: "<<e.what() << std::endl;
78 }
79
80 return(0);
81}

◆ index()

size_t IdDictField::index ( ) const
inline

Definition at line 74 of file IdDictField.h.

75{
76 return m_index;
77}
size_t m_index
Definition IdDictField.h:62

◆ label()

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

Definition at line 81 of file IdDictField.h.

82{
83 return *m_labels.at(index);
84}

◆ name()

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

Definition at line 67 of file IdDictField.h.

68{
69 return m_name;
70}

◆ operator=() [1/2]

IdDictField & IdDictField::operator= ( const IdDictField & )
delete

◆ operator=() [2/2]

IdDictField & IdDictField::operator= ( IdDictField && )
default

◆ set_index()

void IdDictField::set_index ( size_t index)

Definition at line 41 of file IdDictField.cxx.

41 {
42 m_index = index;
43}

◆ verify()

bool IdDictField::verify ( ) const

Definition at line 24 of file IdDictField.cxx.

24 {
25 return(true);
26}

Member Data Documentation

◆ m_index

size_t IdDictField::m_index {}
private

Definition at line 62 of file IdDictField.h.

62{};

◆ m_labels

std::vector<std::unique_ptr<const IdDictLabel> > IdDictField::m_labels
private

Definition at line 61 of file IdDictField.h.

◆ m_name

std::string IdDictField::m_name
private

Definition at line 60 of file IdDictField.h.


The documentation for this class was generated from the following files: