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

#include <IdDictDefs.h>

Collaboration diagram for IdDictDictionary:

Public Types

typedef Identifier::value_type value_type
 
typedef Identifier::size_type size_type
 
typedef std::vector< IdDictDictEntry * > entries_type
 
typedef entries_type::iterator entries_it
 
typedef entries_type::const_iterator entries_const_it
 
typedef std::vector< IdDictRegion * > regions_type
 
typedef regions_type::iterator regions_it
 
typedef regions_type::const_iterator regions_const_it
 
typedef std::vector< IdDictGroup * > groups_type
 
typedef groups_type::iterator groups_it
 
typedef groups_type::const_iterator groups_const_it
 

Public Member Functions

 IdDictDictionary ()
 
 ~IdDictDictionary ()
 
IdDictFieldfind_field (const std::string &name) const
 
IdDictLabelfind_label (const std::string &field, const std::string &label) const
 
int get_label_value (const std::string &field, const std::string &label, int &value) const
 
IdDictSubRegionfind_subregion (const std::string &subregion_name) const
 
IdDictRegionfind_region (const std::string &region_name) const
 
IdDictRegionfind_region (const std::string &region_name, const std::string &group_name) const
 
IdDictGroupfind_group (const std::string &group_name) const
 
void add_field (IdDictField *field)
 
void add_subregion (IdDictSubRegion *subregion)
 
void add_dictentry (IdDictDictEntry *entry)
 
void add_subdictionary_name (const std::string &name)
 
void resolve_references (const IdDictMgr &idd)
 
void generate_implementation (const IdDictMgr &idd, const std::string &tag="")
 
void reset_implementation ()
 
bool verify () const
 Here, we verify global constraints : (this must only be applied after the resolve_references and
generate_implementation operations) More...
 
void sort ()
 Sort: More...
 
void clear ()
 
int find_region (const ExpandedIdentifier &id, size_type &index) const
 Find first region that matches id. More...
 
IdDictRegionfind_region (const ExpandedIdentifier &id) const
 
IdDictRegionfind_region (const ExpandedIdentifier &id, const std::string &group_name) const
 
void integrate_bits ()
 Set up integral of bits for efficient unpacking. More...
 
MultiRange build_multirange () const
 Get MultiRange for full dictionary. More...
 
MultiRange build_multirange (const ExpandedIdentifier &region_id, const Range &prefix=Range(), const std::string &last_field="") const
 Get MultiRange for a specific region_id up to and including 'last_field' If last_field == "", all fields are taken. More...
 
MultiRange build_multirange (const ExpandedIdentifier &region_id, const std::string &group_name, const Range &prefix=Range(), const std::string &last_field="") const
 Get MultiRange for a specific region_id, constrained to be within a specific named group. More...
 
int pack32 (const ExpandedIdentifier &id, size_t index1, size_t index2, Identifier &packedId) const
 Pack to 32bits the subset of id between (inclusive) index1 and index2 - this is generic, i.e. More...
 
int pack32 (const int *fields, size_t index1, size_t index2, size_t region_index, Identifier &packedId, size_t first_field_index=0) const
 Pack to 32bits the subset of id between (inclusive) index1 and index2. More...
 
int reset (size_t index1, size_t index2, size_t region_index, Identifier &packedId) const
 Reset fields from index1 to index2. More...
 
int unpack (const Identifier &id, const ExpandedIdentifier &prefix, size_t index2, ExpandedIdentifier &unpackedId) const
 Unpack the value_type id to an expanded Identifier, considering the provided prefix (result will include the prefix) and up to index2 - (index1 is assumed to be 0, i.e. More...
 
int unpack (const Identifier &id, const ExpandedIdentifier &prefix, size_t index2, const std::string &sep, std::string &unpackedId) const
 Unpack the value_type id to a string, considering the provided prefix (result will include the prefix) and up to index2 - (index1 is assumed to be 0, i.e. More...
 
int unpack (const Identifier &id, size_t first_field_index, size_t field_index, size_t region_index, int &field) const
 Unpack a single field of the value_type id. More...
 
int copy (const Identifier &idin, size_t first_field_index, size_t begin_field_index, size_t end_field_index, size_t region_index, Identifier &idout) const
 Copy a number of fields of the value_type id into another value_type id. More...
 
bool do_checks (void) const
 Checks are performed by default in debug compilation and NOT in optimized compilation. More...
 
void set_do_checks (bool do_checks)
 
bool do_neighbours (void) const
 Neighbour initialization is performed by default One can switch or query this mode for any idHelper with the following methods: More...
 
void set_do_neighbours (bool do_neighbours)
 
std::string file_name (void) const
 Access to file name. More...
 
std::string dict_tag (void) const
 Access to the dictionary tag. More...
 
void set_file_name (const std::string &name)
 Set file name. More...
 
void set_dict_tag (const std::string &tag)
 Set the dictionary tag. More...
 

Public Attributes

std::string m_name
 
std::string m_version
 
std::string m_date
 
std::string m_author
 
std::map< std::string, IdDictField * > m_fields
 
std::map< std::string, IdDictSubRegion * > m_subregions
 
std::vector< IdDictRegion * > m_regions
 
std::vector< IdDictRegion * > m_all_regions
 
std::vector< IdDictGroup * > m_groups
 
std::vector< std::string > m_subdictionary_names
 
IdDictDictionarym_parent_dict
 

Private Attributes

std::string m_file_name
 
std::string m_dict_tag
 
bool m_generated_implementation
 
bool m_do_checks
 
bool m_do_neighbours
 

Detailed Description

Definition at line 96 of file IdDictDefs.h.

Member Typedef Documentation

◆ entries_const_it

typedef entries_type::const_iterator IdDictDictionary::entries_const_it

Definition at line 290 of file IdDictDefs.h.

◆ entries_it

typedef entries_type::iterator IdDictDictionary::entries_it

Definition at line 289 of file IdDictDefs.h.

◆ entries_type

Definition at line 288 of file IdDictDefs.h.

◆ groups_const_it

typedef groups_type::const_iterator IdDictDictionary::groups_const_it

Definition at line 298 of file IdDictDefs.h.

◆ groups_it

typedef groups_type::iterator IdDictDictionary::groups_it

Definition at line 297 of file IdDictDefs.h.

◆ groups_type

Definition at line 296 of file IdDictDefs.h.

◆ regions_const_it

typedef regions_type::const_iterator IdDictDictionary::regions_const_it

Definition at line 294 of file IdDictDefs.h.

◆ regions_it

typedef regions_type::iterator IdDictDictionary::regions_it

Definition at line 293 of file IdDictDefs.h.

◆ regions_type

Definition at line 292 of file IdDictDefs.h.

◆ size_type

Definition at line 100 of file IdDictDefs.h.

◆ value_type

Definition at line 99 of file IdDictDefs.h.

Constructor & Destructor Documentation

◆ IdDictDictionary()

IdDictDictionary::IdDictDictionary ( )

Definition at line 296 of file IdDictMgr.cxx.

297  :
298  m_parent_dict(0),
299  //m_resolved_references(false),
301  m_do_checks(false),
302  m_do_neighbours(true)
303 {}

◆ ~IdDictDictionary()

IdDictDictionary::~IdDictDictionary ( )

Definition at line 305 of file IdDictMgr.cxx.

306 {
307 }

Member Function Documentation

◆ add_dictentry()

void IdDictDictionary::add_dictentry ( IdDictDictEntry entry)

Definition at line 410 of file IdDictMgr.cxx.

411 {
412  // Add region to corresponding group
413  IdDictGroup* group = find_group(region->group_name());
414  if (0 == group) {
415  group = new IdDictGroup(region->group_name());
416  m_groups.push_back(group);
417  }
418  group->add_dictentry (region);
419 }

◆ add_field()

void IdDictDictionary::add_field ( IdDictField field)

Definition at line 346 of file IdDictMgr.cxx.

347 {
348  if (field == 0) return;
349 
350  std::string& name = field->m_name;
351 
352  m_fields[name] = field;
353 }

◆ add_subdictionary_name()

void IdDictDictionary::add_subdictionary_name ( const std::string &  name)

Definition at line 403 of file IdDictMgr.cxx.

404 {
405  m_subdictionary_names.push_back(name);
406 }

◆ add_subregion()

void IdDictDictionary::add_subregion ( IdDictSubRegion subregion)

Definition at line 394 of file IdDictMgr.cxx.

395 {
396  if (subregion == 0) return;
397 
398  std::string& name = subregion->m_name;
399 
400  m_subregions[name] = subregion;
401 }

◆ build_multirange() [1/3]

MultiRange IdDictDictionary::build_multirange ( ) const

Get MultiRange for full dictionary.

Definition at line 1048 of file IdDictMgr.cxx.

1049 {
1050  MultiRange result;
1051 
1053 
1054  for (it = m_groups.begin (); it != m_groups.end (); ++it)
1055  {
1056  const IdDictGroup& group = *(*it);
1057 
1058  MultiRange group_mr = group.build_multirange();
1059 
1060  for (unsigned int i = 0; i < group_mr.size(); ++i) {
1061  const Range& range = group_mr[i];
1062  result.add (range);
1063  }
1064  }
1065 
1066 // IdDictDictionary::regions_const_it it;
1067 
1068 // for (it = m_regions.begin (); it != m_regions.end (); ++it)
1069 // {
1070 // const IdDictRegion& region = *(*it);
1071 
1072 // // skip regions created from parents
1073 // if("dummy" == region.m_name) continue;
1074 
1075 // // skip empty regions - may arise from alternate_regions
1076 // // where a tag selects an empty region
1077 // if(region.m_is_empty) continue;
1078 
1079 // result.add (region.build_range ());
1080 
1081 // }
1082 
1083  return (result);
1084 }

◆ build_multirange() [2/3]

MultiRange IdDictDictionary::build_multirange ( const ExpandedIdentifier region_id,
const Range prefix = Range(),
const std::string &  last_field = "" 
) const

Get MultiRange for a specific region_id up to and including 'last_field' If last_field == "", all fields are taken.

Prepend prefix if provided.

Definition at line 1086 of file IdDictMgr.cxx.

1089 {
1090  MultiRange result;
1091 
1093  if ("" == last_field) {
1094  // Take all fields
1095  for (it = m_regions.begin (); it != m_regions.end (); ++it) {
1096 
1097  const IdDictRegion& region = *(*it);
1098 
1099  // skip regions created from parents
1100  if("dummy" == region.m_name) continue;
1101 
1102  // skip empty regions - may arise from alternate_regions
1103  // where a tag selects an empty region
1104  if(region.m_is_empty) continue;
1105 
1106  Range range(region.build_range ());
1107  // Check region selection
1108  if (range.match(region_id))result.add (std::move(range));
1109  }
1110  }
1111  else {
1112  // Not all fields required
1113  for (it = m_regions.begin (); it != m_regions.end (); ++it) {
1114  const IdDictRegion& region = *(*it);
1115 
1116  // skip regions created from parents
1117  if("dummy" == region.m_name) continue;
1118 
1119  // skip empty regions - may arise from alternate_regions
1120  // where a tag selects an empty region
1121  if(region.m_is_empty) continue;
1122 
1123  Range range(region.build_range ());
1124  // Check region selection
1125  if (range.match(region_id)) {
1126  // Build new range up to last_field and add it to result -
1127  // remove duplicate ranges with addRangeToMR
1128  Range new_range(prefix); // Prepend with prefix
1129 
1130  std::vector <IdDictFieldImplementation>::const_iterator fit;
1131  for (fit = region.m_implementation.begin ();
1132  fit != region.m_implementation.end ();
1133  ++fit) {
1134  const IdDictFieldImplementation& impl = *fit;
1135 
1136 // new_range.add(impl.m_field);
1137  new_range.add(impl.range()->build_range());
1138 
1139  if (last_field == impl.range()->m_field->m_name) {
1140  break;
1141  }
1142  }
1143  result.add(std::move(new_range));
1144  }
1145  }
1146  }
1147 
1148  return (result);
1149 }

◆ build_multirange() [3/3]

MultiRange IdDictDictionary::build_multirange ( const ExpandedIdentifier region_id,
const std::string &  group_name,
const Range prefix = Range(),
const std::string &  last_field = "" 
) const

Get MultiRange for a specific region_id, constrained to be within a specific named group.

The depth of the multirange is up to and including 'last_field' If last_field == "", all fields are taken. Prepend prefix if provided.

Definition at line 1152 of file IdDictMgr.cxx.

1156 {
1157  MultiRange result;
1158 
1160  if ("" == last_field) {
1161  // Take all fields
1162  for (it = m_regions.begin (); it != m_regions.end (); ++it) {
1163 
1164  const IdDictRegion& region = *(*it);
1165 
1166  // skip regions created from parents
1167  if("dummy" == region.m_name) continue;
1168 
1169  // skip empty regions - may arise from alternate_regions
1170  // where a tag selects an empty region
1171  if(region.m_is_empty) continue;
1172 
1173  Range range(region.build_range ());
1174  // Check region selection
1175  if (range.match(region_id) && region.group_name() == group_name)result.add (std::move(range));
1176  }
1177  }
1178  else {
1179  // Not all fields required
1180  for (it = m_regions.begin (); it != m_regions.end (); ++it) {
1181  const IdDictRegion& region = *(*it);
1182 
1183  // skip regions created from parents
1184  if("dummy" == region.m_name) continue;
1185 
1186  // skip empty regions - may arise from alternate_regions
1187  // where a tag selects an empty region
1188  if(region.m_is_empty) continue;
1189 
1190  Range range(region.build_range ());
1191  // Check region selection
1192  if (range.match(region_id) && region.group_name() == group_name) {
1193  // Build new range up to last_field and add it to result -
1194  // remove duplicate ranges with addRangeToMR
1195  Range new_range(prefix); // Prepend with prefix
1196 
1197  std::vector <IdDictFieldImplementation>::const_iterator fit;
1198  for (fit = region.m_implementation.begin ();
1199  fit != region.m_implementation.end ();
1200  ++fit) {
1201  const IdDictFieldImplementation& impl = *fit;
1202 
1203 // new_range.add(impl.m_field);
1204  new_range.add(impl.range()->build_range());
1205 
1206  if (last_field == impl.range()->m_field->m_name) {
1207  break;
1208  }
1209  }
1210  result.add(std::move(new_range));
1211  }
1212  }
1213  }
1214 
1215  return (result);
1216 }

◆ clear()

void IdDictDictionary::clear ( )

Definition at line 1006 of file IdDictMgr.cxx.

1007 {
1008  {
1010 
1011  for (it = m_subregions.begin (); it != m_subregions.end (); ++it)
1012  {
1013  IdDictSubRegion* subregion = (*it).second;
1014  subregion->clear ();
1015  delete subregion;
1016  }
1017 
1018  m_subregions.clear ();
1019  }
1020 
1021  {
1023 
1024  for (it = m_fields.begin (); it != m_fields.end (); ++it)
1025  {
1026  IdDictField* field = (*it).second;
1027  field->clear ();
1028  delete field;
1029  }
1030 
1031  m_fields.clear ();
1032  }
1033 
1034  {
1036 
1037  for (it = m_groups.begin (); it != m_groups.end (); ++it) {
1038 
1039  IdDictGroup* group = *it;
1040  group->clear ();
1041  delete group;
1042  }
1043 
1044  m_groups.clear ();
1045  }
1046 }

◆ copy()

int IdDictDictionary::copy ( const Identifier idin,
size_t  first_field_index,
size_t  begin_field_index,
size_t  end_field_index,
size_t  region_index,
Identifier idout 
) const

Copy a number of fields of the value_type id into another value_type id.

Copy a number of fields of the bits32 id into another bits32 id.

One specifies the begin and end (inclusive) field indexes desired and passes in the region index to be used for decoding. The region index is obtained from find_region. The first_field_index is normally 0. It is non-zero when fields 0 to first_field_index -1 are missing from the compact

One specifies the begin and end (inclusive) field indexes desired and passes in the region index to be used for decoding. The region index is obtained from find_region. The first_field_index is normally 0. It is non-zero when fields 0 to first_field_index -1 are missing from the compact. In this case, idout is shift by the number of missing bits, if possible.

Definition at line 1998 of file IdDictMgr.cxx.

2004 {
2005 
2006  idout = Identifier();
2007  if (region_index >= m_regions.size()) {
2008  std::cout << "IdDictDictionary::copy - region index too large. Index, nregions "
2009  << region_index << " " << m_regions.size() << std::endl;
2010  return (1);
2011  }
2012 
2013  const IdDictRegion& region = *m_regions[region_index];
2014 
2015  if (first_field_index >= region.m_implementation.size() ||
2016  begin_field_index >= region.m_implementation.size() ||
2017  end_field_index >= region.m_implementation.size()) {
2018  std::cout << "IdDictDictionary::copy - field index too large. Indexes first, begin, end, nfields "
2019  << first_field_index << " "
2020  << begin_field_index << " "
2021  << end_field_index << " "
2022  << region.m_implementation.size()
2023  << std::endl;
2024  return (1);
2025  }
2026 
2027  size_t missing_offset = 0;
2028  if (first_field_index) {
2029  if (first_field_index > begin_field_index) {
2030  std::cout << "IdDictDictionary::copy - first_field_index > begin_field_index. Indexes "
2031  << first_field_index << " " << begin_field_index << std::endl;
2032  return (1);
2033  }
2034  // One or more fields missing from prefix, get the offset
2035  missing_offset = region.m_implementation[first_field_index].bits_offset();
2036  }
2037 
2038  size_t prefix_offset = 0;
2039  if (begin_field_index) {
2040  if (begin_field_index > end_field_index) {
2041  std::cout << "IdDictDictionary::copy - begin_field_index > end_field_index. Indexes "
2042  << begin_field_index << " " << end_field_index << std::endl;
2043  return (1);
2044  }
2045  // One or more fields missing from prefix, get the offset
2046  prefix_offset = region.m_implementation[begin_field_index].bits_offset();
2047  }
2048 
2049  const IdDictFieldImplementation& impl = region.m_implementation[end_field_index];
2050  size_t suffix_offset = impl.bits() + impl.bits_offset();
2051 
2052  size_t position = Identifier::NBITS; // overall bit position
2053 
2054  if (position < prefix_offset - missing_offset) {
2055  std::cout << "IdDictDictionary::copy - position < prefix + missing. "
2056  << prefix_offset << " " << missing_offset << std::endl;
2057  return (1);
2058  }
2059 
2060 
2061  if (position < suffix_offset + missing_offset) {
2062  std::cout << "IdDictDictionary::copy - position < suffix + missing. "
2063  << suffix_offset << " " << missing_offset << std::endl;
2064  return (1);
2065  }
2066 
2067 
2068  // prepare the mask for copying
2069 
2071 
2072  Identifier::value_type prefix_mask = prefix_offset ? (static_cast<Identifier::value_type>(1) << (position - prefix_offset + missing_offset)) - 1 : 0;
2073 
2074  Identifier::value_type suffix_mask = (static_cast<Identifier::value_type>(1) << (position - suffix_offset + missing_offset)) - 1;
2075 
2076  mask -= prefix_mask + suffix_mask;
2077 
2078  idout = idin.mask_shift(mask, missing_offset);
2079 
2080 // std::cout << hex << "pre, suff, in, out " << prefix_mask << " "
2081 // << suffix_mask << " "
2082 // << idin << " "
2083 // << idout << " "
2084 // << missing_offset << " "
2085 // << prefix_offset << " "
2086 // << suffix_offset << " "
2087 // << std::endl;
2088 
2089 
2090  return (0);
2091 }

◆ dict_tag()

std::string IdDictDictionary::dict_tag ( void  ) const
inline

Access to the dictionary tag.

Definition at line 700 of file IdDictDefs.h.

701 {
702  return (m_dict_tag);
703 }

◆ do_checks()

bool IdDictDictionary::do_checks ( void  ) const

Checks are performed by default in debug compilation and NOT in optimized compilation.

One can switch or query this mode for any idHelper with the following methods:

Definition at line 2096 of file IdDictMgr.cxx.

2097 {
2098  return (m_do_checks);
2099 }

◆ do_neighbours()

bool IdDictDictionary::do_neighbours ( void  ) const

Neighbour initialization is performed by default One can switch or query this mode for any idHelper with the following methods:

Definition at line 2108 of file IdDictMgr.cxx.

2109 {
2110  return (m_do_neighbours);
2111 }

◆ file_name()

std::string IdDictDictionary::file_name ( void  ) const
inline

Access to file name.

Definition at line 692 of file IdDictDefs.h.

693 {
694  return (m_file_name);
695 }

◆ find_field()

IdDictField * IdDictDictionary::find_field ( const std::string &  name) const

Definition at line 309 of file IdDictMgr.cxx.

310 {
311  std::map <std::string, IdDictField*>::const_iterator it;
312 
313  it = m_fields.find (name);
314 
315  if (it == m_fields.end ()) {
316  // If parent exists, look for field there
317  if(m_parent_dict) {
318  it = m_parent_dict->m_fields.find (name);
319  if (it == m_parent_dict->m_fields.end ()) {
320  return (0);
321  }
322  }
323  else {
324  return (0);
325  }
326  }
327 
328  return ((*it).second);
329 }

◆ find_group()

IdDictGroup * IdDictDictionary::find_group ( const std::string &  group_name) const

Definition at line 383 of file IdDictMgr.cxx.

384 {
385  for (size_t i = 0; i < m_groups.size (); ++i)
386  {
388  if ((group != 0) && (group->name() == group_name)) return (group);
389  }
390 
391  return (0);
392 }

◆ find_label()

IdDictLabel * IdDictDictionary::find_label ( const std::string &  field,
const std::string &  label 
) const

Definition at line 331 of file IdDictMgr.cxx.

332 {
333  IdDictField* idField = find_field(field);
334  if (!idField) return (0);
335  return (idField->find_label(label));
336 }

◆ find_region() [1/5]

IdDictRegion * IdDictDictionary::find_region ( const ExpandedIdentifier id) const

Definition at line 886 of file IdDictMgr.cxx.

887 {
888  return find_region (id, "");
889 }

◆ find_region() [2/5]

IdDictRegion * IdDictDictionary::find_region ( const ExpandedIdentifier id,
const std::string &  group_name 
) const

Definition at line 891 of file IdDictMgr.cxx.

892 {
893  // Find first region that matches id
894 
895  IdDictRegion* pRegion = 0;
897 
898  for (it = m_regions.begin (); it != m_regions.end (); ++it) {
899  IdDictRegion& region = *(*it);
900  if ( (group_name!= "") && (region.group_name() != group_name) ) continue;
901 
902  Range range = region.build_range();
903 
904  if (range.match(id) && range.fields() >= id.fields()) {
905  pRegion = &region;
906  }
907  }
908 
909  return (pRegion);
910 }

◆ find_region() [3/5]

int IdDictDictionary::find_region ( const ExpandedIdentifier id,
size_type index 
) const

Find first region that matches id.

Definition at line 863 of file IdDictMgr.cxx.

864 {
865 
866  // Find first region that matches id
867 
869 
870  size_type i = 0;
871  for (it = m_regions.begin (); it != m_regions.end (); ++it, ++i) {
872  const IdDictRegion& region = *(*it);
873 
874  Range range = region.build_range();
875 
876  if (range.match(id) && range.fields() >= id.fields()) {
877  index = i;
878  return (0);
879  }
880  }
881 
882  return (1);
883 }

◆ find_region() [4/5]

IdDictRegion * IdDictDictionary::find_region ( const std::string &  region_name) const

Definition at line 366 of file IdDictMgr.cxx.

367 {
368  return find_region (region_name, "");
369 }

◆ find_region() [5/5]

IdDictRegion * IdDictDictionary::find_region ( const std::string &  region_name,
const std::string &  group_name 
) const

Definition at line 371 of file IdDictMgr.cxx.

372 {
373  for (size_t i = 0; i < m_regions.size (); ++i)
374  {
375  IdDictRegion* region = m_regions[i];
376  if ( (group_name!= "") && (region->group_name() != group_name) ) continue;
377  if ((region != 0) && (region_name == region->m_name)) return (region);
378  }
379 
380  return (0);
381 }

◆ find_subregion()

IdDictSubRegion * IdDictDictionary::find_subregion ( const std::string &  subregion_name) const

Definition at line 355 of file IdDictMgr.cxx.

356 {
357  std::map <std::string, IdDictSubRegion*>::const_iterator it;
358 
359  it = m_subregions.find (name);
360 
361  if (it == m_subregions.end ()) return (0);
362 
363  return ((*it).second);
364 }

◆ generate_implementation()

void IdDictDictionary::generate_implementation ( const IdDictMgr idd,
const std::string &  tag = "" 
)

Definition at line 787 of file IdDictMgr.cxx.

789 {
790 
791  if (Debugger::debug ())
792  {
793  std::cout << "IdDictDictionary::generate_implementation>" << std::endl;
794  }
795 
797 
798  // Propagate to each region and copy their generation into the
799  // dict's vector.
801  for (it = m_groups.begin (); it != m_groups.end (); ++it) {
802  (*it)->generate_implementation (idd, *this, tag);
803  // Get regions from group and save in m_regions
804  const regions_type& regions = (*it)->regions();
806  for (it1 = regions.begin(); it1 != regions.end(); ++it1) {
807  m_regions.push_back(*it1);
808  }
809  }
810 
811  // Loop again over groups and set the bit-packing - starting at
812  // level 0
813  for (it = m_groups.begin (); it != m_groups.end (); ++it) {
814  // Copy to temporary vector all regions in the group. And
815  // look for regions in local m_regions vector for any
816  // regions "dummy", which come from reference
817  // dictionaries.
818 
819 // std::cout << "Group: " << (*it)->name() << std::endl;
820 
821 // IdDictDictionary::regions_type regions((*it)->regions());
822 // IdDictDictionary::regions_const_it it1;
823 // for (it1 = m_regions.begin (); it1 != m_regions.end (); ++it1) {
824 // if ("dummy" == (*it1)->m_name) {
825 // regions.push_back(*it1);
826 // std::cout << "adding " << (*it1)->m_index << std::endl;
827 // }
828 // }
829 
830  // Skip special group
831  if ("dummy" == (*it)->name()) continue;
832 
833  get_bits (m_regions, 0, (*it)->name());
834 // get_bits (regions, 0, (*it)->name());
835  }
836 
837  // Set integral over the number of bits
838  integrate_bits ();
839 
840  // Set neighbours for regions
842  for (itr = m_regions.begin (); itr != m_regions.end (); ++itr) {
843  (*itr)->find_neighbours(*this);
844  }
845 
847  }
848 }

◆ get_label_value()

int IdDictDictionary::get_label_value ( const std::string &  field,
const std::string &  label,
int &  value 
) const

Definition at line 338 of file IdDictMgr.cxx.

339 {
340  IdDictLabel* idLabel = find_label(field, label);
341  if (!idLabel || !idLabel->m_valued) return (1);
342  value = idLabel->m_value;
343  return (0);
344 }

◆ integrate_bits()

void IdDictDictionary::integrate_bits ( )

Set up integral of bits for efficient unpacking.

Definition at line 913 of file IdDictMgr.cxx.

914 {
915  // For each region, loop over its levels and set the bit offset
916  // for each FieldImplementation
917 
918  for (IdDictRegion* region : m_regions) {
919  size_t bits_offset = 0;
920 
921  for (IdDictFieldImplementation& impl : region->m_implementation) {
922  impl.optimize(); // optimize for decoding
923  impl.set_bits_offset(bits_offset);
924  bits_offset += impl.bits();
925 
926  // Set whether or not to decode index
927  Range::field field = impl.ored_field();
928  if (Range::field::both_bounded != field.get_mode() ||
929  0 != field.get_minimum())
930  {
931  impl.set_decode_index(true);
932  }
933  }
934  }
935 }

◆ pack32() [1/2]

int IdDictDictionary::pack32 ( const ExpandedIdentifier id,
size_t  index1,
size_t  index2,
Identifier packedId 
) const

Pack to 32bits the subset of id between (inclusive) index1 and index2 - this is generic, i.e.

not the most efficient

Assumptions:

  • packedId is initialized to 0
  • the expanded id begins at index = 0
  • index1,2 correspond to the level/field number, this is thus the same as the index into the expanded id due to the previous assumption.

First we need to check whether the specified identifier really matches the Dictionary specifications.

However, we stop the search in the set of regions at the first matching region. Should we request that only one region matches ????

Definition at line 1234 of file IdDictMgr.cxx.

1238 {
1239  packedId = 0;
1240 
1241 // std::cout << "IdDictDictionary::pack32: index1,2, fields "
1242 // << index1 << " " << index2 << " " << id.fields()
1243 // << " " << (std::string)id << std::endl;
1244 
1245  // Preconditions...
1246 
1247  if (index2 < index1) {
1248  // bad parameters.
1249  return (1);
1250  }
1251 
1252  if (index1 >= id.fields ()) {
1253  // nothing very useful !!
1254  return (1);
1255  }
1256 
1257  if (index2 >= id.fields ()) {
1258  // bad parameter...
1259  return (1);
1260  }
1261 
1271  for (size_t k = 0; k < m_regions.size (); ++k) {
1272  bool selected = true;
1273 
1274  const IdDictRegion& region = *m_regions[k];
1275 
1276  // Must skip empty regions - can arise when a tag selects an
1277  // empty region
1278  if (region.m_is_empty) continue;
1279 
1280  for (size_t i = 0; i < region.m_implementation.size (); ++i) {
1281  if (i >= id.fields ()) break;
1282 
1284 
1285  if (!impl.field().match (id[i])) {
1286 // std::cout << "Region #" << region.m_index <<
1287 // " field " << impl.range()->m_field_name <<
1288 // " #" << i << " (" << (std::string) impl.field() << ") does not match " <<
1289 // id[i] << std::endl;
1290 
1291  selected = false;
1292  break;
1293  }
1294  }
1295 
1296  if (selected) {
1297  size_t position = Identifier::NBITS;
1298 
1299 // std::cout << "Region #" << region.m_index << " selected" << std::endl;
1300 
1301  // We have the proper region.
1302  for (size_t i = index1; i <= index2; ++i) {
1304 
1305  Identifier::value_type index = impl.ored_field().get_value_index (id[i]);
1306 
1307  if (0 == position && impl.bits() > 0) {
1308  return(1);
1309  }
1310 
1311  position -= impl.bits();
1312  packedId |= (index << position);
1313 
1314 // std::cout << " pack " << id[i] << " using field " <<
1315 // impl.range()->m_field_name <<
1316 // " #" << i << " (" << (std::string) impl.ored_field() << ")" <<
1317 // " -> index=" << index <<
1318 // " @bit" << position <<
1319 // std::endl;
1320 
1321  }
1322  break;
1323  }
1324  }
1325 
1326 // std::cout << " packed " << hex << packedId << dec << std::endl;
1327 
1328  return (0);
1329 }

◆ pack32() [2/2]

int IdDictDictionary::pack32 ( const int *  fields,
size_t  index1,
size_t  index2,
size_t  region_index,
Identifier packedId,
size_t  first_field_index = 0 
) const

Pack to 32bits the subset of id between (inclusive) index1 and index2.

Here one must provide the region index, which can be found with find_region. This is more efficient than the above pack32.

Assumptions: (different than the previous pack32)

  • packedId is NOT initialized to 0 - allows to just overwrite the specified fields
  • the field array begins at index1, i.e. NOT the first field
  • the field array field array has a length of index2-index1+1
  • index1,2 correspond to the level/field number
  • first_field_index defines the offset for packing. Normally, this is this is 0. But this may be a field > 0, but of course <= index1

Definition at line 1334 of file IdDictMgr.cxx.

1340 {
1341 
1342 // std::cout << "IdDictDictionary::pack32: index1,2, fields "
1343 // << index1 << " " << index2 << " " << id.fields()
1344 // << " " << (std::string)id << std::endl;
1345 
1346  // Preconditions...
1347 
1348  if (m_do_checks) {
1349 
1350  if (index2 < index1) {
1351  // bad parameters.
1352  std::cout << "IdDictDictionary::pack32 - index2 < index1 - 1,2"
1353  << index1 << " " << index2 << std::endl;
1354  return (1);
1355  }
1356 
1357  if (region_index >= m_regions.size()) {
1358  // bad parameters.
1359  std::cout << "IdDictDictionary::pack32 - region index incorrect - index,size"
1360  << region_index << " " << m_regions.size() << std::endl;
1361  return (1);
1362  }
1363  }
1364 
1365 
1366  // Get the region
1367  const IdDictRegion& region = *m_regions[region_index];
1368 
1369  if (m_do_checks) {
1370  if (region.m_is_empty) {
1371  std::cout << "IdDictDictionary::pack32 - region id empty" << std::endl;
1372  // bad parameters.
1373  return (1);
1374  }
1375  if(index1 < first_field_index) {
1376  std::cout << "IdDictDictionary::pack32 - first_field_index > index1 "
1377  << first_field_index << " " << index1 << std::endl;
1378  return (1);
1379  }
1380  }
1381 
1382  // Set the starting position
1383  size_t position = Identifier::NBITS;
1384  if(!first_field_index) {
1386  position -= impl.bits_offset();
1387  }
1388 
1389  size_t field_index = 0;
1390  for (size_t i = index1; i <= index2; ++i, ++field_index) {
1391 
1393 
1394  if (m_do_checks) {
1395 
1396  // Field should be within allowed range
1397  if (!impl.ored_field().match(fields[field_index])) {
1398  std::cout << "IdDictDictionary::pack32 - field does NOT match: value, allowed values "
1399  << fields[field_index] << " " << (std::string)impl.ored_field()
1400  << std::endl;
1401  // bad parameters.
1402  return (1);
1403  }
1404 
1405  // Check that we don't try to go below 0
1406  if (0 == position && impl.bits() > 0) {
1407  std::cout << "IdDictDictionary::pack32 - going past 0" << std::endl;
1408  return(1);
1409  }
1410  }
1411 
1413  if (impl.decode_index()) {
1414  index = impl.ored_field().get_value_index (fields[field_index]);
1415  }
1416  else {
1417  index = (Identifier::value_type)fields[field_index];
1418  }
1419 
1420  position -= impl.bits();
1421  packedId |= (index << position);
1422 
1423 
1424 // std::cout << " pack " << id[field_index] << " using field " <<
1425 // impl.range()->m_field_name <<
1426 // " #" << i << " (" << (std::string) impl.ored_field() << ")" <<
1427 // " -> index=" << index <<
1428 // " @bit" << position <<
1429 // std::endl;
1430 
1431  }
1432 
1433  //std::cout << " packed " << std::hex << packedId << std::dec << std::endl;
1434 
1435  return (0);
1436 }

◆ reset()

int IdDictDictionary::reset ( size_t  index1,
size_t  index2,
size_t  region_index,
Identifier packedId 
) const

Reset fields from index1 to index2.

Definition at line 1441 of file IdDictMgr.cxx.

1445 {
1446 
1447  // Preconditions...
1448 
1449  if (m_do_checks) {
1450 
1451  if (index2 < index1) {
1452  // bad parameters.
1453  std::cout << "IdDictDictionary::pack32 - index2 < index1 - 1,2"
1454  << index1 << " " << index2 << std::endl;
1455  return (1);
1456  }
1457 
1458  if (region_index >= m_regions.size()) {
1459  // bad parameters.
1460  std::cout << "IdDictDictionary::pack32 - region index incorrect - index,size"
1461  << region_index << " " << m_regions.size() << std::endl;
1462  return (1);
1463  }
1464  }
1465 
1466 
1467  // Get the region
1468  const IdDictRegion& region = *m_regions[region_index];
1469 
1470  if (m_do_checks) {
1471  if (region.m_is_empty) {
1472  std::cout << "IdDictDictionary::pack32 - region id empty" << std::endl;
1473  // bad parameters.
1474  return (1);
1475  }
1476  }
1477 
1478  size_t field_index = 0;
1479  for (size_t i = index1; i <= index2; ++i, ++field_index) {
1480 
1482 
1483  size_t position = Identifier::NBITS - impl.bits_offset() - impl.bits();
1484 
1485  Identifier::value_type mask = (((Identifier::value_type)1 << impl.bits()) - 1) << position;
1486 
1488 
1489  packedId &= (mask);
1490 
1491  }
1492  return (0);
1493 }

◆ reset_implementation()

void IdDictDictionary::reset_implementation ( )

Definition at line 850 of file IdDictMgr.cxx.

851 {
853  m_regions.clear();
855  for (it = m_groups.begin (); it != m_groups.end (); ++it) {
856  (*it)->reset_implementation();
857  }
859  }
860 }

◆ resolve_references()

void IdDictDictionary::resolve_references ( const IdDictMgr idd)

Definition at line 421 of file IdDictMgr.cxx.

422 {
423  {
425 
426  for (it = m_fields.begin (); it != m_fields.end (); ++it)
427  {
428  IdDictField* field = (*it).second;
429  field->resolve_references (idd);
430  }
431  }
432  {
434 
435  for (it = m_subregions.begin (); it != m_subregions.end (); ++it)
436  {
437  IdDictSubRegion* subregion = (*it).second;
438  subregion->resolve_references (idd, *this);
439  }
440  }
441  {
442  size_t index = 0;
443 
445  for (it = m_groups.begin (); it != m_groups.end (); ++it)
446  {
447  (*it)->resolve_references (idd, *this, index);
448  }
449  }
450 }

◆ set_dict_tag()

void IdDictDictionary::set_dict_tag ( const std::string &  tag)
inline

Set the dictionary tag.

Definition at line 716 of file IdDictDefs.h.

717 {
718  m_dict_tag = tag;
719 }

◆ set_do_checks()

void IdDictDictionary::set_do_checks ( bool  do_checks)

Definition at line 2102 of file IdDictMgr.cxx.

2103 {
2105 }

◆ set_do_neighbours()

void IdDictDictionary::set_do_neighbours ( bool  do_neighbours)

Definition at line 2114 of file IdDictMgr.cxx.

2115 {
2117 }

◆ set_file_name()

void IdDictDictionary::set_file_name ( const std::string &  name)
inline

Set file name.

Definition at line 708 of file IdDictDefs.h.

709 {
710  m_file_name = name;
711 }

◆ sort()

void IdDictDictionary::sort ( )

Sort:

Prerequisite: first verify the dictionary - no overlaps

Then loop over regions and sort according to their first identifier

Definition at line 986 of file IdDictMgr.cxx.

987 {
988  // verify
989  if (verify()) {
990 
991  std::map< ExpandedIdentifier, IdDictDictEntry* > regions;
992 
994 
995  for (it = m_groups.begin (); it != m_groups.end (); ++it) {
996 
997  (*it)->sort();
998  }
999  }
1000  else {
1001  std::cout << "IdDictDictionary::sort - WARNING verify is FALSE - cannot sort "
1002  << std::endl;
1003  }
1004 }

◆ unpack() [1/3]

int IdDictDictionary::unpack ( const Identifier id,
const ExpandedIdentifier prefix,
size_t  index2,
const std::string &  sep,
std::string &  unpackedId 
) const

Unpack the value_type id to a string, considering the provided prefix (result will include the prefix) and up to index2 - (index1 is assumed to be 0, i.e.

Unpack the bits32 id to a string, considering the provided prefix (result will include the prefix) and up to index2 - (index1 is assumed to be 0, i.e.

part of prefix).

First we need to check whether the specified identifier prefix really matches the Dictionary specifications.

ok we require that the region is at least as large as the prefix.

We have one region that matches the prefix. Let's now try to expand the bits32 from the fields of the region that are beyond the prefix.

this index extracted from the bits32 does not seem to match this field in the region... Let's try another region

this index extracted from the bits32 does not match this field in the region... Let's try another region

Definition at line 1671 of file IdDictMgr.cxx.

1676 {
1677 
1678  ExpandedIdentifier localPrefix (prefix);
1679  //unpackedId.clear ();
1680  //if (0 < localPrefix.fields ()) unpackedId = localPrefix;
1681 
1687  size_t index1 = 0; // field index
1688  size_t position = Identifier::NBITS; // overall bit position - used for debugging only
1689 
1690  for (size_t k = 0; k < m_regions.size (); ++k) {
1691  bool selected = false;
1692 
1693  const IdDictRegion& region = *m_regions[k];
1694 
1695  // Must skip empty regions - can arise when a tag selects an
1696  // empty region
1697  if (region.m_is_empty) continue;
1698 
1699 // for (size_t i = index1; i < region.m_implementation.size (); ++i)
1700  for (size_t i = 0; i < region.m_implementation.size (); ++i) {
1701  if (i >= localPrefix.fields ()) {
1706  selected = true;
1707  index1 = i;
1708  break;
1709  }
1710 
1712 
1713  if (!impl.field().match (localPrefix[i])) {
1714 // std::cout << "Region #" << region.m_index <<
1715 // " field " << impl.range()->m_field_name <<
1716 // " #" << i << " (" << (std::string) impl.field() << ") does not match " <<
1717 // localPrefix[i] << std::endl;
1718 
1719  break;
1720  }
1721  }
1722 
1723  if (selected) {
1730 // bits32 temp = id;
1731 
1732 // std::cout << "Region #" << region.m_index << " selected" << std::endl;
1733 
1734  for (size_t i = index1; i < region.m_implementation.size (); ++i) {
1736 
1737  if (impl.bits() == 0) continue;
1738 
1739  Identifier::value_type mask = (static_cast<Identifier::value_type>(1) << impl.bits()) - 1;
1740 
1741  if (position < impl.bits()) break; // Nothing more to get
1742  size_t index = id.extract(position - impl.bits(), mask);
1743 
1744 // std::cout << "Region #" << region.m_index <<
1745 // " field " << impl.range()->m_field_name <<
1746 // " #" << i << " (" << (std::string) impl.field() << ") index " <<
1747 // index << " bits " << impl.bits() << " mask " << hex << mask << " id " <<
1748 // id << dec << std::endl;
1749 
1750 // size_t index = temp & mask;
1751 // temp >>= impl.bits();
1752 
1753  if (index >= impl.ored_field().get_indices ()) {
1760 // std::cout << " unpack " << index << " using field " <<
1761 // impl.range()->m_field_name <<
1762 // " #" << i << " (" << (std::string) impl.ored_field() << ")" <<
1763 // " -> mismatch" <<
1764 // " @bit" << position <<
1765 // std::endl;
1766  selected = false;
1767  break;
1768  }
1769 
1770  ExpandedIdentifier::element_type value = impl.ored_field().get_value_at (index);
1771 
1778  if (!impl.field().match (value)) {
1779 // std::cout << "Region #" << region.m_index <<
1780 // " field " << impl.range()->m_field_name <<
1781 // " #" << i << " (" << (std::string) impl.field() << ") does not match " <<
1782 // value << std::endl;
1783  selected = false;
1784  break;
1785  }
1786 
1787 // std::cout << "Region #" << region.m_index << " sel " << selected <<
1788 // " unpack " << index << " using field " <<
1789 // impl.range()->m_field_name <<
1790 // " #" << i << " (" << (std::string) impl.ored_field() << ")" <<
1791 // " -> value=" << value <<
1792 // " @bit" << position << " nbits " << impl.bits() <<
1793 // std::endl;
1794 
1795  // Found value
1796 
1797  // Add value to string
1798 
1799  std::string str_value("nil");
1800  char temp[20];
1801 
1802  // The policy below is:
1803  // - if a value is a character string or name, just add this name
1804  // - if a value is a number, then prefix it with the
1805  // name of the field
1806  //
1807  // NOTE: min/max is a number, but for value/label we
1808  // distinguish between number and name by looking for an IdDictLabel
1809  const IdDictRange* range = impl.range();
1810  IdDictLabel* label = range->m_field->find_label(range->m_label);
1811  switch (range->m_specification) {
1814  case IdDictRange::by_minmax:
1815  // For a range of values (numbers), add in the field name
1816  str_value = range->m_field->m_name + ' ';
1817  sprintf (temp, "%d", value);
1818  str_value += temp;
1819  break;
1820  case IdDictRange::by_value:
1821  case IdDictRange::by_label:
1822  str_value = "";
1823  if (!label) {
1824  // Is a number, add in field name
1825  str_value += range->m_field->m_name + ' ';
1826  }
1827  str_value += range->m_label;
1828  break;
1829  case IdDictRange::by_values:
1830  case IdDictRange::by_labels:
1831  str_value = "";
1832  // Is a name
1833  if (label) {
1834  // Found label with "find_label" on the field
1835  if (label->m_valued) {
1836  str_value += range->m_label;
1837  }
1838  }
1839  else {
1840  // If not found with the "find" above, we must
1841  // get the value and name from the range
1842  // itself.
1843 
1844  unsigned int index1 = 0;
1845  for (; index1 < range->m_values.size(); ++index1) {
1846  if (value == range->m_values[index1]) {
1847  break;
1848  }
1849  }
1850 
1851  // In some cases we
1852  if (index1 < range->m_labels.size()) {
1853  if (isNumber(range->m_labels[index1])) {
1854  str_value += range->m_field->m_name + ' ';
1855  }
1856  str_value += range->m_labels[index1];
1857  }
1858  else {
1859  std::cout << "IdDictDictionary::unpack - Could not find value." << std::endl;
1860  std::cout << "value " << value << std::endl;
1861  std::cout << "field values " << std::endl;
1862  for (unsigned int i=0; i < range->m_values.size(); ++i) {
1863  std::cout << range->m_values[i] << " ";
1864  }
1865  std::cout << std::endl;
1866  }
1867  }
1868  break;
1869  case IdDictRange::unknown:
1870 
1871  std::cout << "unknown" << std::endl;
1872 
1873  break;
1874  }
1875 
1876 
1877  if (index1)unpackedId += sep;
1878  unpackedId += str_value;
1879  localPrefix.add (value);
1880 
1881  position -= impl.bits(); // overall bit position
1882 
1883 // id = temp; // set id to shifted value
1884 
1885 
1886  index1++; // next field
1887 
1888  if (index1 > index2) break; // quit at index2
1889  }
1890  if (selected) break;
1891  }
1892  }
1893 
1894  return (0);
1895 }

◆ unpack() [2/3]

int IdDictDictionary::unpack ( const Identifier id,
const ExpandedIdentifier prefix,
size_t  index2,
ExpandedIdentifier unpackedId 
) const

Unpack the value_type id to an expanded Identifier, considering the provided prefix (result will include the prefix) and up to index2 - (index1 is assumed to be 0, i.e.

Unpack the bits32 id to an expanded Identifier, considering the
provided prefix (result will include the prefix)

part of prefix).

First we need to check whether the specified identifier prefix really matches the Dictionary specifications.

ok we require that the region is at least as large as the prefix.

We have one region that matches the prefix. Let's now try to expand the bits32 from the fields of the region that are beyond the prefix.

this index extracted from the bits32 does not seem to match this field in the region... Let's try another region

this index extracted from the bits32 does not match this field in the region... Let's try another region

Definition at line 1510 of file IdDictMgr.cxx.

1514 {
1515 
1516  ExpandedIdentifier localPrefix (prefix);
1517  unpackedId.clear ();
1518  if (0 < localPrefix.fields ()) unpackedId = localPrefix;
1519 
1525  size_t index1 = 0; // field index
1526  size_t position = Identifier::NBITS; // overall bit position - used for debugging only
1527 
1528  for (size_t k = 0; k < m_regions.size (); ++k)
1529  {
1530  bool selected = false;
1531 
1532  const IdDictRegion& region = *m_regions[k];
1533 
1534  // Must skip empty regions - can arise when a tag selects an
1535  // empty region
1536  if (region.m_is_empty) continue;
1537 
1538 // for (size_t i = index1; i < region.m_implementation.size (); ++i)
1539  for (size_t i = 0; i < region.m_implementation.size (); ++i)
1540  {
1541  if (i >= localPrefix.fields ())
1542  {
1547  selected = true;
1548  index1 = i;
1549  break;
1550  }
1551 
1553 
1554  if (!impl.field().match (localPrefix[i]))
1555  {
1556 // std::cout << "Region #" << region.m_index <<
1557 // " field " << impl.range()->m_field_name <<
1558 // " #" << i << " (" << (std::string) impl.field() << ") does not match " <<
1559 // localPrefix[i] << std::endl;
1560 
1561  break;
1562  }
1563  }
1564 
1565  if (selected)
1566  {
1573 // bits32 temp = id;
1574 
1575 // std::cout << "Region #" << region.m_index << " selected" << std::endl;
1576 
1577  for (size_t i = index1; i < region.m_implementation.size (); ++i)
1578  {
1580 
1581  if (impl.bits() == 0) continue;
1582 
1583  Identifier::value_type mask = (static_cast<Identifier::value_type>(1) << impl.bits()) - 1;
1584 
1585  if (position < impl.bits()) break; // Nothing more to get
1586  size_t index = id.extract(position - impl.bits(), mask);
1587 
1588 // std::cout << "Region #" << region.m_index <<
1589 // " field " << impl.range()->m_field_name <<
1590 // " #" << i << " (" << (std::string) impl.field() << ") index " <<
1591 // index << " bits " << impl.bits() << " mask " << hex << mask << " id " <<
1592 // id << dec << std::endl;
1593 
1594 // size_t index = temp & mask;
1595 // temp >>= impl.bits();
1596 
1597  if (index >= impl.ored_field().get_indices ())
1598  {
1605 // std::cout << " unpack " << index << " using field " <<
1606 // impl.range()->m_field_name <<
1607 // " #" << i << " (" << (std::string) impl.ored_field() << ")" <<
1608 // " -> mismatch" <<
1609 // " @bit" << position <<
1610 // std::endl;
1611 
1612  selected = false;
1613  break;
1614  }
1615 
1616  ExpandedIdentifier::element_type value = impl.ored_field().get_value_at (index);
1617 
1624  if (!impl.field().match (value))
1625  {
1626 // std::cout << "Region #" << region.m_index <<
1627 // " field " << impl.range()->m_field_name <<
1628 // " #" << i << " (" << (std::string) impl.field() << ") does not match " <<
1629 // value << std::endl;
1630 
1631  selected = false;
1632  break;
1633  }
1634 
1635 // std::cout << "Region #" << region.m_index << " sel " << selected <<
1636 // " unpack " << index << " using field " <<
1637 // impl.range()->m_field_name <<
1638 // " #" << i << " (" << (std::string) impl.ored_field() << ")" <<
1639 // " -> value=" << value <<
1640 // " @bit" << position << " nbits " << impl.bits() <<
1641 // std::endl;
1642 
1643  // Found value
1644 
1645  unpackedId.add (value);
1646  localPrefix.add (value);
1647 
1648  position -= impl.bits(); // overall bit position
1649 
1650 // id = temp; // set id to shifted value
1651 
1652 
1653  index1++; // next field
1654 
1655  if (index1 > index2) break; // quit at index2
1656  }
1657 
1658  if (selected) break;
1659  }
1660  }
1661 
1662  return (0);
1663 }

◆ unpack() [3/3]

int IdDictDictionary::unpack ( const Identifier id,
size_t  first_field_index,
size_t  field_index,
size_t  region_index,
int &  field 
) const

Unpack a single field of the value_type id.

Unpack a single field of the bits32 id.

One specifies the field index desired and passes in the region index to be used for decoding. The region index is obtained from find_region. The first_field_index is normally 0. It is non-zero when fields 0 to first_field_index -1 are missing from the compact

Definition at line 1907 of file IdDictMgr.cxx.

1912 {
1913  field = 0;
1914 
1915  if (m_do_checks) {
1916 
1917  // Check regions
1918  if (region_index >= m_regions.size()) {
1919  std::cout << "IdDictDictionary::unpack - region index too large. Index, nregions "
1920  << region_index << " " << m_regions.size() << std::endl;
1921  return (1);
1922  }
1923  }
1924 
1925  const IdDictRegion& region = *m_regions.at(region_index);
1926 
1927  if (m_do_checks) {
1928 
1929  // check number of fields
1930  if (field_index >= region.m_implementation.size()) {
1931  std::cout << "IdDictDictionary::unpack - field index too large. Index, nfields "
1932  << field_index << " " << region.m_implementation.size()
1933  << std::endl;
1934  return (1);
1935  }
1936 
1937  }
1938 
1939  const IdDictFieldImplementation& impl = region.m_implementation.at(field_index);
1940  size_t prefix_offset = 0;
1941 
1942  size_t position = Identifier::NBITS; // overall bit position
1943 
1944  // One or more fields missing from prefix, get the offset
1945  if (first_field_index) {
1946  if (m_do_checks) {
1947  if (first_field_index >= region.m_implementation.size()) {
1948  std::cout << "IdDictDictionary::unpack - first_field_index too large. Index, nfields "
1949  << first_field_index << " " << region.m_implementation.size()
1950  << std::endl;
1951  return (1);
1952  }
1953  }
1954 
1955  // One or more fields missing from prefix, get the offset
1956  prefix_offset = region.m_implementation[first_field_index].bits_offset();
1957 
1958  if (m_do_checks) {
1959  // Should have a non-zero number of bits
1960  if (impl.bits() == 0) {
1961  std::cout << "IdDictDictionary::unpack - no bits for this field. Region, field indexes "
1962  << region_index << " " << field_index << std::endl;
1963  return (1);
1964  }
1965 
1966  // Check the shift value
1967  if (impl.bits() + impl.bits_offset() - prefix_offset > position) {
1968  std::cout << "IdDictDictionary::unpack - bits + offset too large. Region, field indexes, bits, offset "
1969  << region_index << " " << field_index << " "
1970  << impl.bits() << " " << impl.bits_offset() << " " << prefix_offset
1971  << std::endl;
1972  return (1);
1973  }
1974  }
1975  }
1976 
1977  Identifier::value_type mask = (static_cast<Identifier::value_type>(1) << impl.bits()) - 1;
1978 
1979  size_t index = id.extract(position -= impl.bits() + impl.bits_offset() - prefix_offset, mask);
1980 
1981  field = index;
1982  if (impl.decode_index()) field = impl.ored_field().get_value_at (index);
1983 
1984 
1985  return (0);
1986 }

◆ verify()

bool IdDictDictionary::verify ( ) const

Here, we verify global constraints : (this must only be applied after the resolve_references and
generate_implementation operations)

a) There should be no overlap between any region duet.

b) In a dictionary, a given field (ie. with a given name) must always be referenced at the same depth across all regions and subregions.

c) When a region specifies a reference to a sub-dictionary :

  • the reference must be the last entry in the region
  • the first region entries of all regions should not overlap (regardless of the definition of the sub-dictionary). IE the first fields in
    these regions must be sufficient to unambiguously select the
    sub-dictionary.

d) Within a dictionary, a given field must always be described either through an enumeration, or through its bounds. However, the various usages of a
given field may specify different tag set (for enumerations) or bounds (for a bounded field).

Definition at line 962 of file IdDictMgr.cxx.

963 {
964  // check #1
965 
967  if (mr.has_overlap ()) return (false);
968 
969  // check #2
970  // check #3
971  // check #4
972 
973  return (true);
974 }

Member Data Documentation

◆ m_all_regions

std::vector<IdDictRegion*> IdDictDictionary::m_all_regions

Definition at line 303 of file IdDictDefs.h.

◆ m_author

std::string IdDictDictionary::m_author

Definition at line 286 of file IdDictDefs.h.

◆ m_date

std::string IdDictDictionary::m_date

Definition at line 285 of file IdDictDefs.h.

◆ m_dict_tag

std::string IdDictDictionary::m_dict_tag
private

Definition at line 310 of file IdDictDefs.h.

◆ m_do_checks

bool IdDictDictionary::m_do_checks
private

Definition at line 313 of file IdDictDefs.h.

◆ m_do_neighbours

bool IdDictDictionary::m_do_neighbours
private

Definition at line 314 of file IdDictDefs.h.

◆ m_fields

std::map<std::string, IdDictField*> IdDictDictionary::m_fields

Definition at line 300 of file IdDictDefs.h.

◆ m_file_name

std::string IdDictDictionary::m_file_name
private

Definition at line 309 of file IdDictDefs.h.

◆ m_generated_implementation

bool IdDictDictionary::m_generated_implementation
private

Definition at line 312 of file IdDictDefs.h.

◆ m_groups

std::vector<IdDictGroup*> IdDictDictionary::m_groups

Definition at line 304 of file IdDictDefs.h.

◆ m_name

std::string IdDictDictionary::m_name

Definition at line 283 of file IdDictDefs.h.

◆ m_parent_dict

IdDictDictionary* IdDictDictionary::m_parent_dict

Definition at line 306 of file IdDictDefs.h.

◆ m_regions

std::vector<IdDictRegion*> IdDictDictionary::m_regions

Definition at line 302 of file IdDictDefs.h.

◆ m_subdictionary_names

std::vector<std::string> IdDictDictionary::m_subdictionary_names

Definition at line 305 of file IdDictDefs.h.

◆ m_subregions

std::map<std::string, IdDictSubRegion*> IdDictDictionary::m_subregions

Definition at line 301 of file IdDictDefs.h.

◆ m_version

std::string IdDictDictionary::m_version

Definition at line 284 of file IdDictDefs.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IdDictDictionary::find_region
IdDictRegion * find_region(const std::string &region_name) const
Definition: IdDictMgr.cxx:366
Identifier::value_type
IDENTIFIER_TYPE value_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:39
IdDictDictionary::build_multirange
MultiRange build_multirange() const
Get MultiRange for full dictionary.
Definition: IdDictMgr.cxx:1048
IdDictRegion::resolve_references
void resolve_references(const IdDictMgr &idd, IdDictDictionary &dictionary)
Definition: IdDictMgr.cxx:2615
get_generator_info.result
result
Definition: get_generator_info.py:21
IdDictGroup
Definition: IdDictDefs.h:355
IdDictDictionary::do_neighbours
bool do_neighbours(void) const
Neighbour initialization is performed by default One can switch or query this mode for any idHelper w...
Definition: IdDictMgr.cxx:2108
IdDictDictionary::m_dict_tag
std::string m_dict_tag
Definition: IdDictDefs.h:310
IdDictRange::by_minmax
@ by_minmax
Definition: IdDictDefs.h:574
IdDictDictionary::m_groups
std::vector< IdDictGroup * > m_groups
Definition: IdDictDefs.h:304
IdDictDictionary::do_checks
bool do_checks(void) const
Checks are performed by default in debug compilation and NOT in optimized compilation.
Definition: IdDictMgr.cxx:2096
Range::field::both_bounded
@ both_bounded
Definition: DetectorDescription/Identifier/Identifier/Range.h:48
index
Definition: index.py:1
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
IdDictRange::by_label
@ by_label
Definition: IdDictDefs.h:570
IdDictDictionary::find_label
IdDictLabel * find_label(const std::string &field, const std::string &label) const
Definition: IdDictMgr.cxx:331
Identifier::mask_shift
value_type mask_shift(value_type mask, size_type shift) const
extract field(s) by masking first, then shifting
IdDictDictionary::groups_const_it
groups_type::const_iterator groups_const_it
Definition: IdDictDefs.h:298
ExpandedIdentifier::add
void add(element_type value)
skel.it
it
Definition: skel.GENtoEVGEN.py:423
IdDictLabel::m_value
int m_value
Definition: IdDictDefs.h:351
IdDictRange::by_labels
@ by_labels
Definition: IdDictDefs.h:571
IdDictDictionary::regions_type
std::vector< IdDictRegion * > regions_type
Definition: IdDictDefs.h:292
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:108
IdDictDictionary::m_do_checks
bool m_do_checks
Definition: IdDictDefs.h:313
IdDictField::find_label
IdDictLabel * find_label(const std::string &name) const
Definition: IdDictMgr.cxx:2153
athena.value
value
Definition: athena.py:122
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
IdDictRegion::clear
void clear()
Definition: IdDictMgr.cxx:2752
IdDictDictionary::find_field
IdDictField * find_field(const std::string &name) const
Definition: IdDictMgr.cxx:309
CalibDbCompareRT.region_id
region_id
Definition: CalibDbCompareRT.py:68
IdDictRegion
Definition: IdDictDefs.h:448
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
IdDictRegion::m_name
std::string m_name
Definition: IdDictDefs.h:476
IdDictDictionary::verify
bool verify() const
Here, we verify global constraints : (this must only be applied after the resolve_references and ge...
Definition: IdDictMgr.cxx:962
IdDictRange::by_minvalue
@ by_minvalue
Definition: IdDictDefs.h:572
IdDictDictionary::m_parent_dict
IdDictDictionary * m_parent_dict
Definition: IdDictDefs.h:306
IdDictLabel
Definition: IdDictDefs.h:344
IdDictDictionary::size_type
Identifier::size_type size_type
Definition: IdDictDefs.h:100
IdDictDictionary::groups_it
groups_type::iterator groups_it
Definition: IdDictDefs.h:297
IdDictDictionary::m_fields
std::map< std::string, IdDictField * > m_fields
Definition: IdDictDefs.h:300
IdDictDictionary::find_group
IdDictGroup * find_group(const std::string &group_name) const
Definition: IdDictMgr.cxx:383
IdDictRegion::build_range
Range build_range() const
Definition: IdDictMgr.cxx:2766
Trk::index1
@ index1
Definition: BoundarySurfaceFace.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
DetDescrDictionaryDict::it1
std::vector< HWIdentifier >::iterator it1
Definition: DetDescrDictionaryDict.h:17
IdDictDictionary::m_generated_implementation
bool m_generated_implementation
Definition: IdDictDefs.h:312
IdDictRegion::m_is_empty
bool m_is_empty
Definition: IdDictDefs.h:479
IdDictRange::by_maxvalue
@ by_maxvalue
Definition: IdDictDefs.h:573
IdDictDictionary::m_regions
std::vector< IdDictRegion * > m_regions
Definition: IdDictDefs.h:302
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
mc.group_name
group_name
Definition: mc.PhPy8EG_A14NNPDF23_NNLOPS_example.py:33
IdDictRegion::group_name
std::string group_name() const
Definition: IdDictMgr.cxx:2599
IdDictRange::unknown
@ unknown
Definition: IdDictDefs.h:567
IdDictDictionary::regions_it
regions_type::iterator regions_it
Definition: IdDictDefs.h:293
Debugger::debug
static bool debug()
Definition: IdDictMgr.cxx:26
MuonValidation_CreateResolutionProfiles.fit
def fit(h, emin, emax)
Definition: MuonValidation_CreateResolutionProfiles.py:69
Identifier::ALL_BITS
@ ALL_BITS
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:47
IdDictDictionary::regions_const_it
regions_type::const_iterator regions_const_it
Definition: IdDictDefs.h:294
IdDictLabel::m_valued
bool m_valued
Definition: IdDictDefs.h:350
python.update_ci_reference_files.mr
mr
Definition: update_ci_reference_files.py:415
grepfile.sep
sep
Definition: grepfile.py:38
MultiRange
A MultiRange combines several Ranges.
Definition: DetectorDescription/Identifier/Identifier/Range.h:351
Trk::index2
@ index2
Definition: BoundarySurfaceFace.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Identifier::NBITS
@ NBITS
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:45
IdDictDictionary::m_do_neighbours
bool m_do_neighbours
Definition: IdDictDefs.h:314
Range
A Range describes the possible ranges for the field values of an ExpandedIdentifier.
Definition: DetectorDescription/Identifier/Identifier/Range.h:27
IdDictRange
Definition: IdDictDefs.h:545
impl
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:46
DeMoScan.index
string index
Definition: DeMoScan.py:362
IdDictDictionary::m_subdictionary_names
std::vector< std::string > m_subdictionary_names
Definition: IdDictDefs.h:305
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
IdDictDictionary::m_subregions
std::map< std::string, IdDictSubRegion * > m_subregions
Definition: IdDictDefs.h:301
MultiRange::size
size_type size() const
Definition: DetectorDescription/Identifier/src/Range.cxx:2488
IdDictRange::by_values
@ by_values
Definition: IdDictDefs.h:569
ExpandedIdentifier::clear
void clear()
isNumber
bool isNumber(const std::string &s)
Definition: PoolSvc.cxx:52
IdDictSubRegion
Definition: IdDictDefs.h:503
IdDictRange::by_value
@ by_value
Definition: IdDictDefs.h:568
ExpandedIdentifier::element_type
int element_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:116
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
Range::field
This is the individual specification for the range of one ExpandedIdentifier field.
Definition: DetectorDescription/Identifier/Identifier/Range.h:37
CaloCondBlobAlgs_fillNoiseFromASCII.fields
fields
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:106
IdDictField
Definition: IdDictDefs.h:318
IdDictDictionary::m_file_name
std::string m_file_name
Definition: IdDictDefs.h:309
IdDictFieldImplementation
IdDictFieldImplementation is used to capture the specification of a single field of an Identifier.
Definition: IdDictFieldImplementation.h:58
IdDictDictionary::integrate_bits
void integrate_bits()
Set up integral of bits for efficient unpacking.
Definition: IdDictMgr.cxx:913
IdDictRegion::m_implementation
std::vector< IdDictFieldImplementation > m_implementation
Definition: IdDictDefs.h:474
fitman.k
k
Definition: fitman.py:528