Project

General

Profile

Feature #6592

Switch enum-to-string macro functionality to templated detail class

Added by Kyle Knoepfel over 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Start date:
07/07/2014
Due date:
% Done:

0%

Estimated time:
Duration:

Description

We have various instances in the Mu2e Offline where enum-to-string matching is implemented using macros:

MCDataProducts/inc/GenId.hh
MCDataProducts/inc/ProcessCode.hh
MCDataProducts/inc/VirtualDetectorId.hh
MCDataProducts/inc/StepInstanceName.hh

Classes exist that do this in an entirely C++ designed fashion, for example:

GeneralUtilities/inc/EnumToStringSparse.hh

And implementations of this exist here (e.g.)

Mu2eUtilities/inc/ProtonPulseRandPDF.hh

Moving to a C++ based approach for this is certainly desirable. However, there still exist certain problems. Anyone adding a new enum instance must also specify an enum-to-string assignment later on (via a map in the sparse case, or a vector in the dense case), similarly to what has to be done now (although an explicit enum-to-string assignment can be done with the new method). An improvement is to use an X macro, where the enum instance/string name need only be specified in one place, and the C preprocessor references the macro to do the assignment for you. This may be the route to go since a potential enum-to-string mismatch is avoided. An example of how this is used is here:

SeedService/inc/SeedService.hh

In any case, this should be thought through. At the very least, switching enum-to-string matching methods will require changes to the xml file that reads in/persists the root-file data products. A way of handling that has been suggested by Philippe Canal and is attached. Once a new enum-to-string method has been developed the following tests should be run:

(1) Run new code with new files (input and output)
(2) Run new code with old files for input and new files for output
(3) Run new code with old and new files (in series) as input and new files for output

Re_ genreflex_streamer question.rtf (3.33 KB) Re_ genreflex_streamer question.rtf Kyle Knoepfel, 07/07/2014 10:21 AM


Also available in: Atom PDF