Skip to content
Snippets Groups Projects

Improve robustness of RelatedInfoMap indexing

Merged Thomas Latham requested to merge tlatham_relatedinfomap_optional into master

Triggered by comment threads: Rec!4251 (comment 9013828) and Rec!4251 (comment 9013825) and subsequent discussions with @graven

The goal of this MR is to:

  • Create in the C++ a compile-time-constant versioned dictionary that, for each unsigned int version number, relates a set of labels (of std::string type, e.g. "CONE_PX") to short int indices that should be used as keys when filling the RelatedInfoMap
  • Create also a compile-time constant that indicates the latest version of the dictionary
  • Version 0 of the dictionary should be empty
  • The integrity of this versioned dictionary needs to be guaranteed by tests that ensure that the relations between a given label and an index cannot be modified for any existing versions
  • Add to RelatedInfoMap an unsigned int data member to represent the version number of the dictionary that will be used to determine its keys, and add a new constructor that can specify this version number
  • Modify the packing/unpacking code for RelatedInfoMap to handle the version number data member - the unpacking should also handle its potential absence when reading "old" data, in which case it should be set to the special 0 value
  • Add to RelatedInfoMap an accessor based on the string label, which will use the version number data member and the dictionary to lookup the index to be retrieved and finally return the corresponding value (or an empty optional in case of any error, e.g. label not in dictionary or index not found in the map)

cc: @mmonk @fswystun @malehura @ghallett @tfulghes

Edited by Thomas Latham

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading