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

Selection of multiple enum value from a list of candidates. More...

Detailed Description

Selection of multiple enum value from a list of candidates.

See also
neml2::EnumSelectionBase

#include <MultiEnumSelection.h>

Inheritance diagram for MultiEnumSelection:

Public Member Functions

 MultiEnumSelection ()=default
 
 MultiEnumSelection (const std::vector< std::string > &candidates, const std::vector< std::string > &selections)
 Create a multi-enum selection from a list of candidates and default selections.
 
 MultiEnumSelection (const std::vector< std::string > &candidates, const std::vector< int > &values, const std::vector< std::string > &selections)
 Create a multi-enum selection from a list of candidates, their corresponding values, and default selections.
 
void select (const std::vector< std::string > &selections)
 
bool operator== (const MultiEnumSelection &other) const
 Test for inequality.
 
bool operator!= (const MultiEnumSelection &other) const
 Test for inequality.
 
 operator std::vector< std::string > () const
 Poor man's reflection implementation.
 
 operator std::vector< int > () const
 Selected values cast to int.
 
template<typename T >
std::vector< T > as () const
 Statically cast the enum value to a C++ enum class.
 
- Public Member Functions inherited from EnumSelectionBase
 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.
 

Additional Inherited Members

- Protected Attributes inherited from EnumSelectionBase
std::unordered_map< std::string, int_candidate_map
 Mapping enum options to int.
 

Constructor & Destructor Documentation

◆ MultiEnumSelection() [1/3]

MultiEnumSelection ( )
default

◆ MultiEnumSelection() [2/3]

MultiEnumSelection ( const std::vector< std::string > & candidates,
const std::vector< std::string > & selections )

Create a multi-enum selection from a list of candidates and default selections.

◆ MultiEnumSelection() [3/3]

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

Create a multi-enum selection from a list of candidates, their corresponding values, and default selections.

Member Function Documentation

◆ as()

template<typename T >
std::vector< T > as ( ) const
inline

Statically cast the enum value to a C++ enum class.

◆ operator std::vector< int >()

operator std::vector< int > ( ) const
inline

Selected values cast to int.

◆ operator std::vector< std::string >()

operator std::vector< std::string > ( ) const
inline

Poor man's reflection implementation.

◆ operator!=()

Test for inequality.

◆ operator==()

bool operator== ( const MultiEnumSelection & other) const

Test for inequality.

◆ select()

void select ( const std::vector< std::string > & selections)

Select new values

Note
This will clear the current selection