Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • Corryvreckan Corryvreckan
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 33
    • Issues 33
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Issue
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Corryvreckan
  • CorryvreckanCorryvreckan
  • Merge requests
  • !479

Merged
Created Nov 26, 2021 by Simon Spannagel@simonspaOwner

Introduce Enum Reflection

  • Overview 2
  • Commits 7
  • Pipelines 2
  • Changes 11

This MR is modeled after allpix-squared/allpix-squared!483 (merged)

This MR adds the Magic Enum class to allow for enum reflection. An overload of corryvreckan::to_string_impl() and corryvreckan::from_string_impl() for enum types enable parsing configuration keys directly into enums:

enum class FileType {
    ROOT,
    TXT,
    CSV,
};

auto model = config.get<FileType>("file_type");
if(model == FileType::ROOT) {
    // do sth
}

without odd string comparisons. If the requested key does not exist in the enum, an error message with all available options is printed, emulating the behavior of the manual else printouts used in string comparisons so far:

|23:08:27.240|   (FATAL) [C:SomeModule:dut] Error in the configuration:
                                            Could not convert value '"spock"' from key 'model' in section 'SomeModule' to type SomeModule::DepositionModel: invalid value, possible values are: mine, yours, theirs
                                            The configuration needs to be updated. Cannot continue.
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: enum