ATLAS Offline Software
Loading...
Searching...
No Matches
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.
 IdDictRange (const std::string &field_name, const std::string &label)
 By label.
 IdDictRange (const std::string &field_name, int value)
 By value.
 IdDictRange (const std::string &field_name, int minvalue, int maxvalue)
 By minmax.
 IdDictRange (const std::string &field_name, const std::vector< int > &values)
 By list of values.
 IdDictRange (const std::string &field_name, const std::vector< std::string > &labels)
 By list of labels.
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.
void set_range (int value)
 By value.
void set_range (int minvalue, int maxvalue)
 By minmax.
void set_range (const std::vector< int > &values)
 By list of values.
void set_range (const std::vector< std::string > &labels)
 By list of labels.
void set_prev (int prev)
 Set previous value and adjust continuation mode.
void set_next (int next)
 Set next value and adjust continuation mode.
void set_wrap_around ()
 Enable wraparound.
virtual void resolve_references (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.

◆ specification_type

Enumerator
unknown 
by_value 
by_values 
by_label 
by_labels 
by_minmax 

Definition at line 20 of file IdDictRange.h.

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}
const std::string & field_name() const
std::string m_field_name

◆ 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{
28}
const std::string & label() const
void set_range(const std::string &label)
By label.

◆ 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{
55}
const std::vector< int > & values() const

◆ 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{
64}
const std::vector< std::string > & labels() const

◆ ~IdDictRange()

virtual IdDictRange::~IdDictRange ( )
virtualdefault

Member Function Documentation

◆ build_range()

Range IdDictRange::build_range ( ) const
overridevirtual

Implements IdDictRegionEntry.

Definition at line 237 of file IdDictRange.cxx.

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

◆ 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}
IdDictField * m_field

◆ 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 177 of file IdDictRange.cxx.

178 {
179 // Add IdDictFieldImplementation to this region
180
181 // NOTE: we DO NOT protect this method with
182 // m_generated_implementation because the same object may be
183 // called more than once because there are IdDictRangeRef's which
184 // point to the same IdDictRange's.
185
186 if (Debugger::debug()) {
187 std::cout << "IdDictRange::generate_implementation>" << std::endl;
188 }
189
190 IdDictFieldImplementation& impl = region.new_implementation();
191 impl.set_range(this);
192 if (m_field->index() == 0) {
193 m_field->set_index(region.fieldSize() - 1);
194 } else if (m_field->index() != (region.fieldSize() - 1)) {
195 std::cout << "Bad field index for " << m_field_name
196 << " index " << m_field->index()
197 << " in dictionary " << dictionary.name()
198 << " region #" << region.index()
199 << " group " << region.group_name()
200 << " tag " << region.tag()
201 << " size " << (region.n_implementation() - 1)
202 << std::endl;
203 }
204
205 size_t index = region.n_implementation() - 1;
206 if (region.n_implementation() <= index) {
207 std::cout << "IdDictRange::generate_implementation: index >= impl size - "
208 << index << " " << region.fieldSize()
209 << std::endl;
210 return;
211 }
212
214 switch (m_specification) {
215 case by_value:
216 case by_label: {
218 break;
219 }
220
221 case by_values:
222 case by_labels: {
224 }
225 break;
226
227 case by_minmax:
229 break;
230
231 case unknown:
232 break;
233 }
234}
static bool debug()
Definition Debugger.h:18
void set_range(const IdDictRange *range)
Modifiers.
void set_field(const Range::field &field)
virtual std::string group_name() const override
IdDictFieldImplementation & new_implementation()
Add a new implementation object and return a reference to it.
size_t fieldSize() const
const std::string & tag() const
size_t index() const
size_t n_implementation() const
str index
Definition DeMoScan.py:362
dictionary
Definition master.py:47

◆ label()

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

Definition at line 149 of file IdDictRange.h.

150{
151 return m_label;
152}
std::string m_label

◆ labels()

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

Definition at line 177 of file IdDictRange.h.

178{
179 return m_labels;
180}
std::vector< std::string > m_labels

◆ 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 ( 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 {
135 m_field = dictionary.find_field(m_field_name);
136 if (m_field == nullptr) {
137 m_field = dictionary.add_field(std::make_unique<IdDictField> (m_field_name));
138 }
139
140 if (m_specification == unknown) {
150 unsigned int labels = m_field->get_label_number();
151 if (labels == 1) {
153 m_label = m_field->get_label(0);
154 } else if (labels > 1) {
156 for (size_t i = 0; i < labels; ++i) {
157 m_labels.push_back(m_field->get_label(i));
158 }
159 }
160 }
161
162 if (m_specification == by_label) {
163 m_value = m_field->get_label_value(m_label);
164 } else if (m_specification == by_labels) {
165 m_values.clear();
166 for (size_t i = 0; i < m_labels.size(); ++i) {
167 const std::string& label = m_labels[i];
168 int value = m_field->get_label_value(label);
169 m_values.push_back(value);
170 }
171 }
173 }
174}
bool m_resolved_references

◆ 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.

◆ 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.

◆ 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{
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.

133{none};

◆ m_field

IdDictField* IdDictRange::m_field {}
private

Definition at line 123 of file IdDictRange.h.

123{};

◆ 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.

130{};

◆ m_minvalue

int IdDictRange::m_minvalue {}
private

Definition at line 129 of file IdDictRange.h.

129{};

◆ m_next_value

int IdDictRange::m_next_value {}
private

Definition at line 132 of file IdDictRange.h.

132{};

◆ m_prev_value

int IdDictRange::m_prev_value {}
private

Definition at line 131 of file IdDictRange.h.

131{};

◆ m_resolved_references

bool IdDictRange::m_resolved_references {}
private

Definition at line 137 of file IdDictRange.h.

137{};

◆ m_specification

specification_type IdDictRange::m_specification {unknown}
private

Definition at line 125 of file IdDictRange.h.

125{unknown};

◆ 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.

128{};

◆ 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: