#include <SelectableItem.h>
Selection of an item among a fixed list of items.
The class is designed to have the list of items static, so the class can be used in a constexpr context. In particular, it can be used in a switch statement.
The helper macro @MAKE_SELECTABLE_ITEMS can be used to make the code more concise.
Derived | The class derived from SelectableItem. The CRTP must be used. |
IdType | A type for the indices |
Classes | |
struct | has_deprecation_map |
struct | has_deprecation_map< T, std::void_t< decltype(T::s_deprecationMap)> > |
Protected Attributes | |
id_type | m_selected_id {} |
Public Member Functions | |
constexpr | SelectableItem ()=default |
constexpr | SelectableItem (const std::string_view key) |
std::string_view | key () const |
std::string_view | description () const |
operator std::string_view () const | |
constexpr | operator id_type () const |
bool | operator== (const std::string_view key) |
bool | operator== (const SelectableItem &other) const |
bool | operator!= (const SelectableItem &other) const |
constexpr SelectableItem & | operator= (const std::string_view key) |
void | print (std::ostream &out) const final |
void | readFromStream (std::istream &stream) final |
Static Public Member Functions | |
static constexpr std::size_t | numberOfItems () |
static constexpr const auto & | items () |
static const std::string & | allKeysAsString () |
static const std::string & | dataDescription () |
Protected Member Functions | |
void | keyError (const std::string_view key) |
Static Protected Member Functions | |
static constexpr id_type | findId (const std::string_view key) |
template<id_type... Is> | |
static constexpr id_type | findId_impl (const std::string_view key, std::index_sequence< Is... >) |
|
protected |
|
constexprdefault |
|
inlineconstexpr |
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inlinestaticconstexprprotected |
|
inlinestaticconstexprprotected |
|
inlinestaticconstexpr |
|
inline |
|
inlineprotected |
|
inlinestaticconstexpr |
|
inlineconstexpr |
|
inlineexplicit |
|
inline |
|
inlineconstexpr |
|
inline |
|
inline |
|
inlinefinalvirtual |
Reimplemented from sofa::helper::BaseSelectableItem.
|
inlinefinalvirtual |
Reimplemented from sofa::helper::BaseSelectableItem.