NEML2 2.0.0
Loading...
Searching...
No Matches
EnumSelectionBase Class Reference

Detailed Description

Our poor man's implementation of enum reflection. This is a necessary ingredient for bridging runtime string parsed from input files and static enum types.

For developers, this class shall only be used for parsing purposes during the setup phase. Avoid directly working with this class at model evaluation phase at all cost!

#include <EnumSelectionBase.h>

Inheritance diagram for EnumSelectionBase:

Public Member Functions

 EnumSelectionBase ()=default
 
 EnumSelectionBase (const std::vector< std::string > &candidates)
 Create an enum selection from a list of candidates.
 
 EnumSelectionBase (const std::vector< std::string > &candidates, const std::vector< int > &values)
 Create an enum selection from a list of candidates and their corresponding values.
 
const std::unordered_map< std::string, int > & candidates () const
 Candidates.
 
std::string candidates_str () const
 Stringified candidates.
 

Protected Attributes

std::unordered_map< std::string, int_candidate_map
 Mapping enum options to int.
 

Constructor & Destructor Documentation

◆ EnumSelectionBase() [1/3]

EnumSelectionBase ( )
default

◆ EnumSelectionBase() [2/3]

EnumSelectionBase ( const std::vector< std::string > & candidates)

Create an enum selection from a list of candidates.

◆ EnumSelectionBase() [3/3]

EnumSelectionBase ( const std::vector< std::string > & candidates,
const std::vector< int > & values )

Create an enum selection from a list of candidates and their corresponding values.

Member Function Documentation

◆ candidates()

const std::unordered_map< std::string, int > & candidates ( ) const
inline

Candidates.

◆ candidates_str()

std::string candidates_str ( ) const

Stringified candidates.

Member Data Documentation

◆ _candidate_map

std::unordered_map<std::string, int> _candidate_map
protected

Mapping enum options to int.