Open knoepfel opened 3 years ago
Comment by @knoepfel on 2019-05-13 15:26:26
This feature requires a design discussion. Although it seems to be a valuable feature to add, it is not clear to what extent the project:fhicl-cpp package can easily support this. We will get back to you.
This issue has been migrated from https://cdcvs.fnal.gov/redmine/issues/22574 (FNAL account required) Originally created by @PetrilloAtWork on 2019-05-09 23:09:29
I would like to request support in FHiCL C++ interface for multiple choice values. I am going with an...
Example
Here
unit
is a configuration parameter of integral type (int
) that may represent three choices: GeV (1
), MeV (2
) and megajoule (3
).Configuration data structure
If the default value is omitted, the parameter is mandatory. Otherwise, its value must match a supported choice, or else a
logic_error
type of exception will be thrown at run time.Configuration FHiCL table
Description on console screen
User code to access the values
Throws a
art::error::Configuration
type ofart::Exception
(or equivalent) if the value is not acceptable.Bonus points
Additional candies:
enum
and/orenum class
typesfhicl::ChoiceSequence
)std::string
instead ofint
it will save replicating theName
into the value on each entry"MJ"
and"megajoule"
both supported and associated to the same value3
; if3
is the default value, it will be written in the description as the first of the matching choices)