Improve robustness of RelatedInfoMap indexing
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 (ofstd::string
type, e.g. "CONE_PX") toshort int
indices that should be used as keys when filling theRelatedInfoMap
- 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
anunsigned 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)
Edited by Thomas Latham
Merge request reports
Activity
Please register or sign in to reply