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

#include <IdDictRange.h>

Inheritance diagram for IdDictRange:
Collaboration diagram for IdDictRange:

Public Types

enum  specification_type {
  unknown, by_value, by_values, by_label,
  by_labels, by_minmax
}
 
enum  continuation_mode {
  none, has_next, has_previous, has_both,
  wrap_around
}
 

Public Member Functions

 IdDictRange (const std::string &field_name)
 Set name only; no range information. More...
 
 IdDictRange (const std::string &field_name, const std::string &label)
 By label. More...
 
 IdDictRange (const std::string &field_name, int value)
 By value. More...
 
 IdDictRange (const std::string &field_name, int minvalue, int maxvalue)
 By minmax. More...
 
 IdDictRange (const std::string &field_name, const std::vector< int > &values)
 By list of values. More...
 
 IdDictRange (const std::string &field_name, const std::vector< std::string > &labels)
 By list of labels. More...
 
virtual ~IdDictRange ()=default
 
const std::string & field_name () const
 
const std::string & label () const
 
const IdDictFieldfield () const
 
specification_type specification () const
 
const std::vector< int > & values () const
 
const std::vector< std::string > & labels () const
 
void set_range (const std::string &label)
 By label. More...
 
void set_range (int value)
 By value. More...
 
void set_range (int minvalue, int maxvalue)
 By minmax. More...
 
void set_range (const std::vector< int > &values)
 By list of values. More...
 
void set_range (const std::vector< std::string > &labels)
 By list of labels. More...
 
void set_prev (int prev)
 Set previous value and adjust continuation mode. More...
 
void set_next (int next)
 Set next value and adjust continuation mode. More...
 
void set_wrap_around ()
 Enable wraparound. More...
 
virtual void resolve_references (const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion &region) override
 
virtual void generate_implementation (const IdDictMgr &idd, IdDictDictionary &dictionary, IdDictRegion &region, const std::string &tag="") override
 
virtual Range build_range () const override
 
virtual void reset_implementation ()
 
virtual bool verify () const
 
virtual void clear ()
 

Private Attributes

std::string m_field_name
 
IdDictFieldm_field {}
 
specification_type m_specification {unknown}
 
std::string m_tag
 
std::string m_label
 
int m_value {}
 
int m_minvalue {}
 
int m_maxvalue {}
 
int m_prev_value {}
 
int m_next_value {}
 
continuation_mode m_continuation_mode {none}
 
std::vector< std::string > m_labels
 
std::vector< int > m_values
 
bool m_resolved_references {}
 

Detailed Description

Definition at line 18 of file IdDictRange.h.

Member Enumeration Documentation

◆ continuation_mode

Enumerator
none 
has_next 
has_previous 
has_both 
wrap_around 

Definition at line 28 of file IdDictRange.h.

28  {
29  none,
30  has_next,
32  has_both,
34  };

◆ specification_type

Enumerator
unknown 
by_value 
by_values 
by_label 
by_labels 
by_minmax 

Definition at line 20 of file IdDictRange.h.

20  {
21  unknown,
22  by_value,
23  by_values,
24  by_label,
25  by_labels,
26  by_minmax
27  };

Constructor & Destructor Documentation

◆ IdDictRange() [1/6]

IdDictRange::IdDictRange ( const std::string &  field_name)

Set name only; no range information.

Definition at line 16 of file IdDictRange.cxx.

18 {
19 }

◆ IdDictRange() [2/6]

IdDictRange::IdDictRange ( const std::string &  field_name,
const std::string &  label 
)

By label.

Definition at line 23 of file IdDictRange.cxx.

26 {
27  set_range (label);
28 }

◆ IdDictRange() [3/6]

IdDictRange::IdDictRange ( const std::string &  field_name,
int  value 
)

By value.

Definition at line 32 of file IdDictRange.cxx.

35 {
36  set_range (value);
37 }

◆ IdDictRange() [4/6]

IdDictRange::IdDictRange ( const std::string &  field_name,
int  minvalue,
int  maxvalue 
)

By minmax.

Definition at line 41 of file IdDictRange.cxx.

44 {
45  set_range (minvalue, maxvalue);
46 }

◆ IdDictRange() [5/6]

IdDictRange::IdDictRange ( const std::string &  field_name,
const std::vector< int > &  values 
)

By list of values.

Definition at line 50 of file IdDictRange.cxx.

53 {
54  set_range (values);
55 }

◆ IdDictRange() [6/6]

IdDictRange::IdDictRange ( const std::string &  field_name,
const std::vector< std::string > &  labels 
)

By list of labels.

Definition at line 59 of file IdDictRange.cxx.

62 {
63  set_range (labels);
64 }

◆ ~IdDictRange()

virtual IdDictRange::~IdDictRange ( )
virtualdefault

Member Function Documentation

◆ build_range()

Range IdDictRange::build_range ( ) const
overridevirtual

Implements IdDictRegionEntry.

Definition at line 238 of file IdDictRange.cxx.

238  {
239  Range result;
240 
242  switch (m_specification) {
243  case by_value:
244  case by_label: {
245  field.set(m_value, m_value);
246  break;
247  }
248 
249  case by_values:
250  case by_labels: {
251  field.set(m_values);
252  break;
253  }
254 
255  case by_minmax: {
257  break;
258  }
259 
260  case unknown: {
261  break;
262  }
263  }
265  field.set(true);
266  } else if (has_previous == m_continuation_mode) {
267  field.set_previous(m_prev_value);
268  } else if (has_next == m_continuation_mode) {
269  field.set_next(m_next_value);
270  } else if (has_both == m_continuation_mode) {
271  field.set_previous(m_prev_value);
272  field.set_next(m_next_value);
273  }
274  result.add(std::move(field));
275  return(result);
276 }

◆ clear()

void IdDictRegionEntry::clear ( )
virtualinherited

Definition at line 29 of file IdDictRegionEntry.cxx.

29  {
30 }

◆ field()

const IdDictField * IdDictRange::field ( ) const
inline

Definition at line 156 of file IdDictRange.h.

157 {
158  return m_field;
159 }

◆ field_name()

const std::string & IdDictRange::field_name ( ) const
inline

Definition at line 142 of file IdDictRange.h.

143 {
144  return m_field_name;
145 }

◆ generate_implementation()

void IdDictRange::generate_implementation ( const IdDictMgr idd,
IdDictDictionary dictionary,
IdDictRegion region,
const std::string &  tag = "" 
)
overridevirtual

Reimplemented from IdDictRegionEntry.

Definition at line 178 of file IdDictRange.cxx.

179  {
180  // Add IdDictFieldImplementation to this region
181 
182  // NOTE: we DO NOT protect this method with
183  // m_generated_implementation because the same object may be
184  // called more than once because there are IdDictRangeRef's which
185  // point to the same IdDictRange's.
186 
187  if (Debugger::debug()) {
188  std::cout << "IdDictRange::generate_implementation>" << std::endl;
189  }
190 
192  impl.set_range(this);
193  if (m_field->index() == 0) {
194  m_field->set_index(region.fieldSize() - 1);
195  } else if (m_field->index() != (region.fieldSize() - 1)) {
196  std::cout << "Bad field index for " << m_field_name
197  << " index " << m_field->index()
198  << " in dictionary " << dictionary.name()
199  << " region #" << region.index()
200  << " group " << region.group_name()
201  << " tag " << region.tag()
202  << " size " << (region.n_implementation() - 1)
203  << std::endl;
204  }
205 
206  size_t index = region.n_implementation() - 1;
207  if (region.n_implementation() <= index) {
208  std::cout << "IdDictRange::generate_implementation: index >= impl size - "
209  << index << " " << region.fieldSize()
210  << std::endl;
211  return;
212  }
213 
215  switch (m_specification) {
216  case by_value:
217  case by_label: {
218  impl.set_field(Range::field(m_value, m_value));
219  break;
220  }
221 
222  case by_values:
223  case by_labels: {
224  impl.set_field(Range::field(m_values));
225  }
226  break;
227 
228  case by_minmax:
229  impl.set_field(Range::field(m_minvalue, m_maxvalue));
230  break;
231 
232  case unknown:
233  break;
234  }
235 }

◆ label()

const std::string & IdDictRange::label ( ) const
inline

Definition at line 149 of file IdDictRange.h.

150 {
151  return m_label;
152 }

◆ labels()

const std::vector< std::string > & IdDictRange::labels ( ) const
inline

Definition at line 177 of file IdDictRange.h.

178 {
179  return m_labels;
180 }

◆ reset_implementation()

void IdDictRegionEntry::reset_implementation ( )
virtualinherited

Reimplemented in IdDictDictionaryRef, IdDictRangeRef, and IdDictReference.

Definition at line 22 of file IdDictRegionEntry.cxx.

22  {
23 }

◆ resolve_references()

void IdDictRange::resolve_references ( const IdDictMgr idd,
IdDictDictionary dictionary,
IdDictRegion region 
)
overridevirtual

The range values were unspecified in the range element.

Therefore, the set of values must be obtained from the field definition (if it exists!!).

If the field is undefined, then too bad, this range will be dummy.

Reimplemented from IdDictRegionEntry.

Definition at line 132 of file IdDictRange.cxx.

133  {
134  if (!m_resolved_references) {
135  m_field = dictionary.find_field(m_field_name);
136  if (m_field == nullptr) {
138  dictionary.add_field(m_field);
139  }
140 
141  if (m_specification == unknown) {
151  unsigned int labels = m_field->get_label_number();
152  if (labels == 1) {
154  m_label = m_field->get_label(0);
155  } else if (labels > 1) {
157  for (size_t i = 0; i < labels; ++i) {
158  m_labels.push_back(m_field->get_label(i));
159  }
160  }
161  }
162 
163  if (m_specification == by_label) {
165  } else if (m_specification == by_labels) {
166  m_values.clear();
167  for (size_t i = 0; i < m_labels.size(); ++i) {
168  const std::string& label = m_labels[i];
170  m_values.push_back(value);
171  }
172  }
173  m_resolved_references = true;
174  }
175 }

◆ set_next()

void IdDictRange::set_next ( int  next)

Set next value and adjust continuation mode.

Definition at line 117 of file IdDictRange.cxx.

◆ set_prev()

void IdDictRange::set_prev ( int  prev)

Set previous value and adjust continuation mode.

Definition at line 109 of file IdDictRange.cxx.

110 {
111  m_prev_value = prev;
113 }

◆ set_range() [1/5]

void IdDictRange::set_range ( const std::string &  label)

By label.

Definition at line 68 of file IdDictRange.cxx.

69 {
71  m_label = label;
72 }

◆ set_range() [2/5]

void IdDictRange::set_range ( const std::vector< int > &  values)

By list of values.

Definition at line 93 of file IdDictRange.cxx.

94 {
96  m_values = values;
97 }

◆ set_range() [3/5]

void IdDictRange::set_range ( const std::vector< std::string > &  labels)

By list of labels.

Definition at line 101 of file IdDictRange.cxx.

102 {
104  m_labels = labels;
105 }

◆ set_range() [4/5]

void IdDictRange::set_range ( int  minvalue,
int  maxvalue 
)

By minmax.

Definition at line 84 of file IdDictRange.cxx.

85 {
87  m_minvalue = minvalue;
88  m_maxvalue = maxvalue;
89 }

◆ set_range() [5/5]

void IdDictRange::set_range ( int  value)

By value.

Definition at line 76 of file IdDictRange.cxx.

77 {
79  m_value = value;
80 }

◆ set_wrap_around()

void IdDictRange::set_wrap_around ( )

Enable wraparound.

Definition at line 125 of file IdDictRange.cxx.

126 {
128 }

◆ specification()

IdDictRange::specification_type IdDictRange::specification ( ) const
inline

Definition at line 163 of file IdDictRange.h.

164 {
165  return m_specification;
166 }

◆ values()

const std::vector< int > & IdDictRange::values ( ) const
inline

Definition at line 170 of file IdDictRange.h.

171 {
172  return m_values;
173 }

◆ verify()

bool IdDictRegionEntry::verify ( ) const
virtualinherited

Reimplemented in IdDictDictionaryRef, IdDictRangeRef, and IdDictReference.

Definition at line 25 of file IdDictRegionEntry.cxx.

25  {
26  return(true);
27 }

Member Data Documentation

◆ m_continuation_mode

continuation_mode IdDictRange::m_continuation_mode {none}
private

Definition at line 133 of file IdDictRange.h.

◆ m_field

IdDictField* IdDictRange::m_field {}
private

Definition at line 123 of file IdDictRange.h.

◆ m_field_name

std::string IdDictRange::m_field_name
private

Definition at line 122 of file IdDictRange.h.

◆ m_label

std::string IdDictRange::m_label
private

Definition at line 127 of file IdDictRange.h.

◆ m_labels

std::vector<std::string> IdDictRange::m_labels
private

Definition at line 134 of file IdDictRange.h.

◆ m_maxvalue

int IdDictRange::m_maxvalue {}
private

Definition at line 130 of file IdDictRange.h.

◆ m_minvalue

int IdDictRange::m_minvalue {}
private

Definition at line 129 of file IdDictRange.h.

◆ m_next_value

int IdDictRange::m_next_value {}
private

Definition at line 132 of file IdDictRange.h.

◆ m_prev_value

int IdDictRange::m_prev_value {}
private

Definition at line 131 of file IdDictRange.h.

◆ m_resolved_references

bool IdDictRange::m_resolved_references {}
private

Definition at line 137 of file IdDictRange.h.

◆ m_specification

specification_type IdDictRange::m_specification {unknown}
private

Definition at line 125 of file IdDictRange.h.

◆ m_tag

std::string IdDictRange::m_tag
private

Definition at line 126 of file IdDictRange.h.

◆ m_value

int IdDictRange::m_value {}
private

Definition at line 128 of file IdDictRange.h.

◆ m_values

std::vector<int> IdDictRange::m_values
private

Definition at line 135 of file IdDictRange.h.


The documentation for this class was generated from the following files:
IdDictField::set_index
void set_index(size_t index)
Definition: IdDictField.cxx:38
IdDictField::get_label
const std::string & get_label(size_t index) const
Definition: IdDictField.cxx:48
get_generator_info.result
result
Definition: get_generator_info.py:21
IdDictRange::by_minmax
@ by_minmax
Definition: IdDictRange.h:26
index
Definition: index.py:1
IdDictRange::by_label
@ by_label
Definition: IdDictRange.h:24
IdDictRange::m_field_name
std::string m_field_name
Definition: IdDictRange.h:122
IdDictRange::by_labels
@ by_labels
Definition: IdDictRange.h:25
athena.value
value
Definition: athena.py:124
IdDictRange::none
@ none
Definition: IdDictRange.h:29
IdDictRange::m_specification
specification_type m_specification
Definition: IdDictRange.h:125
IdDictField::index
size_t index() const
Definition: IdDictField.h:67
IdDictRegion::tag
const std::string & tag() const
Definition: IdDictRegion.h:161
IdDictRange::field
const IdDictField * field() const
Definition: IdDictRange.h:156
IdDictRegion::new_implementation
IdDictFieldImplementation & new_implementation()
Add a new implementation object and return a reference to it.
Definition: IdDictRegion.cxx:65
IdDictRange::m_field
IdDictField * m_field
Definition: IdDictRange.h:123
IdDictRange::has_previous
@ has_previous
Definition: IdDictRange.h:31
IdDictRange::m_maxvalue
int m_maxvalue
Definition: IdDictRange.h:130
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdDictRange::values
const std::vector< int > & values() const
Definition: IdDictRange.h:170
IdDictRange::has_both
@ has_both
Definition: IdDictRange.h:32
IdDictRange::m_prev_value
int m_prev_value
Definition: IdDictRange.h:131
IdDictField::get_label_number
size_t get_label_number() const
Definition: IdDictField.cxx:43
IdDictRegion::fieldSize
size_t fieldSize() const
Definition: IdDictRegion.cxx:236
IdDictRange::unknown
@ unknown
Definition: IdDictRange.h:21
IdDictRange::m_value
int m_value
Definition: IdDictRange.h:128
IdDictRange::label
const std::string & label() const
Definition: IdDictRange.h:149
Debugger::debug
static bool debug()
Definition: Debugger.h:18
IdDictRegion::n_implementation
size_t n_implementation() const
Definition: IdDictRegion.cxx:28
IdDictField::get_label_value
ExpandedIdentifier::element_type get_label_value(const std::string &name) const
Definition: IdDictField.cxx:58
master.dictionary
dictionary
Definition: master.py:47
IdDictRange::m_labels
std::vector< std::string > m_labels
Definition: IdDictRange.h:134
IdDictRange::has_next
@ has_next
Definition: IdDictRange.h:30
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:29
IdDictRange::m_continuation_mode
continuation_mode m_continuation_mode
Definition: IdDictRange.h:133
IdDictRange::set_range
void set_range(const std::string &label)
By label.
Definition: IdDictRange.cxx:68
impl
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:46
IdDictRange::labels
const std::vector< std::string > & labels() const
Definition: IdDictRange.h:177
DeMoScan.index
string index
Definition: DeMoScan.py:362
IdDictRange::m_resolved_references
bool m_resolved_references
Definition: IdDictRange.h:137
IdentifierField
This is the individual specification for the range of one ExpandedIdentifier IdentifierField.
Definition: IdentifierField.h:83
IdDictRange::by_values
@ by_values
Definition: IdDictRange.h:23
IdDictRegion::index
size_t index() const
Definition: IdDictRegion.h:168
IdDictRange::m_label
std::string m_label
Definition: IdDictRange.h:127
IdDictRange::by_value
@ by_value
Definition: IdDictRange.h:22
IdDictField
Definition: IdDictField.h:15
IdDictRange::wrap_around
@ wrap_around
Definition: IdDictRange.h:33
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdDictRange::field_name
const std::string & field_name() const
Definition: IdDictRange.h:142
IdDictRange::m_minvalue
int m_minvalue
Definition: IdDictRange.h:129
IdDictRegion::group_name
virtual std::string group_name() const override
Definition: IdDictRegion.cxx:23
IdDictRange::m_next_value
int m_next_value
Definition: IdDictRange.h:132
IdDictRange::m_values
std::vector< int > m_values
Definition: IdDictRange.h:135