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

This is the individual specification for the range of one ExpandedIdentifier field. More...

#include <Range.h>

Collaboration diagram for Range::field:

Public Types

enum  mode {
  unbounded, low_bounded, high_bounded, both_bounded,
  enumerated
}
 Characterizes the four possible modes of any field specification. More...
 
enum  continuation_mode {
  none, has_next, has_previous, has_both,
  has_wrap_around
}
 
typedef std::vector< element_typeelement_vector
 
typedef std::vector< size_typeindex_vector
 

Public Member Functions

 field ()
 Create a wild-card value. More...
 
 field (const field &other)
 Create a field copy. More...
 
 field (field &&other)
 Move constructor. More...
 
 field (element_type value)
 Create a unique value (understood as : low bound = high bound = value) More...
 
 field (element_type minimum, element_type maximum)
 Create a full range specification (with explicit min and max) More...
 
bool is_valued () const
 Some combined query functions on the specification mode. More...
 
bool has_minimum () const
 
bool has_maximum () const
 
bool wrap_around () const
 
mode get_mode () const
 Query the values. More...
 
element_type get_minimum () const
 
element_type get_maximum () const
 
const element_vectorget_values () const
 
bool get_previous (element_type current, element_type &previous) const
 Returns false if previous/next is at end of range, or not possible. More...
 
bool get_next (element_type current, element_type &next) const
 
size_type get_indices () const
 
index_vector get_indexes () const
 
size_type get_bits () const
 
element_type get_value_at (size_type index) const
 
size_type get_value_index (element_type value) const
 
bool match_any () const
 Check if this is a pure wild card field. More...
 
bool match (element_type value) const
 The basic match operation. More...
 
bool overlaps_with (const field &other) const
 Check whether two fields overlap. More...
 
void clear ()
 Set methods. More...
 
void set (element_type minimum, element_type maximum)
 
void set_minimum (element_type value)
 
void set_maximum (element_type value)
 
void add_value (element_type value)
 
void set (const element_vector &values)
 
void set (bool wraparound)
 
void set_next (int next)
 
void set_previous (int previous)
 
fieldoperator= (const field &other)
 
void operator|= (const field &other)
 
 operator std::string () const
 
bool operator== (const field &other) const
 
bool operator!= (const field &other) const
 
void show () const
 
void optimize ()
 Optimize - try to switch mode to both_bounded, set up lookup table for finding index from value. More...
 

Private Types

enum  max_values { max_indexes = 100 }
 

Private Member Functions

void check_for_both_bounded ()
 Check mode - switch from enumerated to both_bounded if possible. More...
 
void create_index_table ()
 Create index table from value table. More...
 
void set_indices ()
 Set m_indices. More...
 

Private Attributes

element_type m_minimum
 
element_type m_maximum
 
element_vector m_values
 
index_vector m_indexes
 
size_type m_indices
 
element_type m_previous
 
element_type m_next
 
mode m_mode
 
continuation_mode m_continuation_mode
 

Detailed Description

This is the individual specification for the range of one ExpandedIdentifier field.


Definition at line 36 of file DetectorDescription/Identifier/Identifier/Range.h.

Member Typedef Documentation

◆ element_vector

◆ index_vector

typedef std::vector<size_type> Range::field::index_vector

Member Enumeration Documentation

◆ continuation_mode

Enumerator
none 
has_next 
has_previous 
has_both 
has_wrap_around 

Definition at line 52 of file DetectorDescription/Identifier/Identifier/Range.h.

53  {
54  none,
55  has_next,
56  has_previous,
57  has_both,

◆ max_values

Enumerator
max_indexes 

Definition at line 133 of file DetectorDescription/Identifier/Identifier/Range.h.

134  {
135  max_indexes = 100
136  } max_values;

◆ mode

Characterizes the four possible modes of any field specification.

Enumerator
unbounded 
low_bounded 
high_bounded 
both_bounded 
enumerated 

Definition at line 43 of file DetectorDescription/Identifier/Identifier/Range.h.

44  {
45  unbounded,
46  low_bounded,
47  high_bounded,
48  both_bounded,
49  enumerated
50  } mode;

Constructor & Destructor Documentation

◆ field() [1/5]

Range::field::field ( )

Create a wild-card value.

Definition at line 317 of file DetectorDescription/Identifier/src/Range.cxx.

318  :
319  m_minimum(0),
320  m_maximum(0),
321  m_indices(0),
322  m_previous(0),
323  m_next(0),
324  m_mode(unbounded),
326 {
327 }

◆ field() [2/5]

Range::field::field ( const field other)

Create a field copy.

Definition at line 330 of file DetectorDescription/Identifier/src/Range.cxx.

331  : m_minimum (other.m_minimum),
332  m_maximum (other.m_maximum),
333  m_values (other.m_values),
334  m_indexes (other.m_indexes),
335  m_indices (other.m_indices),
336  m_previous (other.m_previous),
337  m_next (other.m_next),
338  m_mode (other.m_mode),
339  m_continuation_mode (other.m_continuation_mode)
340 {
341 }

◆ field() [3/5]

Range::field::field ( field &&  other)

Move constructor.

Definition at line 344 of file DetectorDescription/Identifier/src/Range.cxx.

345 {
346  m_minimum = other.m_minimum;
347  m_maximum = other.m_maximum;
348  m_values.swap (other.m_values);
349  m_indexes.swap (other.m_indexes);
350  m_indices = other.m_indices;
351  m_previous = other.m_previous;
352  m_next = other.m_next;
353  m_mode = other.m_mode;
354  m_continuation_mode = other.m_continuation_mode;
355 
356 }

◆ field() [4/5]

Range::field::field ( element_type  value)

Create a unique value (understood as : low bound = high bound = value)

Definition at line 359 of file DetectorDescription/Identifier/src/Range.cxx.

360  :
361  m_minimum(value),
362  m_maximum(value),
363  m_indices(0),
364  m_previous(0),
365  m_next(0),
368 {}

◆ field() [5/5]

Range::field::field ( element_type  minimum,
element_type  maximum 
)

Create a full range specification (with explicit min and max)

Definition at line 371 of file DetectorDescription/Identifier/src/Range.cxx.

372  :
373  m_indices(0),
374  m_previous(0),
375  m_next(0),
378 {
379  set (minimum, maximum);
380  set_indices();
381 }

Member Function Documentation

◆ add_value()

void Range::field::add_value ( element_type  value)

Definition at line 729 of file DetectorDescription/Identifier/src/Range.cxx.

730 {
731  if (m_mode == low_bounded)
732  {
733  m_values.clear ();
734  m_values.push_back (m_minimum);
735  m_maximum = m_minimum;
736  m_mode = enumerated;
737  }
738  else if (m_mode != enumerated)
739  {
740  m_values.clear ();
741  m_mode = enumerated;
742  }
743 
744  for (size_type i = 0; i < m_values.size (); ++i)
745  {
746  if (m_values[i] == value) return;
747  }
748 
749  m_values.push_back (value);
750  std::sort (m_values.begin (), m_values.end());
751 
752  m_minimum = m_values[0];
753  m_maximum = m_values[m_values.size () - 1];
754 
755  set_indices();
756 }

◆ check_for_both_bounded()

void Range::field::check_for_both_bounded ( )
private

Check mode - switch from enumerated to both_bounded if possible.

Definition at line 1119 of file DetectorDescription/Identifier/src/Range.cxx.

1120 {
1121  if (m_mode == enumerated && !m_values.empty()) {
1122  element_type last = m_values[0];
1123  for (size_type i = 1; i < m_values.size (); ++i) {
1124  if (m_values[i] > last + 1) return;
1125  last = m_values[i];
1126  }
1127 
1128  // Is both bounded - swith mode
1129  m_minimum = m_values[0];
1130  m_maximum = m_values[m_values.size() - 1];
1131 
1132 // for (size_type i = 0; i < m_values.size (); ++i) {
1133 // std::cout << m_values[i] << " ";
1134 // }
1135 // std::cout << " min/max " << m_minimum << " " << m_maximum << std::endl;
1136 
1137  m_mode = both_bounded;
1138  m_values.clear ();
1139  }
1140 }

◆ clear()

void Range::field::clear ( )

Set methods.

Definition at line 653 of file DetectorDescription/Identifier/src/Range.cxx.

654 {
655  m_minimum = 0;
656  m_maximum = 0;
657  m_previous = 0;
658  m_next = 0;
660  m_mode = unbounded;
661  m_values.clear ();
662 }

◆ create_index_table()

void Range::field::create_index_table ( )
private

Create index table from value table.

Create index table from value table

Definition at line 1143 of file DetectorDescription/Identifier/src/Range.cxx.

1144 {
1146  if (m_mode == enumerated && !m_values.empty()) {
1148  // return if we are over the maximum desired vector table size
1149  if (size > max_indexes) {
1150  m_indexes.clear();
1151  return;
1152  }
1153  // Set up vectors for decoding
1154  m_indexes = std::vector<size_type>(size, 0);
1155  size_type index = 0;
1156  for (size_type i = 0; i < m_values.size(); ++i) {
1157  if ((m_values[i]- m_minimum) < (int)size) {
1159  index++;
1160  }
1161  else {
1162  std::cout << "size, value, index, i "
1163  << size << " " << m_values[i] << " "
1164  << index << " " << i << " min, max "
1165  << m_minimum << " "
1166  << m_maximum
1167  << std::endl;
1168  }
1169  }
1170  }
1171 }

◆ get_bits()

ExpandedIdentifier::size_type Range::field::get_bits ( ) const
inline

Definition at line 560 of file DetectorDescription/Identifier/Identifier/Range.h.

562 {
564 
565  size_t indices = get_indices ();
566 
567  indices--;
568  if (indices > 0)
569  {
570  result = 0;
571  while (indices > 0)
572  {
573  indices /= 2;
574  result++;
575  }
576  }
577 
578  return (result);
579 }

◆ get_indexes()

Range::field::index_vector Range::field::get_indexes ( ) const
inline

Definition at line 552 of file DetectorDescription/Identifier/Identifier/Range.h.

554 {
555  return (m_indexes);
556 }

◆ get_indices()

ExpandedIdentifier::size_type Range::field::get_indices ( ) const
inline

Definition at line 545 of file DetectorDescription/Identifier/Identifier/Range.h.

547 {
548  return (m_indices);
549 }

◆ get_maximum()

Range::element_type Range::field::get_maximum ( ) const
inline

Definition at line 531 of file DetectorDescription/Identifier/Identifier/Range.h.

533 {
534  return (m_maximum);
535 }

◆ get_minimum()

Range::element_type Range::field::get_minimum ( ) const
inline

Definition at line 524 of file DetectorDescription/Identifier/Identifier/Range.h.

526 {
527  return (m_minimum);
528 }

◆ get_mode()

Range::field::mode Range::field::get_mode ( ) const
inline

Query the values.

Definition at line 517 of file DetectorDescription/Identifier/Identifier/Range.h.

519 {
520  return (m_mode);
521 }

◆ get_next()

bool Range::field::get_next ( element_type  current,
element_type next 
) const

Definition at line 479 of file DetectorDescription/Identifier/src/Range.cxx.

480 {
481  switch (m_mode)
482  {
483  case unbounded:
484  next = current + 1;
485  if (current == std::numeric_limits<element_type>::max()) return (false);
486  return (true);
487  break;
488  case low_bounded:
489  next = current + 1;
490  if (current == std::numeric_limits<element_type>::max()) return (false);
491  return (true);
492  break;
493  case high_bounded:
494  if (current == m_maximum) {
495  next = current;
496  return (false);
497  }
498  next = current + 1;
499  return (true);
500  break;
501  case both_bounded:
502  if (current == m_maximum) {
504  next = m_minimum;
505  return (true);
506  }
507  if (has_next == m_continuation_mode) {
508  next = m_next;
509  return (true);
510  }
511  next = current;
512  return (false);
513  }
514  next = current + 1;
515  return (true);
516  break;
517  case enumerated:
519  if ((index == m_values.size() - 1) ||
520  (index == 0 && current != m_values[0])) {
522  next = m_values[0];
523  return (true);
524  }
525  if (has_next == m_continuation_mode) {
526  next = m_next;
527  return (true);
528  }
529  next = current;
530  return (false);
531  }
532  ++index;
533  next = m_values[index];
534  return (true);
535  break;
536  }
537 
538  return (false);
539 }

◆ get_previous()

bool Range::field::get_previous ( element_type  current,
element_type previous 
) const

Returns false if previous/next is at end of range, or not possible.

Definition at line 414 of file DetectorDescription/Identifier/src/Range.cxx.

415 {
416  switch (m_mode)
417  {
418  case unbounded:
419  previous = current - 1;
420  if (current == std::numeric_limits<element_type>::min()) return (false);
421  return (true);
422  break;
423  case low_bounded:
424  if (current == m_minimum) {
425  previous = current;
426  return (false);
427  }
428  previous = current - 1;
429  return (true);
430  break;
431  case high_bounded:
432  previous = current - 1;
433  if (current == std::numeric_limits<element_type>::min()) return (false);
434  return (true);
435  break;
436  case both_bounded:
437  if (current == m_minimum) {
440  return (true);
441  }
444  return (true);
445  }
446  previous = current;
447  return (false);
448  }
449  previous = current - 1;
450  return (true);
451  break;
452  case enumerated:
454  if (index == 0) {
455  if (has_wrap_around == m_continuation_mode && !m_values.empty()) {
456  index = m_values.size() - 1;
458  return (true);
459  }
462  return (true);
463  }
464  previous = current;
465  return (false);
466  }
467  --index;
469  return (true);
470  break;
471  }
472 
473  return (false);
474 }

◆ get_value_at()

Range::element_type Range::field::get_value_at ( size_type  index) const
inline

Definition at line 583 of file DetectorDescription/Identifier/Identifier/Range.h.

585 {
586  // Only both_bounded and enumerated are valid to calculate the
587  // value.
588  // both_bounded if the more frequent case and so comes first.
589 
590  if (both_bounded == m_mode) {
591  if (index >= (size_type) (m_maximum - m_minimum + 1)) {
592  throw std::out_of_range("Range::field::get_value_at");
593  }
594  return (m_minimum + index);
595 // if (index >= (size_type) (m_maximum - m_minimum + 1)) return (0);
596 // else return (m_minimum + index);
597  }
598  else if (enumerated == m_mode) {
599  return (m_values.at(index));
600 // if (index >= m_values.size ()) return (0);
601 // else return (m_values[index]);
602  }
603 
604  return (0);
605 }

◆ get_value_index()

ExpandedIdentifier::size_type Range::field::get_value_index ( element_type  value) const
inline

Definition at line 609 of file DetectorDescription/Identifier/Identifier/Range.h.

611 {
612 
613  // Only both_bounded and enumerated are valid to calculate the
614  // index.
615  // both_bounded if the more frequent case and so comes first.
616 
617  if (both_bounded == m_mode) {
618 // if ((value >= m_minimum) &&
619 // (value <= m_maximum)) {
620  return (value - m_minimum);
621 // }
622  }
623  else if (enumerated == m_mode) {
624 // if ((int)m_indexes.size() > ((int)value - (int)m_minimum)) {
625  if (m_indexes.size()) {
626  // Table has been created, do simple lookup
627  assert (value >= m_minimum && value - m_minimum < (int)m_indexes.size());
628  return (m_indexes.at(value - m_minimum));
629  }
630  else {
631  for (size_type i = 0; i < m_values.size (); ++i) {
632  if (m_values[i] == value) return (i);
633  }
634  }
635  }
636 
637  return (0);
638 }

◆ get_values()

const Range::field::element_vector & Range::field::get_values ( ) const
inline

Definition at line 538 of file DetectorDescription/Identifier/Identifier/Range.h.

540 {
541  return (m_values);
542 }

◆ has_maximum()

bool Range::field::has_maximum ( ) const

Definition at line 398 of file DetectorDescription/Identifier/src/Range.cxx.

399 {
400  return ((m_mode == high_bounded) ||
401  (m_mode == both_bounded) ||
402  (m_mode == enumerated));
403 }

◆ has_minimum()

bool Range::field::has_minimum ( ) const

Definition at line 390 of file DetectorDescription/Identifier/src/Range.cxx.

391 {
392  return ((m_mode == low_bounded) ||
393  (m_mode == both_bounded) ||
394  (m_mode == enumerated));
395 }

◆ is_valued()

bool Range::field::is_valued ( ) const

Some combined query functions on the specification mode.

Definition at line 384 of file DetectorDescription/Identifier/src/Range.cxx.

385 {
386  return (m_mode != unbounded);
387 }

◆ match()

bool Range::field::match ( element_type  value) const
inline

The basic match operation.

Definition at line 641 of file DetectorDescription/Identifier/Identifier/Range.h.

643 {
644  size_t i;
645 
646  if (both_bounded == m_mode) {
647  return ((value >= m_minimum) &&
648  (value <= m_maximum));
649  }
650  else if (enumerated == m_mode) {
651  for (i = 0; i < m_values.size (); ++i) {
652  if (value == m_values[i]) return (true);
653  }
654  return (false);
655  }
656  else if (unbounded == m_mode) {
657  return (true);
658  }
659  else if (high_bounded == m_mode) {
660  return (value <= m_maximum);
661  }
662  else if (low_bounded == m_mode) {
663  return (value >= m_minimum);
664  }
665  return (false);
666 }

◆ match_any()

bool Range::field::match_any ( ) const

Check if this is a pure wild card field.

Definition at line 542 of file DetectorDescription/Identifier/src/Range.cxx.

543 {
544  if (m_mode == unbounded) return (true);
545 
546  return (false);
547 }

◆ operator std::string()

Range::field::operator std::string ( ) const

Definition at line 959 of file DetectorDescription/Identifier/src/Range.cxx.

960 {
961  std::string result;
962  char temp[20];
963 
964  if (!is_valued ())
965  {
966  result += "*";
967  }
968  else
969  {
972 
973  if (!has_maximum ())
974  {
975  sprintf (temp, "%d", minimum);
976  result += temp;
977  result += ":";
978  }
979  else if (!has_minimum ())
980  {
981  sprintf (temp, "%d", maximum);
982  result += ":";
983  result += temp;
984  }
985  else if (minimum == maximum)
986  {
987  sprintf (temp, "%d", minimum);
988  result += temp;
989  }
990  else
991  {
992  if (get_mode () == field::enumerated)
993  {
994  for (size_type i = 0; i < get_indices (); ++i)
995  {
996  if (i > 0) result += ",";
997  sprintf (temp, "%d", get_value_at (i));
998  result += temp;
999  }
1000  }
1001  else
1002  {
1003  sprintf (temp, "%d", minimum);
1004  result += temp;
1005  sprintf (temp, "%d", maximum);
1006  result += ":";
1007  result += temp;
1008  }
1009  }
1010  }
1011 
1012  return (result);
1013 }

◆ operator!=()

bool Range::field::operator!= ( const field other) const

Definition at line 1028 of file DetectorDescription/Identifier/src/Range.cxx.

1029 {
1030  return (!((*this) == other));
1031 }

◆ operator=()

Range::field & Range::field::operator= ( const field other)

Definition at line 809 of file DetectorDescription/Identifier/src/Range.cxx.

810 {
811  if (this != &other) {
812  m_minimum = other.m_minimum;
813  m_maximum = other.m_maximum;
814  m_values = other.m_values;
815  m_indexes = other.m_indexes;
816  m_indices = other.m_indices;
817  m_previous = other.m_previous;
818  m_next = other.m_next;
819  m_mode = other.m_mode;
820  m_continuation_mode = other.m_continuation_mode;
821  }
822 
823  return (*this);
824 }

◆ operator==()

bool Range::field::operator== ( const field other) const

Definition at line 1017 of file DetectorDescription/Identifier/src/Range.cxx.

1018 {
1019  if (m_mode != other.m_mode) return false;
1020  if (m_minimum != other.m_minimum) return false;
1021  if (m_maximum != other.m_maximum) return false;
1022  if (m_values != other.m_values) return false;
1023  return (true);
1024 }

◆ operator|=()

void Range::field::operator|= ( const field other)

If there is no overlap we should build a multi-segment specification. The current algorithm is only correct if the overlap in not empty !! A multi-segment specification might also be implemented as an expanded enumerated set (not very optimized !!)

If there is no overlap we should build a multi-segment specification. The current algorithm is only correct if the overlap in not empty !!

(in addition, the expanded solution - to enumerated - is not possible due to the unbounded nature of this mode)

If there is no overlap we should build a multi-segment specification. The current algorithm is only correct if the overlap in not empty !!

(in addition, the expanded solution - to enumerated - is not possible due to the unbounded nature of this mode)

Definition at line 827 of file DetectorDescription/Identifier/src/Range.cxx.

828 {
829  mode other_mode = other.get_mode ();
830 
831  if (m_mode == other_mode)
832  {
833  /*
834  x . . . .
835  . x . . .
836  . . x . .
837  . . . x .
838  . . . . x
839  */
840  switch (m_mode)
841  {
842  case unbounded:
843  break;
844  case high_bounded:
845  if (other.get_maximum () > m_maximum) m_maximum = other.get_maximum ();
846  break;
847  case low_bounded:
848  if (other.get_minimum () < m_minimum) m_minimum = other.get_minimum ();
849  break;
850  case enumerated:
851  {
852  const element_vector& ev = other.get_values ();
853 
854  for (size_t i = 0; i < ev.size (); ++i)
855  {
856  add_value (ev[i]);
857  }
858  }
859  break;
860  default: // both_bounded
867  if (other.get_maximum () > m_maximum) m_maximum = other.get_maximum ();
868  if (other.get_minimum () < m_minimum) m_minimum = other.get_minimum ();
869 
870  break;
871  }
872  }
873  else if ((m_mode == unbounded) || (other_mode == unbounded))
874  {
875  /*
876  o x x x x
877  x o . . .
878  x . o . .
879  x . . o .
880  x . . . o
881  */
882  clear ();
883  }
884  else if ((m_mode == low_bounded) && (other_mode == high_bounded))
885  {
895  /*
896  o o o o o
897  o o x . .
898  o . o . .
899  o . . o .
900  o . . . o
901  */
902  clear ();
903  }
904  else if ((m_mode == high_bounded) && (other_mode == low_bounded))
905  {
915  /*
916  o o o o o
917  o o o . .
918  o x o . .
919  o . . o .
920  o . . . o
921  */
922  clear ();
923  }
924  else
925  {
926  // all other cases...
927 
928  if (has_minimum () && other.has_minimum ())
929  {
930  /*
931  o o o o o
932  o o o x x
933  o o o . .
934  o x . o x
935  o x . x o
936  */
937 
938  if (other.get_minimum () < m_minimum) set_minimum (other.get_minimum ());
939  }
940 
941  if (has_maximum () && other.has_maximum ())
942  {
943  /*
944  o o o o o
945  o o o . .
946  o o o x x
947  o . x o x
948  o . x x o
949  */
950 
951  if (other.get_maximum () > m_maximum) set_maximum (other.get_maximum ());
952  }
953  }
954 
955  set_indices();
956 }

◆ optimize()

void Range::field::optimize ( )

Optimize - try to switch mode to both_bounded, set up lookup table for finding index from value.

Check mode - switch from enumerated to both_bounded if possible

Create index table from value table

Definition at line 1094 of file DetectorDescription/Identifier/src/Range.cxx.

1095 {
1096 
1099 
1102 
1103 }

◆ overlaps_with()

bool Range::field::overlaps_with ( const field other) const

Check whether two fields overlap.

Definition at line 551 of file DetectorDescription/Identifier/src/Range.cxx.

552 {
553  typedef enum
554  {
555  done,
556  min_max,
557  max_min,
558  both,
559  both_and_enum,
560  enum_and_both,
561  all_values
562  } check_type;
563 
564  static const check_type check_needed[5][5] =
565  {
566  {done, done, done, done, done},
567  {done, done, min_max, min_max, min_max},
568  {done, max_min, done, max_min, max_min},
569  {done, max_min, min_max, both, both_and_enum},
570  {done, max_min, min_max, enum_and_both, all_values}
571  };
572 
573  mode other_mode = other.get_mode ();
574 
575  switch (check_needed [m_mode][other_mode])
576  {
577  case done:
578  return (true);
579  case min_max:
580  if (m_minimum <= other.get_maximum ()) return (true);
581  break;
582  case max_min:
583  if (m_maximum >= other.get_minimum ()) return (true);
584  break;
585  case both:
586  if ((m_minimum <= other.get_maximum ()) &&
587  (m_maximum >= other.get_minimum ()))
588  {
589  return (true);
590  }
591  break;
592  case both_and_enum: // this is both_bounded while other is enumerated
593  if ((m_minimum <= other.get_maximum ()) &&
594  (m_maximum >= other.get_minimum ()))
595  {
596  // Check if this(bb) is entirely within other(enum).
597  if ((m_minimum > other.get_minimum ()) &&
598  (m_maximum < other.get_maximum ()))
599  {
600  const element_vector& ev = other.get_values ();
601  for (size_t i = 0; i < ev.size (); ++i)
602  {
603  element_type v = ev[i];
604  if ((v < m_minimum) || (v > m_maximum)) return (false);
605  }
606  }
607 
608  return (true);
609  }
610  break;
611  case enum_and_both: // this is enumerated while other is both_bounded
612  if ((m_minimum <= other.get_maximum ()) &&
613  (m_maximum >= other.get_minimum ()))
614  {
615  // Check if other(bb) is entirely within this(enum).
616  if ((other.get_minimum () > m_minimum) &&
617  (other.get_maximum () < m_maximum))
618  {
619  const element_vector& ev = get_values ();
620  for (size_t i = 0; i < ev.size (); ++i)
621  {
622  element_type v = ev[i];
623  if ((v < other.get_minimum ()) || (v > other.get_maximum ())) return (false);
624  }
625  }
626 
627  return (true);
628  }
629  break;
630  case all_values:
631  // Both fields are enumerated only if there is possibility of overlap
632  if ((m_minimum <= other.get_maximum ()) &&
633  (m_maximum >= other.get_minimum ()))
634  {
635  const element_vector& ev = other.get_values ();
636  for (size_t i = 0; i < m_values.size (); ++i)
637  {
638  element_type v = m_values[i];
639  for (size_t j = 0; j < ev.size (); ++j)
640  {
641  if (v == ev[j]) return (true);
642  }
643  }
644  }
645  break;
646  }
647 
648  return (false);
649 }

◆ set() [1/3]

void Range::field::set ( bool  wraparound)

Definition at line 776 of file DetectorDescription/Identifier/src/Range.cxx.

777 {
778  if (wraparound) {
780  }
781 }

◆ set() [2/3]

void Range::field::set ( const element_vector values)

◆ set() [3/3]

void Range::field::set ( element_type  minimum,
element_type  maximum 
)

Definition at line 665 of file DetectorDescription/Identifier/src/Range.cxx.

666 {
667  m_values.clear ();
668 
669  if (minimum == maximum)
670  {
671  add_value (minimum);
672  }
673  else
674  {
677 
678  m_mode = both_bounded;
679  }
680 
681  set_indices();
682 }

◆ set_indices()

void Range::field::set_indices ( )
private

Set m_indices.

Set the number of indices

Definition at line 1106 of file DetectorDescription/Identifier/src/Range.cxx.

1107 {
1109  m_indices = 1;
1110  if (m_mode == both_bounded) {
1111  m_indices = m_maximum - m_minimum + 1;
1112  }
1113  else if (m_mode == enumerated) {
1114  m_indices = m_values.size ();
1115  }
1116 }

◆ set_maximum()

void Range::field::set_maximum ( element_type  value)

Definition at line 707 of file DetectorDescription/Identifier/src/Range.cxx.

708 {
709  if (m_mode == unbounded)
710  {
711  m_mode = high_bounded;
712  m_maximum = value;
713  }
714  else if ((m_mode == low_bounded) ||
715  (m_mode == both_bounded) ||
716  (m_mode == enumerated))
717  {
718  set (get_minimum (), value);
719  }
720  else
721  {
722  m_maximum = value;
723  }
724 
725  set_indices();
726 }

◆ set_minimum()

void Range::field::set_minimum ( element_type  value)

Definition at line 685 of file DetectorDescription/Identifier/src/Range.cxx.

686 {
687  if (m_mode == unbounded)
688  {
689  m_mode = low_bounded;
690  m_minimum = value;
691  }
692  else if ((m_mode == high_bounded) ||
693  (m_mode == both_bounded) ||
694  (m_mode == enumerated))
695  {
696  set (value, get_maximum ());
697  }
698  else
699  {
700  m_minimum = value;
701  }
702 
703  set_indices();
704 }

◆ set_next()

void Range::field::set_next ( int  next)

Definition at line 784 of file DetectorDescription/Identifier/src/Range.cxx.

785 {
788  }
789  else {
791  }
792  m_next = next;
793 }

◆ set_previous()

void Range::field::set_previous ( int  previous)

Definition at line 797 of file DetectorDescription/Identifier/src/Range.cxx.

798 {
799  if (has_next == m_continuation_mode) {
801  }
802  else {
804  }
806 }

◆ show()

void Range::field::show ( ) const

Definition at line 1035 of file DetectorDescription/Identifier/src/Range.cxx.

1036 {
1037 
1038  std::cout << "min/max " << m_minimum << " " << m_maximum << " ";
1039  std::cout << "values ";
1040  for (size_type i = 0; i < m_values.size(); ++i) {
1041  std::cout << m_values[i] << " ";
1042  }
1043  std::cout << "indexes ";
1044  for (size_type i = 0; i < m_indexes.size(); ++i) {
1045  std::cout << m_indexes[i] << " ";
1046  }
1047  std::cout << "indices " << m_indices << " ";
1048  std::cout << "prev " << m_previous << " ";
1049  std::cout << "next " << m_next << " ";
1050 
1051  std::cout << "mode ";
1052  switch (m_mode) {
1054  std::cout << "unbounded ";
1055  break;
1057  std::cout << "low_bounded ";
1058  break;
1060  std::cout << "high_bounded ";
1061  break;
1063  std::cout << "both_bounded ";
1064  break;
1066  std::cout << "enumerated ";
1067  break;
1068  }
1069 
1070  std::cout << "cont mode ";
1071  switch (m_continuation_mode) {
1072  case Range::field::none:
1073  std::cout << "none ";
1074  break;
1075  case Range::field::has_next:
1076  std::cout << "has_next ";
1077  break;
1079  std::cout << "has_previous ";
1080  break;
1082  std::cout << "has_both ";
1083  break;
1085  std::cout << "has_wrap_around ";
1086  break;
1087  }
1088  std::cout << std::endl;
1089 }

◆ wrap_around()

bool Range::field::wrap_around ( ) const

Definition at line 406 of file DetectorDescription/Identifier/src/Range.cxx.

407 {
409 }

Member Data Documentation

◆ m_continuation_mode

continuation_mode Range::field::m_continuation_mode
private

◆ m_indexes

index_vector Range::field::m_indexes
private

◆ m_indices

size_type Range::field::m_indices
private

◆ m_maximum

element_type Range::field::m_maximum
private

◆ m_minimum

element_type Range::field::m_minimum
private

◆ m_mode

mode Range::field::m_mode
private

◆ m_next

element_type Range::field::m_next
private

◆ m_previous

element_type Range::field::m_previous
private

◆ m_values

element_vector Range::field::m_values
private

The documentation for this class was generated from the following files:
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
Range::element_type
ExpandedIdentifier::element_type element_type
Definition: DetectorDescription/Identifier/Identifier/Range.h:30
Range::field::max_values
max_values
Definition: DetectorDescription/Identifier/Identifier/Range.h:134
Range::field::m_minimum
element_type m_minimum
Definition: DetectorDescription/Identifier/Identifier/Range.h:147
get_generator_info.result
result
Definition: get_generator_info.py:21
max
#define max(a, b)
Definition: cfImp.cxx:41
Range::field::m_values
element_vector m_values
Definition: DetectorDescription/Identifier/Identifier/Range.h:149
Range::field::both_bounded
@ both_bounded
Definition: DetectorDescription/Identifier/Identifier/Range.h:48
index
Definition: index.py:1
Range::field::mode
mode
Characterizes the four possible modes of any field specification.
Definition: DetectorDescription/Identifier/Identifier/Range.h:44
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
Range::field::create_index_table
void create_index_table()
Create index table from value table.
Definition: DetectorDescription/Identifier/src/Range.cxx:1143
Range::maximum
ExpandedIdentifier maximum() const
Definition: DetectorDescription/Identifier/src/Range.cxx:1410
Range::field::get_value_at
element_type get_value_at(size_type index) const
Definition: DetectorDescription/Identifier/Identifier/Range.h:583
athena.value
value
Definition: athena.py:122
Range::field::max_indexes
@ max_indexes
Definition: DetectorDescription/Identifier/Identifier/Range.h:135
Range::field::clear
void clear()
Set methods.
Definition: DetectorDescription/Identifier/src/Range.cxx:653
Range::field::set_minimum
void set_minimum(element_type value)
Definition: DetectorDescription/Identifier/src/Range.cxx:685
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Range::minimum
ExpandedIdentifier minimum() const
min and max ExpandedIdentifiers (if they exist, ie.
Definition: DetectorDescription/Identifier/src/Range.cxx:1371
Range::field::high_bounded
@ high_bounded
Definition: DetectorDescription/Identifier/Identifier/Range.h:47
ev
int ev
Definition: globals.cxx:25
Range::field::has_minimum
bool has_minimum() const
Definition: DetectorDescription/Identifier/src/Range.cxx:390
Range::field::has_next
@ has_next
Definition: DetectorDescription/Identifier/Identifier/Range.h:55
Range::field::has_both
@ has_both
Definition: DetectorDescription/Identifier/Identifier/Range.h:57
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
lumiFormat.i
int i
Definition: lumiFormat.py:92
Range::field::is_valued
bool is_valued() const
Some combined query functions on the specification mode.
Definition: DetectorDescription/Identifier/src/Range.cxx:384
Range::field::unbounded
@ unbounded
Definition: DetectorDescription/Identifier/Identifier/Range.h:45
Range::field::m_indices
size_type m_indices
Definition: DetectorDescription/Identifier/Identifier/Range.h:151
Range::field::m_mode
mode m_mode
Definition: DetectorDescription/Identifier/Identifier/Range.h:154
Range::field::m_maximum
element_type m_maximum
Definition: DetectorDescription/Identifier/Identifier/Range.h:148
Range::size_type
ExpandedIdentifier::size_type size_type
Definition: DetectorDescription/Identifier/Identifier/Range.h:31
Range::field::has_wrap_around
@ has_wrap_around
Definition: DetectorDescription/Identifier/Identifier/Range.h:58
Range::field::m_previous
element_type m_previous
Definition: DetectorDescription/Identifier/Identifier/Range.h:152
Range::field::low_bounded
@ low_bounded
Definition: DetectorDescription/Identifier/Identifier/Range.h:46
Range::field::continuation_mode
continuation_mode
Definition: DetectorDescription/Identifier/Identifier/Range.h:53
Range::field::get_minimum
element_type get_minimum() const
Definition: DetectorDescription/Identifier/Identifier/Range.h:524
Range::field::set
void set(element_type minimum, element_type maximum)
Definition: DetectorDescription/Identifier/src/Range.cxx:665
min
#define min(a, b)
Definition: cfImp.cxx:40
Range::field::has_maximum
bool has_maximum() const
Definition: DetectorDescription/Identifier/src/Range.cxx:398
Range::field::add_value
void add_value(element_type value)
Definition: DetectorDescription/Identifier/src/Range.cxx:729
Range::field::element_vector
std::vector< element_type > element_vector
Definition: DetectorDescription/Identifier/Identifier/Range.h:61
Range::field::m_next
element_type m_next
Definition: DetectorDescription/Identifier/Identifier/Range.h:153
Range::field::m_continuation_mode
continuation_mode m_continuation_mode
Definition: DetectorDescription/Identifier/Identifier/Range.h:155
Range::field::get_indices
size_type get_indices() const
Definition: DetectorDescription/Identifier/Identifier/Range.h:545
Range::field::get_maximum
element_type get_maximum() const
Definition: DetectorDescription/Identifier/Identifier/Range.h:531
Range::field::get_value_index
size_type get_value_index(element_type value) const
Definition: DetectorDescription/Identifier/Identifier/Range.h:609
python.PyAthena.v
v
Definition: PyAthena.py:157
DeMoScan.index
string index
Definition: DeMoScan.py:362
Range::field::none
@ none
Definition: DetectorDescription/Identifier/Identifier/Range.h:54
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
Range::field::has_previous
@ has_previous
Definition: DetectorDescription/Identifier/Identifier/Range.h:56
Range::field::set_maximum
void set_maximum(element_type value)
Definition: DetectorDescription/Identifier/src/Range.cxx:707
Range::field::set_indices
void set_indices()
Set m_indices.
Definition: DetectorDescription/Identifier/src/Range.cxx:1106
ExpandedIdentifier::size_type
boost::container::small_vector< element_type, 12 >::size_type size_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:122
Range::field::get_mode
mode get_mode() const
Query the values.
Definition: DetectorDescription/Identifier/Identifier/Range.h:517
Range::field::m_indexes
index_vector m_indexes
Definition: DetectorDescription/Identifier/Identifier/Range.h:150
Range::field::get_values
const element_vector & get_values() const
Definition: DetectorDescription/Identifier/Identifier/Range.h:538
Range::field::check_for_both_bounded
void check_for_both_bounded()
Check mode - switch from enumerated to both_bounded if possible.
Definition: DetectorDescription/Identifier/src/Range.cxx:1119
Trk::previous
@ previous
Definition: BinningData.h:32
Range::field::enumerated
@ enumerated
Definition: DetectorDescription/Identifier/Identifier/Range.h:49